I am a noob just testing out a very simple strategy of buying leveraged ETFs during the last two trading hours if they have moved a certain percentage.
I noticed the logs in my backtests had some big issues with the dates and prices. First the dates all seem to be off one day; the quantopian data is all one day ahead. For example, when it is actually the 6th, it generates logs as the 7th, and the I have logs Saturdays when the market is not open.
Regarding pricing data, I suspect the error is on my part, but I can't get an accurate figure for the previous day's close. I define closing price as:
close_price = data.current(context.securities,"close")
inside a scheduled function that runs at the end of the of the day. I log this number, and it appears to just be a random number. When I schedule the function to run at a different time (but still on the same day), the supposed closing price changes as well. Not too sure where I went wrong here, and what price I'm actually referencing.
Lastly, what is the most efficient way to get a stock's current price? I use:
current_price = data.history(context.securities, "price", 2, "1m").iloc
But I'm sure there's a much more efficient way that I don't know.
Thanks for any feedback. I'm a complete beginner programmer, and I'm really eager to learn.
|Returns||1 Month||3 Month||6 Month||12 Month|
|Alpha||1 Month||3 Month||6 Month||12 Month|
|Beta||1 Month||3 Month||6 Month||12 Month|
|Sharpe||1 Month||3 Month||6 Month||12 Month|
|Sortino||1 Month||3 Month||6 Month||12 Month|
|Volatility||1 Month||3 Month||6 Month||12 Month|
|Max Drawdown||1 Month||3 Month||6 Month||12 Month|