lambdaclass / options_backtester

Simple backtesting software for options

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

feedback request

ashraf-01 opened this issue · comments

hi all
thanks for the effort provided in creating such library yet I would like to know within which subdirectory / subfolder I can test the example usage that you have provided on the main page of the options_backtester ?
best regards

Hi, thanks for the question!

Unfortunately, the example shown in the README needs the files stocks.csv and options.h5 that contain the stock and option data to run, which we did not provide. You can find an example that will run in backtester/examples/backtester_example.ipynb; just open a Jupiter notebook/lab in the base directory, open the file and run the cells. Also, the main_example.ipynb file has a more detailed explanation of the functionality (although, again, it won’t run unless you provide your own data).

alright sir , I see , that is why I got these mixed results , I thought you have renamed the files and somehow you have forgotten to mention that

I have another question , is there a way to include the logic in this library to implement what ever other strategy based off the classes , defs , you have built within the backtester ?

I'm not entirely sure I understand the question, but the idea behind the Strategy class in the backtester is that you can add different legs (StrategyLeg) to them, and in those legs you can specify different conditions for entry/exit that should allow you to implement a variety of different strategies; so in the README example

leg_1 = StrategyLeg('leg_1', schema, option_type=Type.PUT, direction=Direction.BUY)
leg_1.entry_filter = (schema.underlying == 'SPX') & (schema.dte >= 60) & (schema.underlying_last <=
                                                                          1.1 * schema.strike)
leg_1.exit_filter = (schema.dte <= 30)

leg_2 = StrategyLeg('leg_2', schema, option_type=Type.CALL, direction=Direction.BUY)
leg_2.entry_filter = (schema.underlying == 'SPX') & (schema.dte >= 60) & (schema.underlying_last >=
                                                                          0.9 * schema.strike)
leg_2.exit_filter = (schema.dte <= 30)

strategy = Strategy(schema)
strategy.add_legs([leg_1, leg_2])

this is essentially a long strangle implemented through the DSL provided by this backtester. Changing these conditions (and perhaps adding new ones) one could implement things like an Iron Condor, Long straddle etc.

thanks Javier

I got the point , yet I thought at the beginning that I can add additonal conditions so that I try to hedge one leg with another leg on the same instrument ( due to my little short experience with hedge funds) they tend to neutralize if you like any effects if possible using the chain of the options on the same instrument , if not possible , then use chain of options on instruments which is highly correlated with the original one , if not possible then use index ...and so on ... but now I see your point , yet where I can find the data that you have used in your example usage ?
best regards

@ashraf-01 We will add some data to the repo and create a better README based on your comments. You are right that it should be straightforward to run an example.

thanks I will be waiting in the mean time I might some add new legs and in this I will be contributing to the library soon

@ashraf-01 could you please check the new examples? Let us know if it is clear enough. Thanks!