Optopsy is a nimble backtesting libary for option strategies, it is designed to act as an API for your option chain datasets and allows you to focus on what matters, your trading strategy.
The library is designed to compose well into your data analysis work and uses Pandas extensively under the hood. It extends PandasObject to faciliate common functional composition used in quant finance. As such, please note that importing optopsy
modifies pandas.core.base.PandasObject
to provide added functionality to pandas objects, including DataFrames.
This library is currently in development, please use at your own risk
- Use data from any source, just provide a Pandas dataframe with the required columns when calling optopsy functions.
- Optopsy allows you to mix and match different 'filters' to create an option strategy. Results will be returned as Pandas dataframes so that complex strategies can be composed upon. It is highly encourage to make use of
pandas.DataFrame.pipe
functions and chain methods wherever possible make your code cleaner. To learn more about the subject, I highly recommend reading the following blog post.
Entry rules:
- Days to expiration
- Entry Days (Staggered trades)
- Absolute Delta
- Percentage out-of-the-money
- Contract size
Exit rules:
- Days to expiration
- Hold days
- Profit/Stop loss percent
- Spread delta
- Spread price
- Single Calls/Puts
- Vertical Spreads
- Iron Condors
- (Coming Soon) Iron Butterfly
- (Coming Soon) Covered Stock
- (Coming Soon) Combos (Synthetics/Collars)
- (Coming Soon) Diagonal Spreads
- (Coming Soon) Calendar Spreads
- (Coming Soon) Custom Spreads
- (Coming Soon) Strangles
- (Coming Soon) Straddles
You will need Python 3.7.x and Pandas 0.24.1 or newer. It is recommended to install Miniconda3. See requirements.txt for full details.
pip install optopsy
Optopsy is best used with Jupyter notebooks, however, it is also possible to incorporate it into your python scripts:
The following example uses Level 2 Historical CSV Data Sample from historicaloptiondata.com.
Full Documentation Coming Soon!