Automated NVDA wheel-strategy options bot that runs against the Alpaca paper trading API.
The wheel strategy generates income by selling cash-secured puts on a target stock, then — if assigned — selling covered calls against the resulting share position until the shares are called away. I built this bot to run the strategy on NVDA fully unattended from India, with delta-targeted strike selection, IV Rank gating, earnings avoidance, and full state persistence so it survives crashes and restarts.
- Python 3.10+
- Alpaca Trading + Market Data APIs (paper)
requests,pytz,python-dotenv
- Two-stage state machine — Stage 1 sells cash-secured puts, Stage 2 sells covered calls after assignment, then loops
- Delta-targeted strikes — selects strikes near 0.25 |delta| with a configurable band, not naive % OTM
- IV Rank filter — refuses to open new positions when 252-day IV Rank falls below 30
- Earnings avoidance — skips any expiration that crosses a known NVDA earnings date with a 5-day buffer
- Profit-take and loss-cut — closes early at 50% of credit captured, hard-cuts at 2× premium loss, rolls when short delta hits 0.70
- 5-day re-entry cooldown after every profitable close
- US-market-aware scheduler — handles holidays, market hours, and IST-to-ET conversion for overnight India operation
- State persistence — full strategy state in
state.jsonso restarts resume in place - Daily summary — prints account equity, premium earned, position detail, and adjusted cost basis at 3:50 PM ET
- Python 3.10 or newer
- An Alpaca account with paper trading enabled (free)
- Alpaca paper API key + secret
git clone https://github.com/SayantoDutta/alpaca-wheel-bot.git
cd alpaca-wheel-bot
python -m venv .venv
.venv\Scripts\activate # Windows
# source .venv/bin/activate # macOS/Linux
pip install -r requirements.txtCopy the example env file and fill in your Alpaca paper credentials:
copy .env.example .env # Windows
# cp .env.example .env # macOS/LinuxThen edit .env:
ALPACA_API_KEY=PK...
ALPACA_API_SECRET=...
ALPACA_ENDPOINT=https://paper-api.alpaca.markets/v2
WHEEL_SYMBOL=NVDA
WHEEL_STARTING_EQUITY=10000
python wheel_bot.pyOn Windows, run_bot.bat provides an auto-restart wrapper that relaunches the bot if it exits unexpectedly. Schedule it via Task Scheduler with task.xml if you want it to start at logon.
The bot logs to both stdout and wheel_bot.log in the project directory. State is checkpointed to state.json after every tick.
The bot is a single-file event loop that wakes every 15 minutes during US market hours and idles otherwise.
Tick flow:
- Load
state.json(or default state on first run) - Refresh rolling 252-day IV history from the near-term option chain
- If a short option position is open, evaluate exit triggers (profit, loss, delta) and close if any fire
- Otherwise, choose Stage-1 (CSP) or Stage-2 (CC) action based on whether shares are held
- Find the best contract within the delta band that survives the earnings, premium, and cash-coverage filters
- Submit a sell-to-open limit order priced just inside the bid
- Persist updated state
State machine:
- Stage 1 → put expires worthless → stay Stage 1
- Stage 1 → put assigned → flip to Stage 2 with shares + cost basis recorded
- Stage 2 → call expires worthless → stay Stage 2
- Stage 2 → shares called away → increment cycle count, flip back to Stage 1
The earnings calendar and US market holiday set are hardcoded in wheel_bot.py and need to be updated each year. Strategy parameters (delta target, DTE band, profit-take percentage, etc.) are constants near the top of the file.
Active. Running daily on a paper account. Earnings dates need quarterly refresh; market holidays need annual refresh.