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

RE: [amibroker] Import Industry Assignments



PureBytes Links

Trading Reference Links




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<A 
href="">http://groups.msn.com/asxsharetrading<A 
href="">http://groups.msn.com/fmsaustralia 


  
  <FONT 
  face=Tahoma size=2>-----Original Message-----From: harveyhp 
  [mailto:harveyhp@xxxxxxx] Sent: Monday, 8 December 2003 6:34 
  PMTo: amibroker@xxxxxxxxxxxxxxxSubject: RE: [amibroker] 
  Import Industry AssignmentsGraham,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<A 
    href="">http://groups.msn.com/asxsharetrading<A 
    href="" 
    eudora="autourl">http://groups.msn.com/fmsaustralia 
    
      -----Original Message-----
      From: harveyhp [<A href="" 
      eudora="autourl">mailto:harveyhp@xxxxxxx] 
      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
        <A 
        href="">http://groups.msn.com/asxsharetrading
        <A href="" 
        eudora="autourl">http://groups.msn.com/fmsaustralia 
        -----Original Message-----
        From: harveyhp [<A href="" 
        eudora="autourl">mailto:harveyhp@xxxxxxx] 
        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.
        <A 
        href="">http://www.c1tracking.com/l.asp?cid=5511
        <A href="" 
        eudora="autourl">http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
        ---------------------------------------------------------------------~->
        Send BUG REPORTS to bugs@xxxxxxxxxxxxx
        Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
        -----------------------------------------
        Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 

        (Web page: <A 
        href="">http://groups.yahoo.com/group/amiquote/messages/)
        --------------------------------------------
        Check group FAQ at:
        <A 
        href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
        
        Your use of Yahoo! Groups is subject to <A 
        href="">http://docs.yahoo.com/info/terms/ 
        
        Yahoo! Groups Sponsor 
        ADVERTISEMENT
        <A 
        href=""><IMG 
        height=250 alt="click here" 
        src="" 
        width=300 NOSEND="1">
        <IMG height=1 alt=[] 
        src="" 
        width=1 NOSEND="1">
        Send BUG REPORTS to bugs@xxxxxxxxxxxxx
        Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
        -----------------------------------------
        Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 

        (Web page: <A 
        href="">http://groups.yahoo.com/group/amiquote/messages/)
        --------------------------------------------
        Check group FAQ at: <A 
        href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
        
        Your use of Yahoo! Groups is subject to the <A 
        href="">Yahoo! Terms of 
        Service. 
      Send BUG REPORTS to bugs@xxxxxxxxxxxxx
      Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
      -----------------------------------------
      Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
      (Web page: <A 
      href="">http://groups.yahoo.com/group/amiquote/messages/)
      --------------------------------------------
      Check group FAQ at: <A 
      href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
      
      Your use of Yahoo! Groups is subject to the <A 
      href="">Yahoo! Terms of Service. 
      Yahoo! Groups 
    Sponsor ADVERTISEMENT<A 
    href=""><IMG 
    height=250 alt="click here" 
    src="" 
    width=300 NOSEND="1"><IMG height=1 alt=[] 
    src="" 
    width=1 NOSEND="1">Send BUG REPORTS to 
    bugs@xxxxxxxxxxxxxSend SUGGESTIONS to 
    suggest@xxxxxxxxxxxxx-----------------------------------------Post 
    AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: 
    <A 
    href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
    group FAQ at: <A 
    href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
    Your use of Yahoo! Groups is subject to the <A 
    href="">Yahoo! Terms of Service. 
  Send 
  BUG REPORTS to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to 
  suggest@xxxxxxxxxxxxx-----------------------------------------Post 
  AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: <A 
  href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
  group FAQ at: <A 
  href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
  Your use of Yahoo! Groups is subject to the <A 
  href="">Yahoo! Terms of Service. 







Yahoo! Groups Sponsor


  ADVERTISEMENT 









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



Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.