UZSE Backtest App is an open-source toolkit that closes the gap between regional stock exchanges and the rich Pine Script ecosystem. Because TradingView only indexes a fraction of the world’s exchanges, traders on markets like UZSE (Uzbekistan), MSE (Mongolia), DSE (Dhaka, Bangladesh), and others are left without chart tooling. This project solves that by scraping raw trade data directly from the exchange website, storing it in MongoDB, assembling OHLCV candlesticks, and feeding those candles into the backtest-kit visual editor — giving you a full Pine Script environment over data that TradingView has never seen.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/theonetrade/uzse-backtest-app/llms.txt
Use this file to discover all available pages before exploring further.
UZSE Backtest App is designed specifically for exchanges that are not listed on TradingView. This includes regional emerging-market exchanges such as UZSE (Uzbekistan), MSE (Mongolia), DSE (Dhaka, Bangladesh), GSE (Ghana), SGBV (Algeria), BSE (Botswana), ESE (Eswatini), and MERJ (Seychelles). If your exchange is already on TradingView, you can use Pine Script there directly.
Why This Project Exists
TradingView is the de-facto standard for technical analysis, but it does not carry data for many regional emerging-market exchanges. Traders on those exchanges are typically limited to raw aggregate trade tables — sometimes downloadable only one month at a time in an Excel file that lacks minute-level timestamps. This makes it impossible to apply modern open-source indicator libraries or to run backtests without building the entire data pipeline from scratch. UZSE Backtest App automates that pipeline. By using Playwright to scrape paginated HTML trade tables fromuzse.uz, parsing them into structured records, and persisting them in MongoDB, the app produces a clean, queryable dataset. A subsequent candle-building step transforms per-trade rows into standard OHLCV candlesticks at eleven timeframes, ready for consumption by any backtest-kit indicator.
The Four-Stage Pipeline
The app follows a linear, reproducible pipeline that you can run in full or restart at any stage without creating duplicates:| Stage | Script | What It Does |
|---|---|---|
| 1. Download | download-trades.ts | Launches a headless Chromium browser via Playwright and saves paginated HTML trade tables from uzse.uz to a local tmp/ directory. |
| 2. Import | import-trades.ts | Parses the saved HTML files, extracts trade rows (time, price, quantity, volume), deduplicates them with a SHA-1 hash, and upserts them into the trade-results MongoDB collection. |
| 3. Build Candles | build-candles.ts | Aggregates trades into 1-minute buckets, fills intraday and non-trading-day gaps, then rolls the 1m series up into all supported higher timeframes and writes them to candle-items. |
| 4. Analyze | npm start | Launches the backtest-kit visual editor, which connects to the candle-items collection via a custom mongo-exchange adapter and exposes the full Pine Script indicator and strategy toolchain. |
The backtest-kit Ecosystem
backtest-kit is the engine that powers the analysis layer. It provides:- Visual editor — a browser-based charting interface where you can load any symbol and timeframe from your local MongoDB data.
- Pine Script support — a TypeScript-compatible implementation of Pine Script indicators and strategies via
@backtest-kit/pinets. - Extensible exchange module — the
addExchangeSchemaAPI lets you register any MongoDB-backed data source as a named exchange, which is exactly howmongo-exchangeis wired in this project. - Graph and UI packages —
@backtest-kit/graphand@backtest-kit/uihandle rendering, making the visual editor fully self-contained.
Supported Timeframes
Once the 1-minute base series is built, the candle-builder automatically aggregates into all of the following intervals:1m · 3m · 5m · 15m · 30m · 1h · 2h · 4h · 6h · 8h · 1d
All timeframes are stored in the same candle-items collection and are queryable by { symbol, interval, timestamp }.
Key Dependencies
| Package | Role |
|---|---|
playwright | Headless Chromium scraping of uzse.uz trade pages |
mongoose | MongoDB ODM for trade-results and candle-items collections |
backtest-kit + @backtest-kit/* | Visual editor, Pine Script runtime, charting UI |
functools-kit | Functional utilities used throughout the pipeline scripts |
get-moment-stamp | Timestamp utility used in pipeline date calculations |
garch | GARCH volatility modelling for advanced indicators |
volume-anomaly | Volume anomaly detection indicator library |
agent-swarm-kit + ollama | AI agent layer for news-sentiment analysis |
Where to Go Next
Quickstart
Clone the repo, spin up MongoDB, download your first month of UZSE trades, build candles, and open the editor in under 30 minutes.
Prerequisites
Review the system requirements — Node.js 18+, MongoDB, and Playwright browsers — before running any scripts.
Download Trades
Deep-dive into how the Playwright scraper fetches paginated HTML trade tables from uzse.uz.
Build Candles
Understand the five-step candle algorithm: aggregation, gap-filling, holiday-filling, timeframe roll-up, and idempotency.
Visual Editor
Learn how to load symbols and timeframes in the backtest-kit editor and apply Pine Script indicators.
Exchange Module
See how the custom
mongo-exchange adapter wires MongoDB candle data into the backtest-kit runtime.