PureBytes Links
Trading Reference Links
|
I'm emailing you a modified script file with your file name inserted
into it. Save this file to the same directory where your data file
exists. My script looks for the following data: Ticker, marketID,
fullname, industryID. The ID's are integers starting with 0.
Example: MCOM,3,Metricom,78 The 1 puts in market ID 3 which I've
called NASDAQ and the 78 would put into the industry group
represented by 78 in the broker.industries file.
Brett
--- In amibroker@xxxx, acs64@xxxx wrote:
> Brett,
>
> No luck. I've got the script file setup but when I try to run it I
> keep getting errors. First time it was ';' was expected......so I
> added it where I thought it might go, then it was '{' was expected,
> but I dont have any idea where it is missing....I dont have any
> experience with writing this script, so I'm way in over my head.
I'm
> not importing from TC2000 (is that metastock or something?), maybe
> that has something to do with it? The name of my file to import is
> Tick_Mkt_Name_Ind_Sect.csv. I changed the script where I thought
> this had to be inserted, there was also another reference to
> filename....should I put my file name here also?
>
> Confused,
>
> Larry
>
> --- In amibroker@xxxx, brett_f1@xxxx wrote:
> > Yes, I update at night. I export two data files out of TC2000
> > into .csv files and then run two scripts from within Ami to get
the
> > data into it. The exports from TC2000 take about 2 minutes and
the
> > imports even less than that. Saving the database though takes
> around
> > 5 minutes. My current difficulty is assigning new tickers from
> > TC2000 to the correct Markets and industries. I've asked Tomasz
if
> > he can help me with a script to move the tickers out of Group 255
> > into a .csv file. If I can get that, I can go through several
> other
> > steps to get them assigned correctly...I hope to get it all
> automated
> > soon!
> >
> > Brett
> >
> > --- In amibroker@xxxx, acs64@xxxx wrote:
> > > Hey Brett,
> > >
> > > Yeah, it does help. When I get home I'll try it out. There's
a
> > lot
> > > of ins and outs to the program, but thanks to help from people
> like
> > > you, others and Tomasz, it's a lot easier than it could be.
Have
> > you
> > > updated quotes into the database? It must take awhile to do
that
> > > every night, or are you doing it on weekends? Thanks for the
> help.
> > >
> > > Larry
> > >
> > > --- In amibroker@xxxx, brett_f1@xxxx wrote:
> > > > Hi Larry,
> > > >
> > > > I'm new to AmiBroker as well. I guess I've just been
pounding
> on
> > > my
> > > > head a bit harder. Come to think of it now, I do have a bit
of
> a
> > > > headache today <g>.
> > > >
> > > > The .js file can be run from within AmiBroker or not. It
> really
> > > does
> > > > not matter (if I recall correctly). To run it in Amibroker,
> save
> > > the
> > > > file in the scripts folder of Ami. Then go to tools,
> customize.
> > > > Click New. Give it a name. On the command line, browse to
the
> > > > script file you saved and highlight it. Close out. The next
> > time
> > > > you go Tools menu there will be a new item listed with the
name
> > you
> > > > assigned to the script file!
> > > >
> > > > The two broker files (sector and industries) that you create
> must
> > > > first exist in the new workspace before you create the
> database.
> > > > There is a way around this by deleting a file but I do not
> recall
> > > the
> > > > name right now...
> > > >
> > > > If the database is created this way, the assignments you made
> in
> > > > sectors and industries will govern the setup up the database
> and
> > > the
> > > > subsequent population of the tickers and data.
> > > >
> > > > Does this help?
> > > >
> > > > Brett
> > > >
> > > > --- In amibroker@xxxx, acs64@xxxx wrote:
> > > > > 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
|