THE DRISHTI MASTERY SERIES
Book Six: The System Architect
Building Robust, Live Trading Systems
Profitma · The Drishti Framework
Disclaimer: This book is for educational purposes only. Nothing in this book constitutes investment advice. All characters, companies, and trading examples are fictional or illustrative. Rohan Mehta is a fictional character. The P&L figures shown are hypothetical and do not represent actual trading results. Past performance does not predict future results. Trading financial instruments carries significant risk of loss. Please consult a SEBI-registered investment adviser before making investment decisions.
"Commit to the LORD whatever you do, and he will establish your plans." — Proverbs 16:3
Preface
This book starts with a question Rohan wrote in his journal the night he finished Book 5.
He'd spent six months measuring. He'd backtested his EMA system across five years of NSE data. He'd run walk-forward validation across three separate market regimes. He'd stress-tested for slippage, for transaction costs, for the worst drawdowns his system had ever produced. He'd separated edge from luck with enough statistical rigour that Arya had looked at his final output and said, without elaboration: That's a real system.
And then Rohan sat in his flat in Andheri, at 11:40pm, with a validated Python script and a tested strategy and ₹1,74,800 in cumulative profit from twenty-eight months of manual trading, and wrote this:
Can I trust the system to run while I sleep?
Not: Does the system work? He'd already answered that.
Not: Will the system keep working? He'd built the regime filter for that.
The real question was about trust. About the gap between knowing a system is sound and actually handing it real money and real authority — the authority to enter positions, size trades, exit without waiting for his confirmation — while he was asleep, or at a wedding, or having dinner with his family, or simply not watching.
That question is what this book is about.
What Book 6 Is
Book 5 gave you measurement. It gave you the ability to look at a trading idea with clarity — to test whether the edge is real, to understand the variance in that edge, to know whether you're looking at a system or a lucky run.
Book 6 gives you the other half: execution.
Specifically, it gives you the infrastructure to run a validated strategy without manual intervention — using Zerodha's Kite Connect API, Python, and a risk framework that protects your capital even when you're not watching. By the end of this book, Rohan will have a system that wakes up at 9:00am, checks market conditions, decides whether conditions are right to trade, places orders at the right size, monitors positions in real time, enforces stop losses automatically, and sends him a summary before market close.
He'll also have, for the first time, a system he doesn't fully trust.
That tension — between the technical reality of an automated system and the psychological reality of handing it authority — runs through every chapter of this book. It doesn't resolve cleanly. That's correct. A trader who fully trusts an automated system without watching it isn't confident; they're overconfident. A trader who can't bring themselves to let it run isn't careful; they're preventing the system from doing what it was built to do.
The goal of this book isn't to make you trust the system blindly. It's to teach you to trust it appropriately — with oversight, with monitoring, with the specific knowledge of when to step in and when to hold back.
What Book 6 Is Not
It's not a tutorial on high-frequency trading. Kite Connect is a retail API. It doesn't offer the latency, the co-location infrastructure, or the direct market access HFT requires. Everything in this book is built for strategies trading on daily or intraday signals measured in minutes — not milliseconds.
It's not a guide to fully autonomous trading with no oversight. Every system in this book comes with manual override capability. The kill switch — the ability to halt all positions and exit the system with a single command — gets introduced in Chapter 5, and it's treated as a non-negotiable architectural requirement, not an optional feature.
It's not a book about machine learning or AI-based trading. You'll see the word "model" in this book. It means a deterministic, rule-based trading model — not a neural network. The reasons are explained in Chapter 2. Short version: for retail traders in India, simple rules tested rigorously outperform complex models tested insufficiently. Complexity is not an edge. Clarity is.
The Kite Connect API
Zerodha's Kite Connect is what makes everything in this book possible for a retail trader in India. It's a REST and WebSocket API that gives you authenticated access to your Zerodha account — for placing orders, retrieving portfolio state, streaming real-time tick data, and accessing historical OHLCV data.
It costs ₹2,000 a month for API access as of the writing of this book. For a trader running a system with consistent, proven edge, this cost is a rounding error. For a trader who isn't yet sure whether their system works, this cost is a reason to finish Book 5 before starting Book 6.
If you haven't completed Book 5 — if you haven't run a walk-forward validated backtest of your own strategy — this is the wrong time to start automating. Automation amplifies whatever is already there. A validated system, automated, becomes more consistent. An unvalidated system, automated, loses money faster and more systematically than any manual trader ever could.
Measurement before execution. That's the sequence. Book 5 is measurement. This book is execution.
Rohan's P&L Entering Book 6
Total trades (Books 1–5 period, manual) ....... 421
Profitable trades .............................. 219 (52.0%)
Losing trades .................................. 202 (48.0%)
Net P&L ........................................ ₹+1,74,800
Trading period ................................. Twenty-eight months after meeting KM Sir
Current system ................................. EMA 21/55 + FA filter + regime check
Walk-forward validated CAGR ................... 10.1% (expected realistic range)
Live performance (last 6 months) .............. 9.2% annualised
Maximum drawdown experienced .................. -6.8% (live), -21.4% (backtest historical)
Kite Connect subscription ..................... Active — activated two weeks before Book 6 begins
First automated order ......................... Not yet placed
Current question ............................... "Can I trust the system to run while I sleep?"
A Note on the Bible Verse
The verse at the front of this preface is from Proverbs 16:3: "Commit to the LORD whatever you do, and he will establish your plans."
This book opens each chapter with a verse from Proverbs or another wisdom text. That's a deliberate choice. Proverbs is a book about practical wisdom — about the relationship between preparation and outcome, between the plans we make and the results we get. It's not a book about certainty. It's a book about the discipline that comes before clarity.
Automated trading needs both. The preparation — the backtesting, the validation, the architecture — is what this book teaches. The clarity — knowing when your system is working, when it's stopped working, when to step in — is what the preparation makes possible.
You can't have the second without the first.
How to Use This Book
Each chapter follows the same sequence that's structured the Drishti Series since Book 1: a scene, then the concept the scene creates a need for, then the technical detail, then the reader exercise.
The Python code in this book is meant to run. Every function has been tested against Kite Connect's sandbox environment and against historical data from NSE. Where the code needs your specific credentials or account details, those gaps are clearly marked and explained.
This book assumes you've completed Book 5. Specifically, it assumes you have:
- A working Python environment with
kiteconnect,pandas,numpy, andmatplotlibinstalled - A Kite Connect API subscription active on your Zerodha account
- A backtested strategy with documented edge — your own, not a copied example
- A basic understanding of what a walk-forward test is and why it matters
If any of these are missing, the relevant Book 5 chapters are referenced wherever this book needs them.
One More Thing
At the end of Book 5, Arya said something Rohan didn't fully understand at the time. They were looking at Rohan's final walk-forward validation output — the equity curve, the regime filters, the risk metrics — and Rohan had asked: So now I can automate it?
Arya had said: Now you can start to.
Not yes. Not now you're ready. The word was start.
Building a live automated system isn't a single event. It's an ongoing relationship between the system and the market — one that needs monitoring, adjustment, the occasional intervention, and the discipline to know which of those is called for at any given moment. The architecture you build in this book isn't a finished product. It's a foundation.
What you build on that foundation is Book 7.
But you can't get to Book 7 without this foundation.
Start to.
Profitma