Barry,
Here’s the Jscript that I promised.
This Jscript procedure loads the symbol names and market IDs using the file
that I sent earlier (or any CSV file with symbol, name, marketed and marketname
fields).
It turns out that Graham and Tomasz created
scripts that were very close to what you (and I) need. So, I modified
Graham’s script lightly with a bit of naming from Tomasz script.
It assumes that the symbol file is named “SymbolsList.csv”
and is saved in the ..\Amibroker\ImportWebData\ folder.
To add it to the Tools Menu:
1) Copy the code below to a text file and save with an appropriate
name ending in “.js”.
2) Save the script to the ..Amibroker\Scripts\ folder.
3) In AB, add the script to the Tools menu: “Tools à Customize à Options”.
4) Click “New” and enter a meaningful name.
5) In the “Command” field, point to the file in the
scripts folder.
6) Make your initial folder “C:\Program Files\AmiBroker\Scripts”.
(This may not be necessary. I’m not sure.)
7) Click Close.
To use it, select it from the Tools menu “Tools
à <script name>”. I will iterate through the list
of symbols and add/update the symbol, name, etc.
Regards,
Dan.
/* Based on Code
originally created and posted by Tomasz and Graham */
/* change this
line according to your data file name */
var filename =
"C:\\Program Files\\Amibroker\\ImportWebData\\SymbolsList.csv";
var fso, f, r;
var ForReading =
1;
var oAB;
var oStocks;
var oStock;
var fields;
/* Create
AmiBroker app object */
oAB = new
ActiveXObject( "Broker.Application" );
oStocks =
oAB.Stocks;
/* ... 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 */
Symbol = fields[ 0 ] ;
SymbolName = fields[ 1 ] ;
MarketID = fields[ 2 ] ;
MarketName = fields[ 3 ] ;
//WScript.echo("Symbol: '" + Symbol + "'"
) ;
//WScript.echo("SymbolName: " + SymbolName) ;
//WScript.echo("MarketID: " + MarketID ) ;
//WScript.echo("MarketName: " + MarketName) ;
//Modify Names
oStock = oStocks.Add(Symbol) ;
oStock.FullName = SymbolName ;
oStock.MarketID = parseInt(MarketID) ;
}
/* refresh ticker
list and windows */
oAB.RefreshAll();
WScript.Echo("Name
and Market Setup Finished" );
From:
amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of Dan Clark
Sent: Thursday, November 17, 2005
8:09 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: RE: [amibroker] Re:
Extracting symbol name from Yahoo, how?
Barry
I’m still working on this
script. I have to head to work now.
Essentially the Jscript will open the .csv file and iterate through
each line parsing the line. It will pass the symbol to the
Broker.Application object and set the symbol name and Market ID using the calls
below.
I’m writing the Jscript code now and
don’t have the time to finish it this morning. But, I thought
I’d give you a heads up on what I’m trying to do.
Sorry for the delay.
Regards,
Dan.
p.s. One of the AB
“gems” is the ability to add VBScript or Jscript scripts to the
Tools menu and then call them. You can also execute them use the
WSH cscript approach from the command line. This offers massive
flexibility.
Barry,
Hi. I don’t know if anybody
covered this, but once you get a symbol/name mapping, I believe that the code
below should help to assign the names.
Regards,
Dan.
- Get
CSV list of symbols, symbol names and markets that you are interested
in. Strip out the ones in which you are not interested.
- Save
the file to the
- Create
a Jscript procedure with the code below.
- Add
the code to the AB Tools Menu (Tools à
Customize à Tools à New)
- Execute
the code from the tools menu.
FileName: “AssignNameAndMarket.js”
// Instantiate Broker.Application
AB =
CreateStaticObject("Broker.Application");
//Modify Names
cs
= AB.Stocks(Sym)
;
cs.FullName = SymName;
cs.MarketID = iMarketID;
From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of Barry Scarborough
Sent: Wednesday, November 16, 2005
11:37 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] Re:
Extracting symbol name from Yahoo, how?
Hi Perry,
Thanks for the reply. Actually I am trying to do
just the opposite.
I have a bunch of symbols in my AB database that
have no names. I am
looking for a way to get the full names using the
symbols off the
Yahoo site. There are so many that it would not be
practical to do
this manually. so, I want to do this with a
program.
Cheers,
Barry
--- In amibroker@xxxxxxxxxxxxxxx,
"Perry Lentine" <lentino@xxxx>
wrote:
>
> Barry,
>
> Not sure what you are attempting to do.
But I have the full name
from yahoo
> in my database. I can extract it with
the following:
>
> Filter=1;
>
AddTextColumn(FullName(),"FullName
", 25);
> AddTextColumn(Name(),"Ticker",1.0);
> SetOption("NoDefaultColumns",1);
>
> Set range to last 1 day and explore.
>
> Hope this helps.
>
> Perry Lentine
>
> -----Original Message-----
> From: amibroker@xxxxxxxxxxxxxxx
[mailto:amibroker@xxxxxxxxxxxxxxx]
On Behalf
> Of Barry Scarborough
> Sent: Wednesday, November 16, 2005 8:14 AM
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: [amibroker] Extracting symbol name
from Yahoo, how?
>
> Given a symbol list is there a way to extract
the full name from
Yahoo using
> a script or Excel function?
>
> I would also like to get other information so
I can fill out the
information
> window but full name would do.
>
> Thanks,
> Barry
>
>
>
>
>
> ------------------------ Yahoo! Groups
Sponsor --------------------
~--> Try
> Online Currency Trading with GFT. Free 50K
Demo. Trade
> 24 Hours. Commission-Free.
> http://us.click.yahoo.com/RvFikB/9M2KAA/U1CZAA/GHeqlB/TM
>
-------------------------------------------------------------------
-~->
>
> Please note that this group is for discussion
between users only.
>
> To get support from AmiBroker please send an
e-mail directly to
SUPPORT {at}
> amibroker.com
>
> For other support material please check also:
> http://www.amibroker.com/support.html
>
>
> Yahoo! Groups Links
>
Please note that this group is for discussion between users only.
To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
For other support material please check also:
http://www.amibroker.com/support.html
YAHOO! GROUPS LINKS