How armaanfarshori/dhan_algo works
Tessera is a self-hosted NSE trading platform. The main workflow ingests Dhan market data, builds bars, generates and gates strategy signals, applies risk controls, then executes and persists trades; paper trading is the default. A separate API process reads platform state for a polling dashboard. F&O collection/paper trading, options scalping, and historical backtesting are substantial parallel capabilities. The README documents the process-level wiring; sampled source also supports the scalper’s orchestration and dashboard polling, but not every subsystem’s internal calls.
Main entry points: db.py TimescaleDB · runner.py Strategy runner · execution.py Executors · scalper_orchestrator.py Scalper orchestration
Components 23
Equity Trading
- Trader process
apps/trader.py - Live feed
core/live_feed.py - Bar builder
engine/bar_builder.py - Strategy runner
engine/runner.py - ORB strategy
strategies/orb.py - Kronos gate
ml/kronos_gate.py - Risk engine
engine/risk.py - Executors
engine/execution.py - Portfolio
engine/portfolio.py
Options Trading
- F&O collection
core/fno_collector.py - F&O paper
core/fno_paper.py - Scalper orchestration
engine/scalper_orchestrator.py - Scalper signals
strategies/options_scalper.py
Research
- Backtesting
research/backtest/engine.py - F&O backtesting
research/backtest/fno_orchestrator.py
API and Data
- TimescaleDB
db.py - API process
apps/api.py - API routes
apps/routes
Dashboard
- Dashboard app
dashboard/src/App.jsx - Data polling
dashboard/src/hooks/useDashboardData.js
Other components
- Operator
- Dhan feed
- Dhan API
Connections 26
- Dhan feed → Live feed: streams ticks
- Live feed → Bar builder: forwards ticks
- Bar builder → TimescaleDB: writes bars
- Trader process → Live feed: starts feed
- Trader process → Strategy runner: starts runner
- Strategy runner → ORB strategy: requests decisions
- Strategy runner → Kronos gate: checks signals
- Strategy runner → Risk engine: checks intent
- Strategy runner → Executors: submits orders
- Executors → Dhan API: places live orders
- Executors → Portfolio: records fills
- Portfolio → TimescaleDB: persists positions
- F&O collection → Dhan API: fetches options data
- F&O collection → TimescaleDB: stores market history
- F&O paper → TimescaleDB: records paper trades
- Scalper orchestration → Scalper signals: polls signals
- Scalper orchestration → Risk engine: checks entries
- Scalper orchestration → Executors: submits orders
- Backtesting → TimescaleDB: reads bars
- F&O backtesting → TimescaleDB: reads history
- Operator → Dashboard app: views dashboard
- Dashboard app → Data polling: loads data
- Data polling → API process: requests endpoints
- API process → API routes: dispatches requests
- API routes → TimescaleDB: queries state
- API routes → Dhan API: fetches live account data