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

[amibroker] Re: Import Industry Assignments



PureBytes Links

Trading Reference Links

Never mind. I figured it out. Here's what I added just below the 
stock.IndustryID variable:

stock.MarketID = parseInt( fields[ 3 ] );

However, in your Industries.csv file you'll need another column with 
the zero-based integer number for the market you are adding to.

-ace

--- In amibroker@xxxxxxxxxxxxxxx, acesheet@xxxx wrote:
> Graham,
> 
> Thanks for posting all this information. Just knowing how to do 
this 
> is a huge load off my database setup chores. I did it and it 
worked 
> perfectly.
> 
> I have one more question, however. How can I assign the market 
> category using the javascript file? I assume it would have to be 
> some other sort of 'stock.****' variable, but I'm not a java 
> programmer and I'm not sure of the syntax that would be required.
> 
> Thanks.
> 
> -ace
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "Graham" <gkavanagh@xxxx> wrote:
> > Harvey, the js file below is a newer (or at least different) 
> version to the
> > one I use. 
> > Here is the full file I use and I find it works :) 
> > Seems the one enhancement I did is now in the newer js file, 
> message to say
> > it is finished.
> >  
> >  
> > /* change this line according to your data file name */
> >  
> > var filename = "Industries.csv";
> > 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);
> >  
> > /* read the file line by line */
> > while ( !f.AtEndOfStream )
> > {
> >  
> > r = f.ReadLine();
> >  
> > /* split the lines using comma as a separator */
> > fields = r.split(","); 
> >  
> > /* add a ticker - this is safe operation, in case that */
> > /* ticker already exists, AmiBroker returns existing one */
> > stock = AmiBroker.Stocks.Add( fields[ 0 ] ); 
> >  
> > stock.FullName = fields[ 1 ];
> > stock.IndustryID = parseInt( fields[ 2 ] );
> >  
> > 
> > }
> >  
> > /* refresh ticker list and windows */
> > AmiBroker.RefreshAll();
> >  
> > 
> > WScript.Echo("Industry Setup Finished" );
> >  
> >  
> > 
> > Cheers,
> > Graham
> > http://groups.msn.com/asxsharetrading
> > http://groups.msn.com/fmsaustralia 
> > 
> > -----Original Message-----
> > From: harveyhp [mailto:harveyhp@x...] 
> > Sent: Monday, 8 December 2003 6:34 PM
> > To: amibroker@xxxxxxxxxxxxxxx
> > Subject: RE: [amibroker] Import Industry Assignments
> > 
> > 
> > Graham,
> > 
> > Many thanks for your further advice.  Below is the 
> file "Industries.js" as
> > downloaded from the link on the last line of Newsletter 04-
2000.  
> Would you
> > be kind enough to look over this script to see if anything needs 
> to be
> > changed?  I have named my file "industry_data.txt" exactly as in 
> the
> > example.  Both files are in a sub-folder within the AB folder.
> > 
> > Following your message I have tried adding a line:
> > 
> > var filename = "industry_data.txt"
> > 
> > once before the line that starts "/* change this line . . . ", 
and 
> another
> > time following "var Stock;", to no avail.  I can find nothing in 
> the archive
> > that indicates a problem.  I have checked my data file (again) 
for
> > formatting errors, but first I have to get this script to find 
the 
> file.
> > 
> > Thanks again,
> > 
> > HHP
> > =========================================
> > 
> > /*
> > ** 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("industry_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.FullName = fields[ 1 ];
> > 
> >                         stock.IndustryID = parseInt( fields[ 
2 ] );
> >                 }
> >                 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();
> > 
> > }
> > 
> > =============================================================
> > 
> > At 11:06 PM 07/12/2003, you wrote:
> > 
> > 
> > 1st check that the file with the industry data is correctly 
> identified in
> > the js file. If you have both the js file and the data file in 
the 
> same
> > directory you do not need to use the directory structure to 
refer 
> to it in
> > the js file. I just have them both in a subdirectory wiuthin Ab 
> called
> > /scripts/
> >  
> > Here is the reference for it from my js file
> >  
> > var filename = "Industries.csv";
> >  
> > Another thing to watch for is that your names etc in the lists 
are 
> firstly
> > separated by commas, and you do not have any extra commas within 
> the names.
> > I have found this in the list I get from the ASX of companies 
and 
> their
> > sectors that the names often have commas within them. These 
extra 
> commas
> > need to be removed.
> >  
> > Hope this helps a little
> >  
> > 
> > Cheers,
> > Graham
> > http://groups.msn.com/asxsharetrading
> > http://groups.msn.com/fmsaustralia 
> > 
> > 
> > -----Original Message-----
> > 
> > 
> > From: harveyhp [mailto:harveyhp@x...] 
> > 
> > 
> > Sent: Monday, 8 December 2003 2:42 PM
> > 
> > 
> > To: amibroker@xxxxxxxxxxxxxxx
> > 
> > 
> > Subject: RE: [amibroker] Import Industry Assignments
> > 
> > 
> > 
> > Thanks, Graham, but I'm still not out of the woods.  I've tried 
> placing both
> > files "Industries.js" and "industry_data.txt" in the Amibroker 
> folder, in a
> > separate folder within the Amibroker folder, and in the database 
> folder
> > (also within the Amibroker folder).  When I double-click 
> on "Industries.js"
> > the script starts but then I immediately get a "File not found" 
> error:
> > 
> > 
> > 
> > Windows Script Host
> > 
> > 
> > 
> > Script:    F:\Invest\Amibroker\DB_GP\Industries.js
> > 
> > 
> > Line:      38
> > 
> > 
> > Char:     2
> > 
> > 
> > Error:     File not found
> > 
> > 
> > Code:    800A0035
> > 
> > 
> > Source: Microsoft JScript runtime error
> > 
> > 
> > 
> > Would appreciate any advice.
> > 
> > 
> > Thanks,
> > 
> > 
> > HHP
> > 
> > 
> > =====================
> > 
> > 
> > 
> > At 05:01 PM 07/12/2003, you wrote:
> > 
> > 
> > 
> > Open AB with the database that you want to update
> > 
> > 
> > Then in windows explorer double click on the js file
> > 
> > 
> > 
> > Cheers,
> > 
> > 
> > Graham
> > 
> > 
> > http://groups.msn.com/asxsharetrading
> > 
> > 
> > http://groups.msn.com/fmsaustralia 
> > 
> > 
> > 
> > -----Original Message-----
> > 
> > 
> > From: harveyhp [mailto:harveyhp@x...] 
> > 
> > 
> > Sent: Monday, 8 December 2003 8:39 AM
> > 
> > 
> > To: amibroker@xxxxxxxxxxxxxxx
> > 
> > 
> > Subject: [amibroker] Import Industry Assignments
> > 
> > 
> > 
> > 
> > I am setting up a new database.  The Sector and Industry 
> categories are set 
> > 
> > 
> > up.  Next is to import the stock Symbols, Names and Industry 
> Assignments as 
> > 
> > 
> > described in Newsletter 04-2000.  I have created a sub-folder 
> within the 
> > 
> > 
> > Amibroker folder which contains "industries.js" and a correctly 
> formatted 
> > 
> > 
> > "industry_data.txt" file of the symbols, names and industry 
> numbers.  So 
> > 
> > 
> > far so good.  My question is: How do I ensure that when I run 
> > 
> > 
> > "industries.js" the data is imported into the new database and 
not 
> into 
> > 
> > 
> > another existing database?
> > 
> > 
> > Thanks,
> > 
> > 
> > HHP
> > 
> > 
> > ===================
> > 
> > 
> > 
> > 
> > 
> > ------------------------ Yahoo! Groups Sponsor ------------------
--
> -~--> Buy
> > 
> > 
> > Ink Cartridges or Refill Kits for your HP, Epson, Canon or 
Lexmark 
> Printer
> > 
> > 
> > at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
> > 
> > 
> > http://www.c1tracking.com/l.asp?cid=5511
> > 
> > 
> > http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
> > 
> > 
> > -----------------------------------------------------------------
--
> --~->
> > 
> > 
> > 
> > Send BUG REPORTS to bugs@xxxx
> > 
> > 
> > Send SUGGESTIONS to suggest@xxxx
> > 
> > 
> > -----------------------------------------
> > 
> > 
> > Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
> > 
> > 
> > (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> > 
> > 
> > --------------------------------------------
> > 
> > 
> > Check group FAQ at:
> > 
> > 
> > http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
> > 
> > 
> > 
> > Your use of Yahoo! Groups is subject to 
> http://docs.yahoo.com/info/terms/ 
> > 
> > 
> > 
> > 
> > Yahoo! Groups Sponsor 
> > 
> > 
> > ADVERTISEMENT
> > 
> > 
> >  
> > 
> 
<http://rd.yahoo.com/SIG=12cjho951/M=267637.4116730.5333196.1261774/D
> =egroup
> > 
> 
web/S=1705632198:HM/EXP=1070931713/A=1853618/R=0/*http://www.netflix.
> com/Def
> > ault?mqso=60178338&partid=4116730> click here
> > 
> > 
> >  []
> > <http://us.adserver.yahoo.com/l?
> M=267637.4116730.5333196.1261774/D=egroupmai
> > l/S=:HM/A=1853618/rand=171033672> 
> > 
> > 
> > 
> > Send BUG REPORTS to bugs@xxxx
> > 
> > 
> > Send SUGGESTIONS to suggest@xxxx
> > 
> > 
> > -----------------------------------------
> > 
> > 
> > Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
> > 
> > 
> > (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> > 
> > 
> > --------------------------------------------
> > 
> > 
> > Check group FAQ at:
> > http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
> > 
> > 
> > 
> > Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> > <http://docs.yahoo.com/info/terms/> Service. 
> > 
> > 
> > 
> > Send BUG REPORTS to bugs@xxxx
> > 
> > 
> > Send SUGGESTIONS to suggest@xxxx
> > 
> > 
> > -----------------------------------------
> > 
> > 
> > Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
> > 
> > 
> > (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> > 
> > 
> > --------------------------------------------
> > 
> > 
> > Check group FAQ at:
> > http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
> > 
> > 
> > 
> > Your use of Yahoo! Groups is subject to the Yahoo! Terms of 
Service
> > <http://docs.yahoo.com/info/terms/> . 
> > 
> > 
> > 
> > 
> > Yahoo! Groups Sponsor 
> > ADVERTISEMENT
> >  
> > 
> 
<http://rd.yahoo.com/SIG=12ckmf6t4/M=267637.4116732.5333197.1261774/D
> =egroup
> > 
> 
web/S=1705632198:HM/EXP=1070953588/A=1853618/R=0/*http://www.netflix.
> com/Def
> > ault?mqso=60178338&partid=4116732> click here
> >  []
> > <http://us.adserver.yahoo.com/l?
> M=267637.4116732.5333197.1261774/D=egroupmai
> > l/S=:HM/A=1853618/rand=841083675> 
> > 
> > Send BUG REPORTS to bugs@xxxx
> > Send SUGGESTIONS to suggest@xxxx
> > -----------------------------------------
> > Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
> > (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> > --------------------------------------------
> > Check group FAQ at:
> > http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
> > 
> > Your use of Yahoo! Groups is subject to the Yahoo! Terms of 
Service
> > <http://docs.yahoo.com/info/terms/> . 
> > 
> > 
> > Yahoo! Groups Sponsor	
> >  
> > 
> 
<http://rd.yahoo.com/SIG=12c665o56/M=259395.3614674.4902533.1261774/D
> =egroup
> > 
> 
web/S=1705632198:HM/EXP=1070966050/A=1524963/R=0/*http://hits.411web.
> com/cgi
> > -bin/autoredir?camp=556&lineid=3614674&prop=egroupweb&pos=HM> 
> 	
> >  
> > <http://us.adserver.yahoo.com/l?
> M=259395.3614674.4902533.1261774/D=egroupmai
> > l/S=:HM/A=1524963/rand=756158820> 	
> > 
> > Send BUG REPORTS to bugs@xxxx
> > Send SUGGESTIONS to suggest@xxxx
> > -----------------------------------------
> > Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
> > (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> > --------------------------------------------
> > Check group FAQ at:
> > http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
> > 
> > Your use of Yahoo! Groups is subject to the Yahoo! Terms of 
Service
> > <http://docs.yahoo.com/info/terms/> .


Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->

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/