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

[amibroker] Re: SecurityFundamentals.dll



PureBytes Links

Trading Reference Links

From:    Dimension <dimension@xxxx> 
Date:  Mon Nov 29, 2004  12:23 am 
Subject:  COM DLL to read fundamental data from web site

 
The following dll will allow a user to pull financial data from 
various websites for use in your AFL studies.  Thanks to Anthony 
Faragasso, who had asked about this and helped to create and test 
(since I don't have VB6 to compile).

<<...>> <<...>> 

Quick Start: 
1) dowload the dll and save to some local direcotry 
2) Register the dll. From Windows desktop: select Start->Run, then, 
in the dialogue that appears type "regsvr32 <path to dll>".  Where 
<path to dll> is the where you saved the dll to (i.e. "regsvr32 
C:\Amibroker\ComAddIns\SecurityFinancials.dll" ) regsvr32 

D:\Program Files\AmiBroker\Plugins\SecurityFinancials.dll

3) Download and save the DataDefs.ini file. 
4) Add the following snippet to your AFL code to test all is well: 

sf = CreateObject("SecurityFundamentals.Fundamentals"); 
//NOTE: 'C:\\Projects\\SecurityFundamentals\\DataDefs.ini' should be 
changed to where ever you saved the DataDefs.ini file

sf.scrapeFundamentals
("Yahoo", "C:\\Projects\\SecurityFundamentals\\DataDefs.ini", Name
( ) ); 
flot = sf.getData( "Float" ); 
pctInsdrHlds = sf.getData( "PctInsdrHld" ) ; 
AddColumn( IIF( flot == "", null, flot ) , "Float" ); 
AddColumn( IIF( pctInsdrHlds == "", null, pctInsdrHlds ) , "Insdr 
Holdings" ); 
Filter = 1; 

More detailed docs... 

Retrieving Fundamental data for a Symbol in AFL: 
1)There are a couple of ways to use this dll, you can set indiviudal 
properties or you can use a one liner to tell the dll everything it 
needs to know to read data from a sie. The easiest is probably just 
using the one liner to tell the object everything it needs to know 
to retrieve the desired data.  To do this, you would call use the 
scrapeFundamentals method.

2) scrapeFundamentals (<Site>, <ConfigFile>, <Ticker>) 

Site is the same of site entry in the DataDefs file.  Remember that 
the DataDefs.ini file allows you to configure retrieval from 
different site.  The sample DataDefs.ini file contains Yahoo as an 
example, but you could add configure the dll to read from other site 
as well.  In the case of the sample DataDefs.ini file, the value for 
<Site> would be "Yahoo". 
<ConfigFile> is the path + file name of the config file that defines 
a site to look for data and how to read the data from that site. The 
DataDefs.ini is an example file that could be used here 
<Ticker> is the symbol we will be pulling fundamental/financial data 
for 
3) use getFloat(<data name>) method to retrieve data defined in the 
DataDefs.ini file.  
4) example of usage in AFL: 

sf = CreateObject("SecurityFundamentals.Fundamentals");
sf.scrapeFundamentals
("Yahoo", "C:\\Projects\\SecurityFundamentals\\DataDefs.ini", Name
()); 

        flot = sf.getData( "Float" );
        pctInsdrHlds = sf.getData( "PctInsdrHld" ) ;
        AddColumn( IIF( flot =="", null, flot ) , "Float");
        AddColumn( IIF( pctInsdrHlds =="", null, 
pctInsdrHlds ) , "Insdr Holdings"); 

Filter = 1; 

Modifying DataDefs to add additional dataItems: 
Data that will be pulled are defined in the DataDefs.ini file.  It 
is possible to pull data from any site, as long as there is a way to 
identify how to parse that data.   In the sample DataDefs.ini file, 
I am using finance.yahoo.com and there are some pre-loaded data 
reading instructions in there already, but other data can be added.  
The best way to explain how is to go thru an example.

Let's see how we can modify this file to pull Market Cap shown here: 
http://finance.yahoo.com/q/ks?s=MSFT 
  
(Changes at each step are highlisted in bold) 
1) Open the DataDef file: 
2) Observe the what is the last line.  In the datadefs.ini file, the 
last data item was "Data8, Float". 
3) Cut and paste that line below the line starting with Data8, so 
you would end up with: 
        DATA8 = DivDate||| DT ||| Dividend Date.*?>.*?>(.*?)< 
        DATA8 = DivDate||| DT ||| Dividend Date.*?>.*?>(.*?)< 
4) I now need to increment the data number so it remains sequential. 
Change the last DATA8 to DATA9, so I would end up with this:

        DATA8 = DivDate||| DT ||| Dividend Date.*?>.*?>(.*?)< 
        DATA9 = DivDate||| DT ||| Dividend Date.*?>.*?>(.*?)< 
5) I am trying to scrape Market Cap, so I need to give it a 
meaningful "identifier".  Change DivDate to something 
like "MarketCap" (this can be anything you want, but this value will 
be what you use when you call getData("<dataitem>") from AFL).  So 
we end up with something like:

        DATA8 = DivDate||| DT ||| Dividend Date.*?>.*?>(.*?)< 
        DATA9 = MarketCap||| DT ||| Dividend Date.*?>.*?>(.*?)< 
6) Next I need to define what can kind of data I am reading.  There 
are 4 types allowed: NUM, NUM_ABBR, PCT, DT.  NUM = numeric.  PCT = 
a percentage data item.  DT = date.  And NUM_ABBR are abbreviated 
numbers (where the number is followed by a M (millions ) or B 
(billions).  In the case of Market Cap on the yahoo page, we see 
that it is one of those abbreviated numbers, so we the datatype we 
want to use is NUM_ABBR.  Cap I would change the pattern string to:

        DATA8 = DivDate||| DT ||| Dividend Date.*?>.*?>(.*?)< 
        DATA9 = MarketCap||| NUM_ABBR ||| Market Cap.*?>.*?>(.*?)< 
7) finally I need to tell the Fundamentals object how to find 
MktCap. On the page at the URL above, we see that all data are shown 
in a two column table. The left being the data name and the right 
being the value. So for Market Cap I would change the pattern string 
to:

        DATA8 = DivDate||| DT ||| Dividend Date.*?>.*?>(.*?)< 
        DATA9 = MarketCap||| DT ||| Market Cap.*?>.*?>(.*?)< 
8) Note: the app actually uses something called regular rexpressions 
to do it's searches (that is what the last paramter of each line is, 
a regular expression pattern).  This is for advanced users and is 
what allows flexibility in searching various sites.  However, I 
should note…this dll has only been tested on Yahoo's site.


Sample INI FILE

DataDefs.ini

[Yahoo]
URL = http://finance.yahoo.com/q/ks?s=
DATA0 = Float ||| NUM_ABBR ||| Float.*?>.*?>(.*?)<
DATA1 = OutShares ||| NUM_ABBR ||| Shares Outstanding.*?>.*?>(.*?)<
DATA2 = Avg3MVolume ||| NUM ||| Average Volume.*?3 month.*?>.*?>(.*?)
<
DATA3 = Avg10DVolume ||| NUM ||| Average Volume.*10 day.*?>.*?>(.*?)<
DATA4 = PctInsdrHld ||| PCT ||| % Held by Insiders.*?>.*?>(.*?)<
DATA5 = PctInstHld ||| PCT ||| % Held by Institutions.*?>.*?>(.*?)<
DATA6 = ShareShort ||| NUM_ABBR ||| Shares Short.*?>.*?>(.*?)<
DATA7 = DivYield||| PCT ||| Dividend Yield.*?>.*?>(.*?)<
DATA8 = DivDate||| DT ||| Dividend Date.*?>.*?>(.*?)<


 


- In amibroker@xxxxxxxxxxxxxxx, "tipequity" <l3456@xxxx> wrote:
> Virtuouz
> 
> I am a new to amibroker and would like to download fundamental 
data 
> elements from Yahoo (e.g., no of oustanding shares). Would please 
tell 
> me how I can use the dll that you have posted in the file section.
> 
> thanks
> 
> cam




------------------------ 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

<*> 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/