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