This project includes backtests for a variety of trading strategies written in Python. The main strategies tested are variants of a Synthetic Covered Call strategy, also called Poor Man's Covered Call or PMCC. The strategy involves taking a synthetic long position in an underlying by buying a long dated call option, usually with high delta. Shorter dated call options are then sold against the long call option to generate income. The trade typically has net positive theta, delta, and vega.
There are also functions written for testing long SPY trades with entry/exits based on the VIX term structure, and a SPY put hedging strategy.
The options data used in the backtests was provided by Discount Option Data. To save time, I parsed the data for SPY options into a dataframe and pickled it. These functions are also included in main.py
.
To save more time, I wrote import_data.py
to keep a thread running with the dataframe after reading the pickle file, as this step alone could take over a minute each time.
The backtests track daily portfolio balance starting from an arbitrary portfolio value. The daily P&L and other metrics can be derived from the time series data. The synthetic covered call backtests include settings for varying the percentage of the portfolio invested, as well as delta and expiration requirements for entering trades.
The backtesting script keeps track of every individual position as it steps through each trading day. It tracks total premium collected and total slippage also.
Admittedly, the results are a bit disorganized, as I didn't intend to make this project public originally. However, I had some of the backtests categorized in this Google Drive.