A powerful tool to fetch SPX option chain data including Greeks (delta, gamma, theta, vega, rho), bid/ask quotes, and underlying prices. Data is stored in SQLite and can be exported to JSON for analysis.
- Comprehensive Data Collection: Fetches options data for SPX (monthly/quarterly) and SPXW (weekly) automatically
- Full Greeks: Delta, gamma, theta, vega, and rho for all options
- Market Quotes: Real-time bid/ask prices and calculated mid prices
- Underlying Price Tracking: Records SPX price at the time of each data fetch
- SQLite Database: Organized storage with indexing for fast queries
- JSON Export: Export data to well-structured JSON files for analysis
- Flexible Filtering: Filter by expiration date, strike range, and delta range
- Command-Line Interface: Easy to use and automate
- A Tastytrade account (with API access enabled)
- Internet connection
- Computer running macOS or Windows
Python is the programming language this tool is written in. You need to install it first.
-
Open Terminal
- Press
Command (β) + Spaceto open Spotlight - Type
Terminaland press Enter
- Press
-
Check if Python is already installed
python3 --version
- If you see something like
Python 3.11.xor higher, you already have Python! Skip to Step 2. - If not, continue below.
- If you see something like
-
Install Python using Homebrew (recommended method)
First, install Homebrew if you don't have it:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"Then install Python:
brew install python
-
Verify installation
python3 --version
You should see
Python 3.11.xor higher.
Alternative for macOS: Download the installer from python.org and run it.
-
Download Python
- Go to python.org
- Click on the latest Python 3.x version (e.g., Python 3.12.x)
- Download the "Windows installer (64-bit)"
-
Run the Installer
- Double-click the downloaded file
β οΈ IMPORTANT: Check the box that says "Add Python to PATH" at the bottom- Click "Install Now"
- Wait for installation to complete
- Click "Close"
-
Verify Installation
- Press
Windows Key + R - Type
cmdand press Enter - In the command prompt, type:
python --version
You should see
Python 3.11.xor higher. - Press
- Go to https://github.com/Quenos/option_chain_fetcher
- No login required - the repository is public
- Click the green "Code" button (near the top right)
- Click "Download ZIP"
- Extract the ZIP file to a folder on your computer
- macOS: Double-click the ZIP file
- Windows: Right-click the ZIP file β "Extract All"
- Remember where you extracted it (e.g.,
Documents/option_chain_fetcher)
If you have Git installed:
git clone https://github.com/Quenos/option_chain_fetcher.git
cd option_chain_fetcherDependencies are additional Python packages this tool needs to work.
-
Open Terminal
-
Navigate to the project folder
cd /path/to/option_chain_fetcherReplace
/path/to/with the actual path where you extracted the files.Example:
cd ~/Documents/option_chain_fetcher
-
Install required packages
pip3 install -r requirements.txt
This will take a minute or two. Wait for it to complete.
-
Open Command Prompt
- Press
Windows Key + R - Type
cmdand press Enter
- Press
-
Navigate to the project folder
cd C:\path\to\option_chain_fetcher
Replace
C:\path\to\with the actual path where you extracted the files.Example:
cd C:\Users\YourName\Documents\option_chain_fetcher
-
Install required packages
pip install -r requirements.txt
This will take a minute or two. Wait for it to complete.
To fetch option data, you need to set up API access with your Tastytrade account.
π Follow the detailed tutorial: OAUTH_SETUP_TUTORIAL.md
Quick Overview:
-
Log in to Tastytrade β https://trade.tastytrade.com/
-
Navigate to: Manage β My Profile β API
-
Enable API Access (if not already enabled)
-
Create a new OAuth Grant:
- Redirect URI:
http://localhost:8000(exactly) - Permission: Select "Read" only (
β οΈ do NOT select "Trade")
- Redirect URI:
-
Copy your Client ID and Client Secret (save them immediately!)
-
Run the setup script:
macOS:
python3 get_refresh_token.py
Windows:
python get_refresh_token.py
-
Follow the prompts to complete authentication
The script will create a .secrets file with your credentials. Keep this file safe and never share it!
For detailed step-by-step instructions with screenshots, see OAUTH_SETUP_TUTORIAL.md.
macOS:
python3 option_chain_fetcher.py --max_dte 7 --min_strike 5800 --max_strike 6000Windows:
python option_chain_fetcher.py --max_dte 7 --min_strike 5800 --max_strike 6000This fetches options expiring in the next 7 days with strikes between 5800 and 6000.
β±οΈ Performance Note: The fetcher retrieves data for each option individually. For large date ranges (high max_dte) and wide strike ranges, the process can take several minutes to complete. This is normal as the tool is fetching quotes and Greeks for hundreds or thousands of options. The script will show progress in the console and log file.
macOS:
python3 export_to_json.pyWindows:
python export_to_json.pyThis exports the latest data to JSON files in the json_exports/ folder.
macOS:
python3 option_chain_fetcher.py --clear_dbWindows:
python option_chain_fetcher.py --clear_dbFor detailed documentation, see:
- OPTION_CHAIN_USAGE.md - Complete usage guide for the data fetcher
- JSON_EXPORT_GUIDE.md - How to export and work with JSON files
- OAUTH_SETUP_TUTORIAL.md - Step-by-step API setup guide
- SPX_HANDLING_NOTES.md - Understanding SPX vs SPXW
- CHANGES.md - Project changelog and technical details
The tool creates a SQLite database with two tables:
- option_chain_data: All option data with Greeks and quotes
- underlying_prices: SPX price at the time of each fetch
When you specify --symbol SPX or --symbol SPXW, the tool automatically fetches both:
- SPX: Monthly/quarterly expirations
- SPXW: Weekly expirations
This gives you complete market coverage in a single run!
Filter your exports by:
- Expiration date range
- Strike price range
- Delta range
- Specific expiration date
Example:
# macOS
python3 export_to_json.py --start_date 2025-10-06 --end_date 2025-10-10 --min_delta 0.25 --max_delta 0.45
# Windows
python export_to_json.py --start_date 2025-10-06 --end_date 2025-10-10 --min_delta 0.25 --max_delta 0.45Contributions are welcome! Feel free to open issues or submit pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.
This tool is for educational and research purposes only. It provides market data but does not execute trades. Always verify data independently before making trading decisions.
If you encounter issues:
- Check the OAUTH_SETUP_TUTORIAL.md troubleshooting section
- Review the log file:
option_chain_fetcher.log - Open an issue on GitHub with:
- Your operating system (macOS/Windows)
- Python version (
python --versionorpython3 --version) - Error messages from the log file
Once you've completed the installation steps above, you're ready to start fetching SPX option data!
First run command:
macOS:
cd ~/Documents/option_chain_fetcher
python3 option_chain_fetcher.py --max_dte 7 --min_strike 5800 --max_strike 6000Windows:
cd C:\Users\YourName\Documents\option_chain_fetcher
python option_chain_fetcher.py --max_dte 7 --min_strike 5800 --max_strike 6000Happy trading! π