Access Text File on FTP - problem

Hello! I am trying to have Amibroker read the following text file which is on an FTP server. I wrote the following code with a button that accesses the site and should show the data. It does access the main site

ftp://shortstock: @ftp3.interactivebrokers.com

but not when I add "/usa.txt" to the link. What do I need to change here?

id = GuiGetEvent( 0, 0 );
event = GuiGetEvent( 0, 1 );

GuiButton( "DATA", 23, 10, 20, 155, 30, 7 );
if( id == 23 && event == 1 )
{
	ih = InternetOpenURL( "ftp://shortstock: @ftp3.interactivebrokers.com/usa.txt" ); 
	_TRACE(""+ih);
	
	if( ih ) 
	{ 
		 while( ( str = InternetReadString( ih ) ) != "" ) 
		 { 
			 printf( "%s", str ); 
		 } 
		 InternetClose( ih ); 
	}
	

}


It requires IB login to download the file. That could be the possible reason.

Amibroker access the site ok

ftp://shortstock: @ftp3.interactivebrokers.com/

It includes the username and (empty) password in the link.
But not the txt file.

I have just tested it using ParamTrigger and it works

if( ParamTrigger( "Download TXT from IB", "Click" ) )
{
	ih = InternetOpenURL( "ftp://shortstock: @ftp3.interactivebrokers.com/usa.txt" ); 
	_TRACE(""+ih);
	
	if( ih ) 
	{ 
		 while( ( str = InternetReadString( ih ) ) != "" ) 
		 { 
			 printf( "%s", str ); 
		 } 
		 InternetClose( ih ); 
	}
}
1 Like

Not getting anything from this click in the Interpretation. Just a 0 in TRACE. How does the output look like for you?

It works here

ib

Not for me. Tried restarting Amibroker, but still. I can access the file on the browser.

Check firewall or anti antivirus

That's all turned off. ftp://shortstock: @ftp3.interactivebrokers.com works but not the text file.

Hi Guys, Just tried this. I can paste the link into AB's WebResearch window (address shortens when you click on GO to "ftp://ftp3.interactivebrokers.com/usa.txt") and it works (get the file like @codejunkie posted) . So not sure what the "shortstock: @" does. I assume it was meant as login and password.

If I try to use the button, it won't pass the Verify Syntax check. I get an "Error 47. Exception - 550 Failed to change directory."

If I try with the shortened version, I get an error 47. Exception - The login request was denied."

Not sure what else to try.

Works on Amibroker's web search for me, too.

What do you receive if not using any trigger?

//if( ParamTrigger( "Download TXT from IB", "Click" ) )
{
	ih = InternetOpenURL( "ftp://shortstock: @ftp3.interactivebrokers.com/usa.txt" ); 
	_TRACE(""+ih);
	
	if( ih ) 
	{ 
		 while( ( str = InternetReadString( ih ) ) != "" ) 
		 { 
			 printf( "%s", str ); 
		 } 
		 InternetClose( ih ); 
	}
}

Error in Syntax occurs on the ih=InternetOpenURL line each time.

OK, Googling lots gives me the format of:

ftp://userid:password@hostname

Stumped with how to get the filename as part of the request.

The file adress is the one given by trongart and download is working fine for me.

ftpfile = "ftp://shortstock: @ftp3.interactivebrokers.com/usa.txt";

Which AmiBroker version are you running?

@codejunkie, doing the same one. Just can't get it to work in code.

When I strip off the "/usa.txt" I get the contents of the page. But when I try to speicify the file I get the syntax errors.

From my googling I confirmed that shortstock is the userid, blank is the password, and the "@ftp..." is the host name. So not sure how to specify the file, or why it works for you. Have tried several variations:
"ftp://shortstock: @ftp3.interactivebrokers.com/usa.txt" - the original - Syntax Error - Directory
"ftp://shortstock: @ftp3.interactivebrokers.com /usa.txt" - Syntax Error - server name not resolved
"ftp://shortstock: @ftp3.interactivebrokers.com//usa.txt" - Syntax Error - Directory
"ftp://shortstock: @ftp3.interactivebrokers.com usa.txt" - Syntax Error - server name not resolved
"ftp://shortstock: @ftp3.interactivebrokers.com" - Outputs directory of files
"ftp://shortstock: @ftp3.interactivebrokers.com //usa.txt" - Syntax Error - Directory

So not sure what else to try.

What magic are you using to get this working? I use Amibroker 6.28.0.

If I don't use a trigger, I get this error: Warning 507: Internet error: 505 Failed to change directory.

I'm also trying to resolve this issue, but until now with no luck ...

I'm able to display the content of this file in a web browser. When I enter this url:

ftp://shortstock: @ftp3.interactivebrokers.com/usa.txt

... I get this result:

FTP

... but I get this Error in AmiBroker:

FTP%20Error

1 Like

All,

I am using AB 6.20.1 64 bit on W10 Pro

I don't get past the AFL Verify Syntax.

InternetOpenURL relies on Internet Explorer and IE does not support this feature because username and password is clear text, and is a security problem

1 Like