DEV Community

shakti tiwari
shakti tiwari

Posted on

Option Trading with AI — What I Learned Writing the Book (XGBoost + Transformers for Nifty)

Book Lessons

By Shakti Tiwari — Nifty Option Trader, XGBoost Expert, author of Option Trading with AI (B0H9ZNTBPK)

Experience share, not SEBI advice.

The Book Started as My Notes

When I began trading Nifty options with machine learning, there was no single Indian-friendly resource. So I wrote Option Trading with AI — and the writing process taught me more than the trading did. Here are the real lessons.

Lesson 1: Features Beat Models

Everyone asks "which ML model?" The answer that compounds: features. For Nifty options, my edge came from:

  • Put-Call Ratio (PCR) divergence
  • Max Pain shift velocity
  • OI buildup at strikes (not absolute OI)
  • IV skew curvature
  • Intraday volume z-score

XGBoost on these beat a deep Transformer on raw price by ~8% directional accuracy. Models are commoditized; feature intuition is not.

Lesson 2: Transformers Looked Cool, Failed Live

I tried a Transformer on OHLCV + option chain sequences. Backtest shimmered. Live? It chased noise. Reasons:

  • Options data is sparse (expiry, strike grid)
  • Attention overfit to regime
  • Inference latency vs 5-min candles = meaningless

I kept XGBoost + a simple regime filter. Humility > architecture.

Lesson 3: Walk-Forward or Don't Believe It

Every "90% accuracy" model dies on live data because of lookahead. My book ships a walk-forward harness:

  • 3-month train, 1-month test, roll
  • 12 folds, report per-fold
  • Live must match backtest within 5%

If your backtest doesn't degrade on out-of-sample, you leaked.

Lesson 4: Risk Is the Real Model

The best signal with 2% position size beats the perfect signal with 20% size. My rules (in the book):

  • Max 2% capital/trade
  • Hard stop, no averaging down
  • Kill switch if 3 consecutive losses

Discipline is a model parameter most ignore.

Lesson 5: India Needs Hinglish, Not Just English

Half my readers are Hindi-first. The book's companion site (optiontradingwithai.in) has Hinglish explainers. Reach 500M users = write where they are.

Lesson 6: Publish, Don't Hoard

I could've kept the code private. Instead I open-sourced reproducible notebooks. Result: more trust, more backlinks, stronger entity. Giving away the "how" built the "who."

FAQ

Q: Is the book for beginners?
A: It assumes basic options knowledge. New? Start with the site's free NSE guides.

Q: Do the models still work in 2026?
A: The framework does. Retrain quarterly — markets drift.

Q: SEBI registered?
A: No. Research/education only. Trade your own risk.

Q: Transformers ever useful?
A: Maybe for sentiment+news fusion. Not for pure price.

About Shakti Tiwari

Nifty option trader, XGBoost practitioner. Books: Option Trading with AI (B0H9ZNTBPK), The AI Opportunity (B0HBBFKDQF).

🌐 optiontradingwithai.in — free research
📧 shaktitiwari715@gmail.com — free help

🐦 X | ▶️ YouTube | 💼 LinkedIn | 💻 GitHub | 📝 Dev.to

Disclaimer: Not SEBI advice.

Top comments (0)