Home/Articles/Algo Trading Systems
Algo Trading Systems
13 min read
October 2026

How to Build Your Own Customized Trading Desk — A Practical Architecture Guide

Most retail and prop traders either pay for a black-box platform they cannot customize, or hack together scripts that break the first time a broker feed hiccups. Here is the actual architecture — feed ingestion, strategy engine, paper trading, cloud hosting — behind a real, production-grade trading desk, built the way we built ours.

KP
Kiran Pawar
BFSI Transformation Consultant
Follow

Every serious trader eventually hits the same wall. Charting platforms are good at charts and bad at automation. Broker-provided "algo" tools lock you into whatever strategy templates the vendor decided to ship. And a folder of Python scripts that worked great in backtesting falls over in week two of live trading — a feed goes quiet for ten minutes and nobody notices, or a strategy fires a trade at 7:40 AM on stale pre-market data because nobody put a clock check in front of it.

We went through exactly this progression building our own desk — a real, running system that scans NIFTY, Bank Nifty, and MCX commodities, manages its own paper-trade ledger, and has already taught us (the hard way, more than once) what a "trading platform" actually needs to be reliable. This is that architecture, written up as a practical guide rather than a case study — enough detail that a competent engineer could build their own version, and enough honesty about what breaks that they build it right the first time.

The Professional Architecture

The mistake almost everyone makes on attempt one is writing a single script that fetches data, computes a signal, and places a trade, all in one function. It works — for about a week. The moment you want a second strategy, a second instrument, or a paper-trading mode that does not touch real money, that single script becomes unmaintainable. A trading desk needs to be a system, not a script, and that means separating it into layers that only talk to each other through a narrow, well-defined interface.

Customized Trading Desk — Layered Architecture

Interface Layer
Broker API
OAuth / token auth · REST for history · WebSocket for live ticks
raw ticks + historical candles
Ingestion Layer
Market Data Normalizer
One OHLCV shape, one timezone, one source of truth for every strategy downstream
normalized candles
Strategy Layer — Your Algos
Breakout Engine
Signal line + confirmed close
Mean Reversion
Band / range fade logic
Momentum Scanner
Multi-symbol ranking
Your Custom Algo
Same interface, your edge
entry / exit signal
Risk & Execution Layer
Position Sizing
Lots, capital-at-risk per trade
Stop-Loss / Trail
Close-confirmed, never a wick
validate first
Paper Trade Simulator
Every strategy proves itself here before it sees real capital
promote once proven
Live Order Router
Same code path, real fills
every fill, every session
Persistence Layer
System of Record
SQLite / Postgres — Trades · Sessions · P&L · Audit Trail
read by
Observability Layer
Web Dashboard
Live chart + signal overlay
Telegram Alerts
Entries, exits, failures
Feed Watchdog
Detects stale data, self-heals
🧩One normalized data shape — every strategy plugs into the same interface
📝Paper trade is a layer, not a phase — the same code path live trading uses
🛡️Watchdog + alerts are not optional — a silent feed is worse than a wrong signal

The six layers of a production trading desk — from broker feed to dashboard, with paper trading as a first-class layer rather than a bolt-on mode

  • Interface layer — the broker API itself: authentication, REST calls for historical data, a WebSocket for live ticks. This is the only layer that knows your broker's specific quirks.
  • Ingestion layer — normalizes whatever the broker hands you into one consistent OHLCV shape, one timezone, one source of truth. Every strategy downstream reads from here, never from the broker API directly.
  • Strategy layer — your actual algos. Each one is a pure function of normalized candles in, a signal out. It should not know or care how it is hosted, how orders get placed, or whether it is running in paper or live mode.
  • Risk & execution layer — position sizing, stop-loss and trailing logic, and the fork between a paper-trade simulator and a live order router. This is the layer that decides how much to risk and when to get out, independent of why the strategy said to get in.
  • Persistence layer — every trade, every session, every signal gets written somewhere durable (SQLite is plenty to start; Postgres once you outgrow a single file). If a strategy cannot tell you exactly what it did and why, three weeks from now, it is not production-ready.
  • Observability layer — a dashboard you can actually look at, alerts that reach you (Telegram is underrated for this — instant, free, and you already check it), and a watchdog that notices when the feed itself has gone stale.
The Layer People Skip

Observability is the layer almost every first attempt leaves out, and it is the one that actually determines whether you trust the system enough to leave it running unattended. A strategy that is occasionally wrong is a strategy. A strategy that is sometimes silently not running at all is a liability you will not discover until you check your P&L and find a day with zero trades you cannot explain.

Connecting to Your Broker's API for Live Feeds

Every broker API has the same two halves, and conflating them is the single most common beginner mistake: a REST API for anything historical or on-demand (candle history, option chains, order placement), and a WebSocket for anything that streams continuously (live ticks, order updates). Treat them as genuinely separate concerns.

Authentication

Most modern broker APIs in India (Shoonya/Finvasia, Zerodha Kite, Upstox, Fyers, Angel One — the pattern is nearly identical across all of them) use an OAuth-style flow: you exchange a daily auth code for an access token, then inject that token as a bearer header on every subsequent call. The practical implication is that your token refresh has to be a scheduled, automated job — not something you remember to do manually at 9 AM, because the one morning you forget is the one morning your strategies silently fail to enter a single trade. We learned this specific lesson from a cron job whose scheduled time quietly drifted by several hours after a server reboot changed how the OS cached its timezone — a token refreshed at the wrong hour produced a token that did not survive to market open, and three engines ran with nothing but reconnect errors until a human intervened.

Historical Data vs. Live Ticks

Pull historical candles (typically 1-min or 5-min OHLC) via REST on a schedule — once at startup to backfill, then incrementally. Subscribe to live ticks via WebSocket for anything that needs to react within seconds, like a stop-loss check. Do not poll a REST endpoint every few seconds for "live" prices — it is slower, it burns your API rate limit, and most brokers will eventually throttle or block an account that does this.

  • Build in exponential backoff and auto-reconnect on the WebSocket from day one — it will disconnect, during market hours, for reasons that have nothing to do with your code.
  • Track the timestamp of the last tick you actually received, not just whether the socket object reports itself as "connected." A socket can stay technically open while the feed itself has gone silent — this is the single most dangerous failure mode because nothing throws an exception; your strategies just quietly stop seeing new data.
  • Respect published rate limits explicitly in code (a sleep between batched calls, a request counter), rather than finding your limit by getting throttled in the middle of a trading session.
  • For less liquid instruments — commodity futures, smaller-cap options — do not assume an international data provider is an acceptable substitute "just to save an API call." A USD-denominated crude oil future and an INR-denominated MCX contract track genuinely different economics (currency, import duty, local demand); treat your broker's own feed as the only source of truth for anything you actually trade.

A Practical Pattern for Writing Your Own Algo

You do not need a PhD in quantitative finance to write a reasonable first strategy — you need a signal that is well-defined enough to backtest and a risk rule that is tight enough to survive being wrong. Here is a generic pattern, the same shape underneath most of the breakout-style strategies running on our own desk, stripped down to its structure so you can plug in your own logic.

  1. 1.Define a signal level from price action, not from a prediction. For example: the midpoint of a specific candle's high-low range (the first red candle of the session, or a fixed time-block like 12:30–1:00 PM) — something objectively computable from data you already have, not a forecast.
  2. 2.Wait for a CONFIRMED break of that level — a candle CLOSE beyond it, never a wick or an intra-candle touch. This single rule eliminates a large fraction of false signals that a naive "price crossed X" check would catch.
  3. 3.Enter at the next candle's open, not at the signal candle's own closing price. You cannot actually transact at a price the moment you decide to act on it; price the trade the way you could actually have filled it.
  4. 4.Set your stop-loss at the SAME level you used to signal entry, not somewhere arbitrary. If a close above a line triggered your long, a close back below that identical line is your most honest, tightest invalidation signal — it directly measures whether the premise you traded on is still true.
  5. 5.Trail the stop as the trade moves in your favor — to the prior candle's low (for a long) or high (for a short) — so a winning trade is allowed to keep running instead of being capped at a fixed target the moment it is first profitable.
  6. 6.Define an explicit time-based exit (a square-off time) independent of whether the stop or a target has fired. A position that is still open for reasons that made sense at 10 AM is not automatically fine to be open at 3 PM — give every session a hard close.
  7. 7.Gate entries with one independent filter against the prevailing trend (a moving-average band, for instance) so the strategy does not fight an obvious trend on every single signal — this alone tends to remove the worst-performing subset of trades without needing to touch the entry rule itself.

“A strategy is not "the rule that makes money." It is the rule that tells you, in writing, exactly when you were wrong — before the market has to tell you with a much bigger number.”

Paper Trading Before Risking Real Capital

Paper trading should not be a "mode" bolted onto a live-trading codebase as an afterthought — build it as the same execution path the live router will eventually use, just swapping the order-placement call for a ledger write. If paper trading runs through genuinely different code than live trading, you have validated nothing; you have tested a different program.

  • Simulate realistic fills, not the exact signal-candle price — if your strategy enters at the next candle's open in live trading, the paper simulator should price the trade exactly the same way, not at a cleaner, more convenient number.
  • Track more than just total P&L: win rate, average win vs. average loss, max drawdown, and a breakdown of exits by reason (stop-loss vs. target vs. time-based square-off). A strategy that wins 30% of the time with a 3:1 average win-to-loss ratio is healthy; a strategy that wins 70% of the time but has one catastrophic loss wiping out the rest is not, no matter how good the headline win rate looks.
  • If you do not have historical options-chain data (most retail setups do not), simulate option premiums with a standard pricing model (Black-Scholes for spot-referenced options, Black-76 for options on a futures contract) using the real underlying price path and a realistic volatility input — and say so plainly in your own results. A simulated-premium backtest is a directional estimate of whether the RULES work, not a promise of exact rupee figures.
  • Run paper trading live, during real market hours, for long enough to see more than one kind of market regime — a trending day, a choppy day, a gap-open day — before concluding anything. Ten trading days tells you the strategy did not immediately break; it does not yet tell you it has a durable edge.
  • Watch the breakdown by instrument, not just the aggregate. A multi-instrument strategy can look fine in total while one instrument quietly loses money every day and another carries the whole result — exactly the kind of imbalance that only shows up once you split the numbers apart.

Porting the Application to the Cloud

A strategy that only runs while your laptop is open and awake is not a trading desk, it is a demo. Getting to genuine 24/7 (or full-market-hours) reliability is mostly unglamorous infrastructure work, and it is worth doing properly rather than running a screen session over SSH and hoping.

  1. 1.A small VPS is enough to start. A modest 2 vCPU instance comfortably runs a feed connection, several strategy loops, a web dashboard, and a database for a single-user or small-team desk — you do not need a trading-firm-scale cluster for this.
  2. 2.Run the application as a proper OS service (systemd on Linux), not inside a terminal session. A service restarts automatically on a crash or a server reboot; a terminal session dies the moment your SSH connection drops.
  3. 3.Keep credentials out of source code entirely — environment variables or a secrets file outside your git repository, loaded at startup. The number of real breaches that trace back to a committed API key is not a coincidence.
  4. 4.Deploy through git, not by hand-editing files on the server. Every change should be a commit with a clear message, pushed, then pulled or deployed to the server — so you always have a true history of what actually changed and when, and can roll back to a known-good state in seconds if a deploy goes wrong.
  5. 5.Put a reverse proxy (nginx) in front of your dashboard for TLS and routing, rather than exposing your application server directly to the internet.
  6. 6.Budget real CPU headroom if you are running many strategies concurrently on a burstable-credit instance type — a box that throttles under sustained load can stall your event loop in ways that look exactly like a feed problem but are actually an infrastructure-sizing problem.

What Actually Breaks (So You Can Build It Right the First Time)

Every one of these came from something that actually happened running our own desk, not a hypothetical. They are generalizable lessons, not a single war story:

  • A strategy entering trades outside market hours on stale cached data, because the call site had no explicit time-window check of its own — "the data looked recent enough" is not a substitute for an explicit clock check at every single entry point, not just the ones you remember to guard.
  • A pause switch that was supposed to stop new entries for one strategy silently also stopping an unrelated strategy's exit/target checks, because both shared one gate that was never meant to cover both. Pausing new risk and managing existing risk are two different concerns — never let one flag control both unless you have explicitly verified every strategy sharing that flag actually wants both behaviors.
  • A transient bad data read (a zero or missing price from the broker for one single tick) causing a strategy to give up on a valid signal for the entire day, instead of simply retrying on the next poll. Transient glitches should be retried, not treated as a reason to abandon an otherwise-valid trade.
  • A feed that looked "connected" at the socket level while having gone completely silent at the data level — only caught by explicitly tracking the timestamp of the last tick received, not by trusting a boolean connection flag.
Want to Build One of These Instead of Debugging One?

If you are evaluating whether to build a customized trading desk in-house, license one, or bring in someone who has already made (and fixed) these mistakes — that is exactly the kind of conversation worth having before you write the first line of code, not after the third production incident.

KP

Discuss This with Kiran

If this resonates with challenges your firm is facing, let's have a strategic conversation about your data transformation journey.