Backtesting Options based on Futures
Here's what I want to accomplish.
I want to go over futures data, apply a particular strategy (say moving average crossover) and at the specific time point of the crossover, I want to buy and sell using options (synthetic futures or long call/put).
So, essentially what I want to be able to do is, supply a timeseries of OHLC data of options of the underlying (say NIFTY50) along with the different strike prices and optiontype (PE/CE) and enter/exit trades in backtest based on that.
So, essentially, my options timeseries data csv file header is as follows:
Date, Expiry, OptionType, StrikePrice, Open, High, Low, Close
How do I use this to backtest options with the OHLC format?
I remember the admin mentioning about being able to test options with OHLC format. Any direction on this could really help.
Thanks a ton!
You can just inherit the GenericCSV class and add additional lines. have a look at this post.
Thanks Rajan. I am onto it. However, is there a way we can introduce a line which takes in string as input?
I just looked int to the source code for GenericCSVData and BT converts anything other than date to float values. In case if you just want to feed CE/PE.. maybe take them as +1 and -1 ? would that solve your issue ?
Yes, that's what I have done for now. Thank you for the prompt response!
I am looking to backtest option strategies (i.e. long/put) using futures/index data, exactly the same question you mentioned at the beginning of this thread.
Are you able to use backtrader to backtest options based on Futures? If yes, have you find any similar article? Thanks!