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

Re: Importing ticker, market, industry and sector



PureBytes Links

Trading Reference Links

Hi Brett,

I'm afraid I dont know enough about about this now to be able to do 
the import....You said the code that you supplied should be cut and 
paste into a .js file. How is this file started from within 
Amibroker? Also, the broker.sector and broker.market files....do the 
categories from within them need to match the setup in the database 
file exactly? I assume they do, but not sure. I have setup a new 
blank workspace. It appears the data I downloaded is the same as the 
file that you uploaded to the files area of this group. I can 
understand why one wouldnt need the industry and sector since they 
are similar to each other.

I'm new to Amibroker, so I probably need to have the most basic of 
steps explained along the way, otherwise I'll miss something. Thanks 
for the help.....

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