Click here to Login





                                                   How can I incorporate earnings release data into my backtests scripts?

  1

0
Scott Stephens
2013-05-14 22:57:25


I'd like to make my trading behavior different depending on whether it's the day before/after an earnings announcement or not. I found this item, which can download the data: http://www.quantshare.com/item-742-historical-earnings-calendar-for-major-stock-exchanges. However, I can't figure out how to use it in a strategy script. I've tried to following snippet of code to detect whether I'm processing the bar before which earnings will be announced:

earnings_var = GetData('earnings_cal', 'etime',String);
after_close = "After Market Close";
is_earnings = earnings_var == after_close;

As far as I can tell, is_earnings never gets set to true. Can anybody help me figure out how to use the earnings data?

Thanks,

Scott



QuantShare
2013-05-15 09:48:55

  0

Hi Scott,

First of all, make sure the earnings calendar data was downloaded properly. Check the custom database "earnings_cal" in "Data -> Edit Databases".

Regarding your formula, and in order to compare text values, you must use the function "stringequal".

Example:
is_earnings = stringequal(earnings_var, after_close);

Let me know how it goes.



Scott Stephens
2013-05-15 17:06:34

  0

I confirmed that the earnings data appears in the earnings_cal database. I'm running this little test just on AAPL from April 1 to May 10 (this year), and AAPL shows up as expected with etime equal to "After Market Close" on "23/04/2013 00:00:00". Changing my by signal to be set with:

earnings_var = GetData('earnings_cal', 'etime',String);
after_close = "After Market Close";
is_earnings = stringequal(earnings_var,after_close);
buy = is_earnings

Doesn't cause any changes. No trades are made in the backtest. Any other thoughts for me?



QuantShare
2013-05-15 21:35:03

  0

Best Answer
Sorry I didn't noticed that but to get "Text" data, you should get "GetDataString" instead of "GetData".

earnings_var = GetDataString('earnings_cal', 'etime', '');
after_close = "After Market Close";
is_earnings = stringequal(earnings_var,after_close);
buy = is_earnings;


Please note also that in case you want to get numeric data, the third parameter of the "GetData" function is wrong. It should be: LastData, NA or Zero.
LastData: If on the current date, "GetData" returns no values then use the last available one
NA: If on the current date, "GetData" returns no values then return NA (Not a Number)
Zero: If on the current date, "GetData" returns no values then return 0



matt
2014-01-12 18:14:38

  0

When I downloaded the earnings database scripts I was unable to get the actual earnings and estimate data. Has anyone had different results?




Earnings database (by Patrick Fonce, uploaded several months ago)
No notes

Rate an item Rate an item Rate an item Rate an item Rate an item Number of downloads Notes Report an item

QuantShare
2014-01-12 20:58:39

  0

The item you are referring to doesn't download the earnings and estimate numbers (Please read the item description).

Please use thisitem instead:
Historical Earnings Surprise, EPS and Consensus Data






Historical Earnings Surprise, EPS and Consensus Data (by Patrick Fonce, uploaded several months ago)
No notes

Rate an item Rate an item Rate an item Rate an item Rate an item Number of downloads Notes Report an item

No more messages
0




Reply:

No html code. URLs turn into links automatically.

Type in the trading objects you want to include: - Add Objects
To add a trading object in your message, type in the object name, select it and then click on "Add Objects"










QuantShare

Trading Items
Historical Earnings Calendar Data for U.S. Stocks - Date/Time and...
Historical Earnings Surprise, EPS and Consensus Data
Next Earnings Release In Days
UK Economic Data - Average Earnings Index
5-Minute Historical Intraday Data for Forex, Indices and Futures/...

How-to Lessons
How to download earnings calendar data for various stocks
How to download and use U.S. stocks earnings data
How to import trading data from CSV files
How to create trading rules based on Put and Call volume data
How to display Forex economic calendar data in a chart

Related Forum Threads
How can I get data from Barchart
How can i download additional data not within the standard time p...
How to view the raw data files?
How data management works
How to import Index data ?

Blog Posts
How to create a trading system, screen and composite using earnin...
How to Automatically Import Local Data Into QuantShare
How to Import Metastock data into QuantShare
Step by step on how to get free realtime/delayed data for stocks,...
How to create buy and sell trading rules based on News Data









QuantShare
Product
QuantShare
Features
Create an account
Affiliate Program
Support
Contact Us
Trading Forum
How-to Lessons
Manual
Company
About Us
Privacy
Terms of Use

Copyright © 2024 QuantShare.com
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Google+
Follow us on Google+
RSS Trading Items



Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.