-
-
Notifications
You must be signed in to change notification settings - Fork 162
Home
Thank you for using Optopsy! I hope you find this library useful, please feel free to send pull requests, comments, suggestions and contact me for any additional help you may require!
Most backtesting tools for option strategies don't reveal how the options are backtested, since this is open sourced, I will try to be as transparent as possible on how the algorithm works. You can decide if it works for your situation. My aim for this library is not to be able to backtest every possible event driven scenarios out there, but to focus on answering the core questions laid out in the introduction. There are no fancy features such as being 'event driven', but theoretically, it is possible by injecting a list of entry and exit dates created from external sources based on indicators.
The algorithm for the statistics module is as follows:
- Evaluate all option chains provided (filter for desired the entry and exit dates and calculate the profit/loss of each individual option chain)
- Group each 'evaluated' option chain into buckets (buckets are assigned to 'Days to Expiration' (grouped by days in intervals of 7, by default), and either 'delta' or 'strike distance percent' from current price (grouped in intervals of 5%, by default). Obviously, the smaller the intervals, the more accurate the results should be
- Construct the legs of the option strategy with the previously evaluated amounts and net out the profit/loss
- Aggregate all the constructed strategies into their buckets and calculate the average profit loss for each bucket combination
- The result will contain the average profit/loss amounts of the strategy (and other statistics such as min/max, distributions) for all the combinations of inputs (strike dist %/ DTE)
Obviously, statistics do not take into account real world events in a chronological order.
As the algorithm is heavily based on bucketing and approximations to improve performance, it is not recommended to make trade decisions based on the results solely from this library. Please use at your own risk.
Copyright © 2020, Michael Chu