Algo Trading & Quant
Python automation, backtesting frameworks, execution systems, and quantitative research workflows for systematic trading.
Python Automation
IBKR via ib_insync, Zerodha Kite Connect, yfinance for data, scheduled jobs via cron / GitHub Actions.
Backtesting
Event-driven backtester with stop / target / time-stop simulation, R-multiple tracking, drawdown analysis, and walk-forward validation.
Quant Strategies
Mean reversion, trend following, divergence detection, volatility expansion, pairs trading โ all with paper-first deployment.
What "algo trading" actually involves
It's not just "let the computer trade." A complete algo system handles every step a discretionary trader would, but in code:
- Implementing technical indicators โ RSI, MACD, ATR, Stochastic, EMA, Supertrend, Bollinger Bands. Either via TA-Lib (C-fast) or pure pandas (portable).
- Detecting candlestick patterns โ Doji, Hammer, Engulfing, Morning/Evening Star, Marubozu, Shooting Star. TA-Lib has 60+ patterns built-in.
- Calculating stop-loss dynamically โ `stop = entry โ N ร ATR(14)` is the workhorse. Optional "swing-pivot floor" widens the stop to just past the prior structural level if ATR is tighter.
- Calculating target levels โ fixed R-multiple (1.5R, 2R) or technical (mean-reversion to BB middle, prior swing high).
- Position sizing & quantity โ `qty = int((NAV ร risk_pct%) / (entry โ stop))`. Floor first, then divide โ small but real bug source.
- Order execution โ bracket orders (market entry + stop + target as OCO children) via the broker's API. Always log the parent + child IDs to a CSV for audit.
- Risk management โ daily kill switch, max concurrent positions, max loss per trade as % of NAV. Enforce in code, not in the prompt.
- Backtesting before live โ replay historical bars, simulate fills at next-bar open, track exits realistically. Watch for lookahead bias.
- Paper-first deployment โ never flip to live without 60+ days of paper-account proof that the system behaves as designed under real bid-ask + slippage.
A typical signal-to-order pipeline
# 1. Fetch bars ohlc = fetch_bars(ticker, period="6mo", interval="1d") # 2. Compute indicators ohlc["RSI"] = rsi(ohlc["close"], 14) ohlc["MACD"] = macd(ohlc["close"], 12, 26, 9) ohlc["ATR"] = atr(ohlc, 14) # 3. Detect divergence + candlestick confluence divs = find_divergence(ticker, ohlc) ohlc = detect_candle_patterns(ohlc) # 4. If signal fires, build the trade plan if buy_signal(ohlc): entry = ohlc["close"].iloc[-1] stop = entry - 2.0 * ohlc["ATR"].iloc[-1] target = entry + 3.0 * ohlc["ATR"].iloc[-1] # 1.5R qty = int((NAV * 0.01) / (entry - stop)) # 1% risk # 5. Submit bracket order to broker place_bracket(ticker, "BUY", qty, entry, stop, target) log_to_csv(ticker, qty, entry, stop, target)
Tools we use on the channel
- Python โ the only realistic language for retail algo trading in 2026
- pandas + numpy โ bar / indicator manipulation
- TA-Lib โ fast indicator + candle pattern library (C-backed)
- ib_insync โ IBKR API wrapper (much cleaner than native ibapi)
- kiteconnect โ Zerodha API for Indian markets
- yfinance โ free historical data for backtesting + universe scans
- scipy.signal.argrelextrema โ pivot detection for divergence + structure
- matplotlib / lightweight-charts โ visualization