Backtesting Options based on Futures
-
Hi,
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!
-
Hey Shravan,
You can just inherit the GenericCSV class and add additional lines. have a look at this post.
-
Hi,
Thanks Rajan. I am onto it. However, is there a way we can introduce a line which takes in string as input?
-
Hey,
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!