Web applications

TradeIQ CSE

Strategy backtesting, paper trading and portfolio analytics for the Colombo Stock Exchange

Abstract

TradeIQ CSE is a web platform that turns Colombo Stock Exchange market data into a validated, queryable store and layers rule-based strategy backtesting, paper-trading simulation, portfolio analytics, and a machine-learning price-direction service on top of it. It is built for retail investors, finance students, and researchers who have no programming background, and for external developers who need programmatic access to CSE data through a public API. Unlike Backtrader, TradingView, or QuantConnect, it models CSE-specific mechanics — the local 1.12% transaction-cost schedule, T+2 settlement, and per-era data gaps — so simulated results reflect what a Sri Lankan investor would actually have experienced. The system is delivered as three containerised API services plus a scheduled data pipeline, with a shared deterministic simulation engine and strict look-ahead prevention: no decision at time T may use data timestamped after T.

The problem

CSE investors have no way to test a trading rule before risking real money on it. Backtrader, TradingView, and QuantConnect don't carry CSE data. CSE-facing sites give price charts but no backtesting, simulation, or analytics.

Pointing a generic tool at CSE data wouldn't work either. Sri Lankan trading carries a 1.12% one-way fee and settles on T+2, so a strategy that looks profitable under a zero-fee model can lose money in practice. The historical data is also uneven — close-only before 2000, no open price until 2017 — so any platform that quietly interpolates across those gaps produces results you can't trust.

The solution

TradeIQ CSE validates CSE market data into a canonical store, then adds rule-based backtesting, paper trading with virtual capital, portfolio analytics, and an ML price-direction service, plus a public API for developers.

The architecture is three services — Market Data, Account, and ML Prediction — behind an nginx reverse proxy, with a scheduled AWS Lambda data pipeline. Each service owns its own PostgreSQL database and talks to the others only through REST APIs. Redis handles rate limiting and caching. The frontend is a React SPA, and the whole thing runs locally with one Docker Compose command.

Two decisions carry the credibility of the system. One stateless simulation engine is shared by both backtesting and paper trading, so fill logic, fees, and T+2 settlement are defined once and can't drift apart. And look-ahead prevention is structural: a rule evaluated on the close of day T can only execute against the open of day T+1.

In detail

Approach

Rule sets are built through forms, not scripting — one buy rule plus one or more sell rules, with an end-of-period fallback. The same saved rule set can drive a historical backtest and then be attached to a paper-trading portfolio, so a user tests on history and runs it forward against live data.

Results are shown against two reference points: a benchmark index (ASPI or S&P SL20) and the hindsight-optimal outcome for the same period. The second one lets a user see the gap between their rules and the best achievable result, which says more than a bare return figure.

Challenges

The data eras were the hardest part. Instead of locking the platform to 2017 onward, the engine changes behaviour by era — next-day-open fills inside the validated 2017–2025 window, close-price fallback for earlier periods, with results annotated as reduced fill realism. Charts do the same: render what exists, state the gap, never interpolate.

Fees had to be configuration rather than constants, itemised per fill across five components and reconciling exactly with totals. Money uses exact decimal types, four places internally, two on screen.

Sri Lanka's Personal Data Protection Act ruled out storing plaintext email, so addresses are held as ciphertext plus a blind-index hash for lookup.

Results

Ten-security backtests over 2017–2025 target 30 seconds, single-security 10, with submission acknowledged in 2 seconds while the run continues in the background. Daily ingestion including validation finishes within 30 minutes. The schema is 28 tables across three namespaces. Because the simulation engine sits clear of transport and persistence, its fill, fee, and settlement logic are each testable in isolation.

Future work

Daily index ingestion isn't scheduled yet, so benchmark overlays run on historical index data and degrade gracefully. Tamil and Sinhala translations fall back to English. Mobile is deferred.

My contribution

I authored the ML prediction service requirements — a PPO model giving per-security directional calls with confidence values, generated in scheduled batches, constrained so no output is a buy/sell/hold recommendation — plus the data-pipeline and admin-dashboard requirements and the legal and compliance sections. In the architecture document I authored the deployment and implementation views, the pipeline activity diagram, and the administration use-case diagram. Krishna covered backtesting and the rule builder; Nimesh covered paper trading, the simulation engine, and analytics.

Related projects

Web applications

Adept

Automated Developer Productivity and Code Quality Insights Platform

212 2026
Web applications

Loop

Unify WhatsApp, Telegram and web chat into one AI-routed inbox for small businesses.

211 23