mirror of
https://github.com/wassname/options_backtester.git
synced 2026-06-27 16:30:55 +08:00
59def63d6a0f1a8a027414fe11cbf54d1a888a10
Options Backtester
Simple backtester to evaluate and analyse options strategies over historical price data.
Requirements
- Python >= 3.5
- pipenv
Setup
For backtesting, set $OPTIONS_DATA_PATH to the appropriate directory where the data is located. All file paths parsed by the backtester will be relative to this directory.
To use the data scraper the following environment variables need to be set:
$SAVE_DATA_PATH: where the data will be saved to (default is./data/scraped)$TIINGO_API_KEY: used to fetch data from Tiingo$S3_BUCKET: name of the S3 bucket to backup data$AWS_ACCESS_KEY_ID: AWS acces key id$AWS_SECRET_ACCESS_KEY: AWS secret key
You can configure the data scraper by editing the configuration file data_scraper.conf (json-formated).
Sample file:
{
"cboe": {
"mute_notifications": ["BFB", "CBSA"]
},
"notifications": {
"slack_webhook": "https://hooks.slack.com/services/MY_WORKSPACE_WEBHOOK"
}
}
HINT: store environment variables in an .env file and pipenv will load them automatically when using make env.
Usage
Create environment and download dependencies
$> make init
Activate environment
$> make env
Run tests
$> make test
Scrape data (supported scrapers: CBOE, Tiingo)
$> make scrape scraper=cboe
$> make scrape scraper=tiingo
Run backtester with benchmark strategy
$> make bench
Recommended reading
For complete novices in finance and economics, this post gives a comprehensive introduction.
Books
Introductory
- Option Volatility and Pricing 2nd Ed. - Natemberg, 2014
- Options, Futures, and Other Derivatives 10th Ed. - Hull 2017
- Trading Options Greeks: How Time, Volatility, and Other Pricing Factors Drive Profits 2nd Ed. - Passarelli 2012
Intermediate
- Trading Volatility - Bennet 2014
- Volatility Trading 2nd Ed. - Sinclair 2013
Advanced
- Dynamic Hedging - Taleb 1997
- The Volatility Surface: A Practitioner's Guide - Gatheral 2006
- The Volatility Smile - Derman & Miller 2016
Papers
- Volatility: A New Return Driver?
- Easy Volatility Investing
- Everybody’s Doing It: Short Volatility Strategies and Shadow Financial Insurers
- Volatility-of-Volatility Risk
- The Distribution of Returns
- Safe Haven Investing Part I - Not all risk mitigation is created equal
- Safe Haven Investing Part II - Not all risk is created equal
- Safe Haven Investing Part III - Those wonderful tenbaggers
- Insurance makes wealth grow faster
- Ergodicity economics
- The Rate of Return on Everything, 1870–2015
- Volatility and the Alchemy of Risk
Data sources
Exchanges
Historical Data
Languages
Jupyter Notebook
98.5%
Python
1.5%