This repository contains a minimal local tool to perform an OAuth handshake with the Schwab API, generate local TLS certs for the redirect server, and fetch option/derivative positions into a local JSON file.
Files of interest
auth/client.json— stores your Schwabclient_idandclient_secret(created on first run)auth/token.json— saved raw token response after the initial handshakeauth/cert.pem,auth/key.pem— local TLS certs used for the local redirect serverdata/positions.json— output produced bydata.pywith option positions
Quick start
- Install Python dependencies (if needed):
python -m pip install requests cryptography- Run the initial auth handshake to create client config and obtain tokens:
python main.pyOn first run you will be prompted to paste your Client ID and Client Secret from the Schwab Developer Portal. These will be saved at auth/client.json.
- Fetch option positions (after successful auth):
python data.pyThis writes data/positions.json with the structure: a list of accounts each containing options entries with symbol, quantity, cost_basis, and lots (each lot has lot_init, quantity, cost_basis).
- Populate tracking data from the saved positions:
python data.py --trackThis writes data/tracking.json with current derivative price, strike price, and the current underlying asset price for each option/derivative position.
- Validate the project (syntax and JSON checks) without calling external APIs:
python test.pyNotes and tips
- The project stores sensitive values locally (
auth/client.jsonandauth/token.json). Do not commit these files to a public repository. Add an appropriate.gitignorebefore pushing. - If you want a requirements file, create
requirements.txtwithrequestsandcryptography.