Saturday, November 28, 2026
Day 10: Quantitative Trading, Algo Systems & Backtesting | क्वांटिटेटिव ट्रेडिंग और एल्गो सिस्टम्स
NS CODE & CAPITAL
Lesson 10

Quantitative Trading & Algo Systems

Transform manual discretion into automated statistical rules, master quantitative backtesting metrics, mitigate curve-fitting, and connect broker APIs.

1. Discretionary vs. Algorithmic Trading

Algorithmic Trading is the execution of orders using automated, pre-programmed mathematical instructions accounting for variables such as time, price, and volume without human emotional interference:

  • Zero Emotional Bias: Eliminates hesitation, panic-selling, and greed by converting rules into pure conditional logic (If X then Y).
  • Execution Speed: Computes multivariant conditions and transmits orders via broker APIs in milliseconds.

2. The Architecture of an Algo Trading System

1. Strategy Engine (Logic)

• Computes real-time market data feed.
• Detects triggers (e.g., 20 EMA crossover + RSI > 60).
• Calculates precise position size based on active account equity.

2. Execution Engine (API Bridge)

• Connects directly to Broker REST/WebSocket APIs.
• Automatically handles slippage, order placement, and modifications.
• Enforces hard kill-switches on daily drawdown breach.

3. Crucial Quantitative Backtesting Metrics

Performance Metric Statistical Formula / Definition Healthy Benchmark
Max Drawdown (MDD) Peak-to-trough decline in your portfolio equity curve. < 15% Max Equity
Sharpe Ratio Measures excess return generated per unit of total risk/volatility. > 1.5 (Annualized)
Profit Factor Gross Total Profits divided by Gross Total Losses across all trades. > 1.75 Ratio
Out-of-Sample Test Testing the strategy on fresh, unseen historical data to prevent curve-fitting. Consistent Returns

4. Over-Optimization: The Overfitting Trap

The number one pitfall for quant traders is Curve-Fitting (Over-Optimization)—modifying indicators and parameters until historical results look flawless:

  • The Flaw: An over-optimized system memorizes historical market noise rather than identifying repeatable structural edges. It collapses in live trading.
  • The Fix (Walk-Forward Optimization): Keep rules minimal. Backtest on 70% data (In-Sample) and validate the model on the remaining 30% unseen data (Out-of-Sample).
Day 10 Practical Assignment
Open TradingView Pine Editor and run a built-in Strategy Backtest (e.g., EMA Cross Strategy).
Analyze the Strategy Report metrics: Check Max Drawdown, Profit Factor, and Total Closed Trades.
Explore your broker's Developer Portal (e.g., Zerodha Kite Connect, Angel One SmartAPI, or Dhan HQ) to review how API order authentication works.

1. मैनुअल बनाम एल्गोरिदमिक ट्रेडिंग (Algo Trading)

एल्गो ट्रेडिंग (Algo Trading) का अर्थ है अपने ट्रेडिंग नियमों को कंप्यूटर प्रोग्राम (कोड) में बदलना, जो बिना किसी मानवीय डर या लालच के खुद ही बाजार में ट्रेड निष्पादित करता है:

  • भावनाओं का पूर्ण अंत: डर, लालच, और हिचकिचाहट पूरी तरह खत्म हो जाती है क्योंकि कंप्यूटर केवल नियमों (If X then Y) पर काम करता है।
  • रफ्तार (Millisecond Execution): इंसानी आंख के देखने से पहले ही एल्गो मिलीसेकंड में ऑर्डर ब्रोकर के पास भेज देता है।

2. एक सफल एल्गो सिस्टम के दो मुख्य आधार

1. स्ट्रैटेजी इंजन (Logic)

• लाइव मार्केट डेटा को स्कैन करना।
• सिग्नल पहचानना (जैसे: 20 EMA का 50 EMA के ऊपर क्रॉसओवर)।
• कुल पूंजी के 1% रिस्क के अनुसार ऑटोमैटिक क्वांटिटी तय करना।

2. एक्जीक्यूशन इंजन (Broker API)

• ब्रोकर के API से सुरक्षित कनेक्शन बनाना।
• ऑटोमैटिक बाय/सेल और स्टॉप लॉस ऑर्डर लगाना।
• दिन का तय नुकसान होने पर खुद ही टर्मिनल बंद (Kill-Switch) करना।

3. बैकटेस्टिंग के 4 सबसे महत्वपूर्ण पैमाने (Metrics)

पैमाना (Metric) परिभाषा और महत्व सुरक्षित मानक स्तर
मैक्स ड्रॉडाउन (MDD) रणनीति के दौरान आपकी कुल पूंजी में आई अधिकतम ऐतिहासिक गिरावट। 15% से कम होना चाहिए
शार्प रेशियो (Sharpe) जोखिम के मुकाबले मिलने वाले मुनाफे की स्थिरता को मापता है। > 1.5 (उत्कृष्ट)
प्रॉफिट फैक्टर कुल हुए मुनाफे को कुल हुए नुकसान से भाग देने पर मिलने वाला अनुपात। > 1.75 रेश्यो
आउट-ऑफ-सैंपल टेस्ट सिस्टम को ऐसे डेटा पर टेस्ट करना जो उसने पहले कभी न देखा हो। स्थिर मुनाफा

4. ओवर-ऑप्टिमाइजेशन (Overfitting) का बड़ा धोखा

एल्गो ट्रेडर्स की सबसे बड़ी गलती होती है कर्व-फिटिंग (Curve Fitting)—यानी इंडिकेटर्स के पैरामीटर्स को तब तक बदलते रहना जब तक पुराना बैकटेस्ट 100% परफेक्ट न दिखने लगे:

  • खतरा: ऐसा सिस्टम पुराने डेटा को रट लेता है लेकिन लाइव मार्केट में नया डेटा आते ही पूरी तरह फेल हो जाता है।
  • बचाव का नियम: नियम हमेशा सरल रखें। 70% पुराने डेटा पर स्ट्रैटेजी बनाएं और बचे हुए 30% नए डेटा पर उसे सत्यापित (Validate) करें।
डे 10 प्रैक्टिकल असाइनमेंट
TradingView के Pine Editor में कोई इन-बिल्ट स्ट्रैटेजी (जैसे Moving Average Crossover) लगाकर बैकटेस्ट रिपोर्ट देखें।
स्ट्रैटेजी टेस्टर में Max Drawdown और Profit Factor के आंकड़े नोट करें।
अपने ब्रोकर (जैसे Zerodha, Angel One, या Dhan) के API Developer Portal पर जाकर देखें कि एल्गो ऑर्डर कैसे कनेक्ट होता है।

"Trade with statistical edge and systematic discipline—the market rewards consistency over luck."

Trading Series • Day 10 Masterclass Edition

Leave a Reply

Your email address will not be published. Required fields are marked *