Backtesting options using intraday OHLC data on backtrader.
am_trade last edited by
Firstly thank you for this awesome library. This is the most flexible open source library I have seen on the internet for backtesting.
I was planning on using backtrader for options backtesting. I understand that rolling over to new expirations won't be easy but what I was thinking is just adding all the strike options data feeds as different asset classes into the Cerebro PLUS the underlying data feed to get intraday signals.
data feed 0: Underlying assets 1 minute data (OHLC intraday 1 minute data available)
data feed 1-20: Call options for 20 strikes for May monthly expiration 1 minute data . (OHLC intraday 1 minute data available of only when trades were placed)
data feed 21-40: Put options for 20 strikes for May monthly expiration 1 minute data. (OHLC intraday 1 minute data available of only when trades were placed)
Based on data feed 0 I generate long or short signals.
Long signal means I buy the first out of the money call option at market i.e. buy 1 of the data feeds from 1 to 20 and close the position when sell signal comes.
Short signal means I buy the first out of the money put option at market i.e. buy 1 of the data feeds from 21 to 40 and close the position when sell signal comes.
No position sizing involved for now. Just an all in all out strategy.
Does anyone has sample code for something like that or anything else that gets the job done for me?
It would be great if someone can help me with this and I genuinely believe something like that will help a lot of people in the future.
I am sorry if I have missed anything in the documentation.
Even a base use case code would also be great if you could post it here.
email ID: email@example.com
run-out last edited by
Have a look at this response. https://community.backtrader.com/topic/1115/is-anyone-successfully-backtesting-options-with-backtrader/4