KiteEdge - Portfolio Intelligence Platform

Full-stack, analytics-only platform for Zerodha Kite - 43+ technical indicators, Monte Carlo VaR, ARIMA/Prophet forecasting, and real-time WebSocket streaming.

Role
Full-Stack Developer & Architect
Timeline
May 2026 – present
Team
Solo
Outcome
43+Technical Indicators
Stack
Elixir · Phoenix · Python · FastAPI · React · TypeScript · PostgreSQL · Kafka

TL;DR

Retail investors on Zerodha lacked institutional-grade analytics. I designed and built KiteEdge - a self-hosted polyglot platform combining an Elixir/Phoenix backend for real-time data streaming, a Python analytics engine for quantitative finance, and a React dashboard - delivering 43+ technical indicators, Monte Carlo VaR, ensemble forecasting, a NIFTY 500 screener, FIFO trade analytics, and Power BI export across 50 API endpoints, without ever executing trades.

43+Technical Indicators
50API Endpoints
13Compose Services
8Kafka Topics

Context & Problem

Retail investors using Zerodha Kite get basic portfolio views - current holdings, day P&L, and simple charts. But institutional-grade analytics - technical indicators across multiple timeframes, portfolio risk quantification (VaR, Sharpe, drawdown analysis), stress testing against historical scenarios, and statistical forecasting - require expensive Bloomberg/Refinitiv terminals or fragmented Python scripts.

The gap: a self-hosted, privacy-first platform that connects to your Kite account and delivers institutional-quality analytics without ever touching your trades.

Research & Discovery

  • Studied quantitative finance workflows at institutional level - what metrics do professional portfolio managers track daily?
  • Benchmarked retail analytics tools (Smallcase, Tickertape, Screener.in) on depth of technical analysis, risk quantification, and forecasting capabilities
  • Identified core unmet needs: multi-timeframe technical analysis (not just daily), portfolio-level risk decomposition, scenario-based stress testing, and statistically rigorous forecasting with confidence intervals
  • Key constraint: analytics only - the platform must never execute trades, ensuring zero regulatory risk and user trust

Solution & Approach

1. Polyglot Microservice Architecture

Elixir/OTP for real-time streaming and concurrency (Phoenix Channels, Broadway for Kafka consumers), Python for quantitative computation (pandas, NumPy, SciPy, statsmodels), React/TypeScript for interactive visualisation. Each service does what its language does best.

2. Technical Analysis Engine (43+ Indicators)

Full indicator suite across four categories: Trend (SMA, EMA, MACD, ADX, Ichimoku, Parabolic SAR, Aroon), Momentum (RSI, Stochastic RSI, Williams %R, CCI, ROC, KAMA), Volatility (ATR, Bollinger Bands, Keltner Channel, Donchian), Volume (OBV, VWAP, CMF, MFI, ADI). Technical Summary Score [-100, +100] with Buy/Sell bands - TradingView-style composite scoring.

3. Risk Analytics with Mathematical Rigor

Portfolio ratios (Sharpe, Sortino, Calmar, Treynor, Beta, Alpha), Value at Risk via three methods (Historical, Parametric Gaussian, Monte Carlo with 10,000 GBM simulations), Conditional VaR / Expected Shortfall, correlation matrix with Ledoit-Wolf shrinkage, stress testing against historical scenarios (COVID-19, GFC, Demonetisation, Taper Tantrum), and max drawdown depth/duration/recovery analysis.

4. Ensemble Forecasting

ARIMA/SARIMA (auto-fitted via AIC/BIC selection) + Facebook Prophet (NSE trading calendar + weekly seasonality) combined via inverse-MAE weighted ensemble. Walk-forward backtesting validates with MAE, RMSE, MAPE, and directional accuracy.

5. Portfolio Intelligence & Discovery

Shipped May–Aug 2026, this layer turned the analytics engine into a daily driver: multi-year XIRR per holding and portfolio-level, nightly dividend tracking, and sector/asset-class/market-cap breakdowns; a FIFO-matched trade journal with realized P&L, win rate, profit factor, and expectancy; an append-only suggestion journal that records what the models recommended and how those calls aged - a scorecard the user can't edit; a NIFTY 500 screener with 400-bar backfill plus fundamentals per symbol, tier-ranked composite scoring, and a resumable nightly refresh; a deploy advisor that proposes allocations in whole shares; QuantStats HTML tear sheets; and OData v4 entity sets so Power BI and Excel can live-refresh against the platform.

Implementation

Four architectural decisions shaped the platform:

1. Elixir umbrella monorepo with service boundaries. The Gateway (Phoenix), Market Data (OTP GenServer), and Notification (Broadway) services live in an Elixir umbrella. The Analytics Engine (Python/FastAPI) and Data Pipeline (Python/Kafka consumers plus nightly schedulers for fundamentals, dividends, and universe screening) are separate services. Docker Compose orchestrates a 13-service topology - 8 application services plus Postgres, Redis, Kafka, Prometheus, and Grafana - with health checks on every stateful service.
KiteEdge/
├── apps/
│   ├── kite_edge/          # Core domain - Ecto schemas, Kite API client
│   ├── kite_edge_web/      # Phoenix REST + channels - 50 endpoints
│   ├── market_data/        # KiteTicker → Kafka publisher
│   └── notification/       # Broadway Kafka consumer → alerts + email
├── analytics_engine/       # Python FastAPI - indicators, risk, forecasts
├── data_pipeline/          # Kafka consumers + nightly schedulers
│                           #   candles, indicators, alerts, forecasts,
│                           #   fundamentals, dividends, universe screener
├── dashboard/              # React SPA - interactive dashboard
└── infra/                  # Docker, Grafana, Kafka, Prometheus config
2. Real-time streaming via Phoenix Channels + Kafka. Market Data service connects to Kite's binary WebSocket (KiteTicker), decodes tick data, and publishes to Kafka topics. The Data Pipeline aggregates ticks into candles (1m, 5m, 15m, 1h, daily), computes indicators, and evaluates alert rules. Phoenix Channels push live updates to the React dashboard. 3. Privacy-first session management. Kite OAuth tokens live only in Redis with an 18-hour TTL - never persisted to disk. The platform is fully self-hosted; no data leaves the user's machine. This is the trust differentiator. 4. Every prediction includes confidence intervals and methodology. Monte Carlo VaR reports the simulation count and distribution assumptions. Forecasts include MAE/RMSE from walk-forward validation. Stress test scenarios cite the historical event and date range. No black boxes.
# Monte Carlo VaR - 10,000 GBM simulations
def monte_carlo_var(returns, portfolio_value, days=10, sims=10_000, ci=0.95):
    mu = returns.mean()
    sigma = returns.std()
    
    # Geometric Brownian Motion
    Z = np.random.standard_normal((sims, days))
    daily_returns = np.exp((mu - 0.5 * sigma**2) + sigma * Z)
    price_paths = portfolio_value * np.cumprod(daily_returns, axis=1)
    
    final_values = price_paths[:, -1]
    var_absolute = portfolio_value - np.percentile(final_values, (1 - ci) * 100)
    cvar = portfolio_value - final_values[final_values <= np.percentile(
        final_values, (1 - ci) * 100
    )].mean()
    
    return {"VaR": var_absolute, "CVaR": cvar, "simulations": sims}

Outcome & Metrics

  • 43+ technical indicators across Trend, Momentum, Volatility, and Volume categories with multi-timeframe support
  • 50 documented API endpoints across portfolio, risk, forecasting, screener, trade journal, watchlists, and reports
  • 13 Docker Compose services - 8 application services plus Postgres, Redis, Kafka, Prometheus, Grafana
  • 8 Kafka topics feeding candle building, indicator updates, alert evaluation, and forecast scheduling
  • 4 VaR models - Historical, Parametric, Monte Carlo (10K GBM simulations), Conditional VaR - plus 4 historical stress scenarios (COVID-19, GFC, Demonetisation, Taper Tantrum)
  • 3 forecast models - ARIMA/SARIMA, Prophet, Inverse-MAE Ensemble - validated by walk-forward backtesting
  • NIFTY 500 screener - nightly universe refresh, tier-ranked composite scoring, resumable batch scheduler
  • 127 test files across the Elixir apps and Python analytics engine
  • Real-time streaming - Phoenix Channels + Kafka for live portfolio updates; Prometheus + Grafana observability

Learnings

What Worked

The polyglot approach paid off. Elixir handles 100K+ concurrent WebSocket connections with minimal memory - perfect for real-time tick streaming. Python's NumPy/pandas/statsmodels ecosystem made quantitative finance computations straightforward. Trying to do everything in one language would have compromised both.

Honest constraints beat false precision. Fundamentals coverage is best-effort and nullable by design (no free source covers Indian small-caps completely), tax estimates carry documented caveats instead of pretending to be advice, and the suggestion journal keeps the models accountable by recording every call and how it aged.

What I'd Change

Would implement a proper event-sourcing pattern for the analytics pipeline instead of direct Kafka consumers. The current consumer-based approach works but makes replaying historical analysis harder. An event store would let users re-run any analysis against historical market conditions.

Related work