Open conanak99 opened 6 years ago
Hi @conanak99, thanks for your report! Sorry for the (very) slow reply.
Generally, the length of each data.history
should not be related to the overall length of the backtest (however, a longer backtest probably means more data.history
calls).
One thing that comes to mind is that the price
field is forward-filled. This means that if on any given bar (minute or daily, depending on your backtest granularity), if we don't have a price for the asset, we have to go searching for the last price we have. That can be a bit time consuming - but I'd be surprised if you were missing pricing data for those names.
Can you try using close
or open
or some other price field that isn't forward-filled, to see if it makes a difference?
Dear Zipline Maintainers,
I have 2 questions related to the performance of
data.history
api at the end of this post.Let me explain my situation first: I'm implementing a moving average trading algorithm. The algorithm will compare moving average of 4 assets: AAPL, AMZN, MSFT, GOOG
When I run the back-testing from 2016 to 2018, the
handle_data
function takes 0.02 seconds to finish. However, when I run the backtesting from 2010 to 2018,handle_data
function takes 0.15 seconds to finish, which is 7 times slower and make my backtesting very slow.I have confirmed that
data.history
is the main reason for slowness. When I replacedata.history
with a fixed number, the average time forhandle_data
to finish is 0.02 second.So, I have 2 questions related to the performance of
data.history
api.data.history
api becomes. Is this the expected behaviour of this api?Many thanks, Harry