7 min read
Options Trading Automation - Part 1
trading automation python

I built a bot to automate my options trading strategy, removing emotion and enabling consistent winning trades. Here’s how I did it.

Disclaimer: This is a personal project writeup, not financial advice. I’m sharing my approach as a personal project. Options trading involves financial risk and isn’t suitable for everyone. Do your own research and consult a financial advisor before trading.

1. The Problem with Manual Trading

My first job out of school was options trading on the New York Stock Exchange. Each trade had hundreds of thousands on the line. It was intense, educational, and taught me both the math and psychology of trading.

While I’m no longer working in finance, I took what I learned about options with me. Now working in tech as a PM, I wanted to apply that knowledge to generate income without the emotional rollercoaster of active trading.

This year I’ve been playing with an options strategy in my portfolio. In the 50 trades that I’ve done, it generated $1,283—a 19% return on deployed capital of ~$6,000. In contrast, the S&P returned 14.72%.

While the strategy worked well, I kept missing opportunities. I’d forget to check positions, hold losers too long, or close winners too early out of fear.

My instinct when facing a repetitive, rule-based problem? Automate it. So I built a trading bot.

2. The Solution: Automated Wheel Strategy

What is the Wheel?

The wheel is a classic, income-generating options strategy that works in four stages.

Stage 1: Sell a cash-secured put I sell a put option while holding enough cash to buy 100 shares if assigned. I collect premium from selling the put immediately.

Stage 2: Assignment (if the put expires in-the-money) I now own the stock at the strike price, and I’ve already collected premium from the put sale.

Stage 3: Sell a covered call With 100 shares in hand, I sell a call option against them. I collect more premium.

Stage 4: Assignment (if the call expires in-the-money) If the stock rises above my strike, my shares get called away. I sell at a profit and return to Stage 1.

The cycle repeats indefinitely, hence the “wheel.”

Why It Works

This strategy thrives in sideways, choppy, and slowly appreciating markets where I can take advantage of price oscillation.

It underperforms in a strong bull markets because upside is capped when shares get called away, or when the market crashes because I’m forced to buy at the strike prices than current trading price.

Why IBIT?

The key is picking an underlying I actually want to own. For me, that’s IBIT (BlackRock’s Bitcoin ETF). IBIT has worked well so far because it has:

  • High implied volatility (~43%): Makes selling options attractive
  • Liquid options markets: Tight bid-ask spreads
  • Exposure to Bitcoin - An asset class I believe in
  • Manageable price point (~$60-70/share) - Contract size works with ~$7,000 capital1

3. Building the Bot

I built this as a straightforward Python script that runs twice daily. No fancy infrastructure—just enough to get the job done.

The Core Workflow

  1. Fetch market data and my current positions from Schwab’s API
  2. Analyze option chains based on my strategy parameters (0.30 delta, 30-45 DTE, prefer monthly expiry for liquidity)
  3. Determine if there’s a trade to make
  4. Log the decision

I’m using launchd on macOS to run the script automatically in the morning and mid-afternoon. This means my laptop needs to stay on—not ideal, but it works for now. Cloud deployment is next once I validate the core workflow and strategy.

Tech Stack

  • Language: Python
  • API: Schwab Trader API
  • Data storage: JSON files (no database needed for a single-user bot)
  • Scheduling: launchd

Architecture Decisions

I opted for simplicity:

  • Stateless execution - The script runs, does its thing, and exits. No long-running processes or memory leaks.
  • CLI-only - Everything runs from the terminal (though a dashboard might be cool eventually)
  • File-based state - JSON files are human-readable, easy to debug, and version-controllable

4. The Rules Engine

The bot follows a set of rules I’ve refined based on intuition from manual trading.

Entry Rules: The IV Filter

I only sell options when IV Rank ≥ 50th percentile.

IV Rank measures where current implied volatility sits relative to the past 52 weeks. If it’s below 50%, premiums are too thin to justify the risk. The bot tracks this history and skips trades when the market is calm.

It’s like selling insurance when people are scared and premiums are high, not when everyone’s comfortable and insurances are cheap.

There is one exception for covered calls. I only sell them if the stock is up 5%+ from my cost basis. This prevents me from capping gains on a position that’s already working or—worse—locking in a loss by getting called away below my entry.

Exit Rules: Aggressive Profit-Taking

Time decay works in my favor, but I don’t wait around for max profit. Locking in gains early beats getting greedy.

My profit targets:

  • Day 0-1: Close at 10% profit (quick win on immediate vol drop)
  • Day 2+: Close at 20% profit (capture early theta)
  • Anytime: Close at 70% profit (near-max gain, why push it?)

In addition, if IV Rank drops below 50% and I’m up 10%+, I close immediately. When volatility collapses, option prices crater fast. The bot capitalizes on that before waiting for time-based targets.

What This Looks Like in Practice

Say I sell a put for $2.00 premium:

  • If IV tanks overnight, the option might drop to $1.80 by next day, the bot closes for $0.20 profit (10%)
  • If the underlying moves suddenly on day 2 and the option is at $1.60, the bot closes for $0.40 profit (20%)
  • If it slowly decays to $0.60 → bot closes for $1.40 profit (70%)

I rarely hold to expiration. My philosophy is to close early and redeploy capital.

5. Results and Learnings

What I’ve Learned So Far

Broker APIs are messy. Settlement delays, data inconsistencies, and quirks I don’t encounter in manual trading. Building robust error handling is essential.

Dry-run mode is critical. This rang home for me as a PM working with engineers. We always emphasize a solid definition of “done” before launching anything live.

Automation removes emotion. No more second-guessing, no more FOMO, no more panic selling. The bot follows the rules, period.

What’s Next

Before risking real money, I’m running a two-week paper trading simulation. The bot logs every trade it would make, and I’m tracking the hypothetical P&L. This helps me catch edge cases and build confidence before going live.

In Part 2, we will review the dry run results and determine if the strategy is ready for live deployment.

Code is open source on GitHub

Want to see more side projects? Check out HolaMundo, my AI language tutor, or browse my photography.

Footnotes

  1. There are active traders on Reddit r/thetagang running way more capital than what I’m doing here with this strategy. Personally, I’m still a believer in buy-and-hold and treat this as an experiment to generate additional income.