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

Re: Importing ticker, market, industry and sector



PureBytes Links

Trading Reference Links

Thanks a million Brett. It is early morning where I am right now, 
but after work tonight I will give it a try. It took about 6 hours 
of downloading from Yahoo to get the historical data last night 
mainly because there are over 9,000 stocks in the list. Can you 
imagine trying to categorize these by hand?! Ouch......thanks again.

Larry

--- In amibroker@xxxx, brett_f1@xxxx wrote:
> I can relate to that! I ported over my entire TC2000 database over 
> several times before i got it right.
> 
> I suggest you first be sure that you have your broker.sectors and 
> broker.industries files set up correctly and working in a fresh 
> workspace (database). Then set up your Markets by setting up the 
> market names in Stock, Categories.
> 
> Then cut and paste the following text into a file and give it a 
name 
> with a .js extension - perhaps ImportTickers&Industries.js
> 
> /*
> ** 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>
> **
> ** Modified 5/6/2001 by Brett Forrester
> */
> 
> /* script for importing TC2000 ticker, market, full name, and 
> industry assignment number */
> 
> WScript.Echo( "Script Started" );
> 
> /* change this line according to your data file name */
> ImportStocks("tick_mkt_name_ind.csv");
> 
> 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 ] ); 
> 
> /* add following line - blf */
> stock.MarketID = parseInt( fields[ 1 ] );
> 
> stock.FullName = fields[ 2 ];
> 
> stock.IndustryID = parseInt( fields[ 3 ] );
> }
> 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();
> 
> }
> 
> ================End Cut and Paste==============
> 
> This script will look for Ticker, MarketID (0 to n), Stock Name, 
and 
> Industry ID (0 to n). You do not need the sector ID because it is 
> implied from the industry assignment.
> 
> When you're comfortable with this turnout, SAVE your database. Now 
> you have the structure set up and your ready to import data.
> 
> This worked for me. I'm sure Tomasz will chime in if I'm right or 
> wrong. I found it best to start with a clean empth database 
without 
> any sample data existing what so ever.
> 
> Brett
> 
> --- In amibroker@xxxx, acs64@xxxx wrote:
> > Hello all,
> > 
> > I have created a large .csv file with ticker symbols, market, 
> > industry and sector. I would like to be able to load the whole 
> list 
> > with all data in one shot into Ami but am not sure how to do it. 
I 
> > have tried using the import wizards but the fields do not seem to 
> > fit. Is there some coding required to make it work? Any help 
> would 
> > be greatly appreciated. Thanks
> > 
> > Larry