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

RE: [amibroker] Creating a text file - NEVER MIND. SCORE!!!!



PureBytes Links

Trading Reference Links

Many thanks to Ron and Tony.  Here’s the scan code to retrieve the Earnings Date and save it to a file:

 

//Get the data

rmaObj = CreateStaticObject("rmaAFLObjects.EstEarnDate");

EarningsDate = "";

EarningsDate = rmaObj.EarningsDate(Name());

if (StrLeft(EarningsDate , 1) == "c")

       EarningsDate = "N/A";

 

fh = fopen( "C:\\Program Files\\AmiBroker\\LookupData\\" + "EstEarn_" + Name() + ".csv ", "w");

if( fh )

{

fputs( "EstEarningsDate" + "," + EarningsDate, fh );  //+ "\n"

fclose( fh );

}

Buy = 1;

 

And this is the code that retrieves the data for a chart or scan:

 

EarningsDateString = "";

fh = fopen( "C:\\Program Files\\AmiBroker\\LookupData\\" + "EstEarn_" + Name() + ".csv ", "r");

if( fh )

       {

       EarningsDateString = fgets( fh );

       fclose( fh );

       EarningsDate = StrExtract(EarningsDateString, 1 );  //0-based ordinal position

       }

else

       {

       EarningsDate = "N/A";

       }

 

For 1801 symbols (my “Tradable Symbols” list), the scan takes about 10 minutes to run.  However, when data is retrieved for chart and is used in a scan or chart, response is virtually instantaneous.   It’s MUCH faster than retrieving the data from Yahoo one-by-one. 

 

Using the original code to retrieve the symbols one-by-one for a chart symbol.  There’s perceptible lag.  Now, using the “file” method, there’s virtually NO lag.

 

Regards,

 

Dan.


From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of Dan Clark
Sent: Saturday, August 13, 2005 10:46 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: RE: [amibroker] Creating a text file - NEVER MIND. Figured it out.

 

Ron,

 

Actually, that’s the easy part.  J   Here’s the scan:

 

// Queries Yahoo for earnings date, parses html and reports the date.

rmaObj = CreateStaticObject("rmaAFLObjects.EstEarnDate");

EarningsDate = "";

EarningsDate = rmaObj.EarningsDate(Name());

if (StrLeft(EarningsDate , 1) == "c")

      EarningsDate = "N/A";

 

Filter   =  Buy = 1;

SetOption( "NoDefaultColumns"             , True                                 );

AddTextColumn( Name()                     , "Symbol"                             );

AddTextColumn( FullName()                 , "Company"                            );

AddTextColumn( EarningsDate               , "EarningsDate"                       )

 

Regards,

 

Dan.

 


From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of mrdavis9
Sent: Saturday, August 13, 2005 10:35 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: Re: [amibroker] Creating a text file - NEVER MIND. Figured it out.

 

Dan, hopefully, at least one result of these creative efforts of yours will enable us to create explorations with>>>  AddColumn(EstEarningsDate);  Ron D

 

 

----- Original Message -----

From: Dan Clark

Sent: Saturday, August 13, 2005 11:58 AM

Subject: RE: [amibroker] Creating a text file - NEVER MIND. Figured it out.

 

Ron,

 

Thanks.   Actually, I figured out something similar about 3 minutes ago.  (Great minds… :) 

 

In my case, I’m not interested in saving quote data, but simply the Estimated Earnings Date (at least in this iteration) plus other data.   If I understand the string handling functions correctly, it appears that multiple types of data could be saved in each file as a string pair.   The first member of the string pair would be a type identifier with the second member being the value.  For example, data in an “MSFT_Val.csv” file might be:

 

EstEarningDate,18-Aug-05

CurrentRSC,307

RSCMinus5,251

RSCMinus21,251

 

If this works, it might be a way of speeding up scans tremendously.    I.e., you’d populate the files in one scan and then use the data in other scans and charts.

 

Do you see any issues with this?  Better solution?

 

Thanks and regards,

 

Dan.

 

 


From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of ronbo
Sent: Saturday, August 13, 2005 9:33 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: RE: [amibroker] Creating a text file - NEVER MIND. Figured it out.

 

here is an example Graham coded a while back.  use it as an example to do what you want.  it creates a .csv file for every symbol...

 

hth,

ron

 

/*

Export EOD data to CSV files One file for each stock

In the first line insert the directory you want to save them to, make sure the directory exists

Select your charts to export with the "Apply to" filter in AA window

Select the timeframe period you want to save as using the AA "Settings"

Press Scan button

by Graham Kavanagh 05 Feb 2004

Modified 4/1/2004 by ronbo to remove the Time column,

1. remove the dashes in the date

2. remove the Time column

3. customize the file location

*/

fh = fopen( "C:\\Program Files\\PFScan 2\\Data\\"+Name()+".csv ", "w");

if( fh )

{

fputs( "Ticker,Date,Open,High,Low,Close,Volume \n", fh );

y = Year();

m = Month();

d = Day();

for( i = 0; i < BarCount; i++ )

{

fputs( Name() + "," , fh );

ds = StrFormat("%04.0f%02.0f%02.0f,",

y[ i ], m[ i ], d[ i ] );

fputs( ds, fh );

qs = StrFormat("%.3f,%.3f,%.3f,%.3f,%.0f\n",

O[ i ],H[ i ],L[ i ],C[ i ],V[ i ] );

fputs( qs, fh );

}

fclose( fh );

}

Buy = 1;

-----Original Message-----
From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx]On Behalf Of Dan Clark
Sent: Saturday, August 13, 2005 9:09 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: RE: [amibroker] Creating a text file - NEVER MIND. Figured it out.

 

 


From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of Dan Clark
Sent: Saturday, August 13, 2005 8:49 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] Creating a text file

 

Hi,

 

I’m trying to read from and save data to a file.   There is an fdelete function, but I can’t find an fcreate function.  How do you CREATE a file in AFL if it does not already exist?  

 

Regards,

 

Dan.

 

 





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