This is a C++ bot for options trading that is meant to speed up performance over the python implementation. The application includes custom interpolation models to analyze option chains and mispricings.
Make sure you have the following dependencies installed:
- Eigen
- Curl
- nlohmann/json
- CMake 3.14 or later
You can install these libraries via vcpkg or your preferred package manager.
- Create a
.envfile in the root directory with the following structure:
SCHWAB_API_KEY=your_schwab_api_key
SCHWAB_SECRET=your_schwab_secret
SCHWAB_CALLBACK_URL=your_callback_url
SCHWAB_ACCOUNT_HASH=your_account_hash
FRED_API_KEY=your_fred_api_key
DRY_RUN=true
TIME_TO_REST=2- Create a
stocks.jsonfile in the root directory with the following structure:
[
{
"ticker": "JPM",
"date_index": 0,
"option_type": "calls",
"min_overpriced": 0.14,
"min_oi": 400.0
}
]- Clone the repository and navigate to the project folder:
`git clone https://github.com/nichoc0/options.git
- Build the project using CMake:
mkdir build cd build cmake .. make
- Run the program using the following command:
./options
- filters option chains by bid price, implied volatility, and open interest
- fits SVI, SSVI, RFV+RBF and SVI+RBF to the IV smile, with arbitrage-free constraints
- compares model IV against realized vol and writes the results to CSV
A set of Python scripts wrap the C++ modeler for backtests, analysis, plotting, and an HTTP service.
Pinned in requirements.txt. Install into a virtualenv:
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
Scripts resolve repo-relative locations through paths.py, so they run from any checkout without editing absolute paths. The historical arkham/{options,treasury,results} layout is assumed for external data and result directories (they resolve next to the repo).
plot_smile.py --source {rbf,cpp,models} --style {serif,sans} --out PREFIXrenders the 2D volatility smile from the committed model CSVs.plot_vol_surface_3d.pyrenders the 3D surface.build_surface.py --model {raw,rfvrbf} --input-dir DIR --out FILEbuilds surface JSON fromspy_<dte>dte.csvtenor files.
The scripts under scripts/ run the modeler across dates and analyze the output, for example:
python3 scripts/run_call_backtest.py
python3 scripts/plot_volatility_smiles.py
deploy/iv_server.py is a Flask app served by gunicorn behind loopback. It requires the X-API-Key header to match IV_API_KEY.
export IV_API_KEY=your_secret
gunicorn -w 2 -b 127.0.0.1:8080 iv_server:app
See deploy/deploy.sh and deploy/terraform/ for the EC2 deployment (private subnet, SSM access, no SSH).
All Rights Reserved License (ARR).
This project is licensed under an All Rights Reserved License (ARR). See the LICENSE file for more details.