[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: rename script



PureBytes Links

Trading Reference Links

Once Amiquote doesn't support "Symbol Translation Table" for Yahoo 
Current update. I need a scrippt to rename symbols in my database.
I tried this but didn't work.

/*
** AmiBroker/Win32 scripting Example
**
** File:	 Industries.js
** Created:  Tomasz Janeczko, November 26th, 2000
** Last updated: Tomasz Janeczko, December 17th, 2000
** Purpose:  Import industy assignments
** Language:	 JavaScript (Windows Scripting Host)
**
** The data is stored in lines with following format
** <ticker>,<full name>,<industry number>
**
*/

WScript.Echo( "Script Started" );

/* change this line according to your data file name */
ImportStocks("yahoo_data.txt");

WScript.Echo( "Finished" );

function ImportStocks( filename )
{
	var fso, f, r;
	var ForReading = 1;
	var AmiBroker;
	var fields;
	var stock;


	/* Create AmiBroker app object */
	AmiBroker = new ActiveXObject( "Broker.Application" );

	/* ... and file system object */
	fso = new ActiveXObject( "Scripting.FileSystemObject" );

	/* open ASCII file */
	f = fso.OpenTextFile( filename, ForReading);

	i = 1;
	/* read the file line by line */
	while ( !f.AtEndOfStream )
	{
		r =  f.ReadLine();
		
		/* split the lines using comma as a separator */
		fields = r.split(","); 
		
		try
		{
			
			/* add a ticker - this is safe operation, in 
case that	 */
			/* ticker already exists, AmiBroker returns 
existing one */
			stock = AmiBroker.Stocks.Add( fields[ 0 ] ); 
				
			stock.ticker = fields[ 1 ];


		}
		catch( e )
		{
				WScript.echo( "There is a problem in 
line no." + i + ".\nThe line looks as follows:\n'" + r + "'\nIt will 
be skipped and next lines will be processed as normal" );
		}
					
		i++;	
	}

	/* refresh ticker list and windows */
	AmiBroker.RefreshAll();

}







------------------------ Yahoo! Groups Sponsor --------------------~--> 
Try Online Currency Trading with GFT. Free 50K Demo. Trade 
24 Hours. Commission-Free. 
http://us.click.yahoo.com/RvFikB/9M2KAA/U1CZAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/