Skip to main content

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 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.
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 from uzse.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:
StageScriptWhat It Does
1. Downloaddownload-trades.tsLaunches a headless Chromium browser via Playwright and saves paginated HTML trade tables from uzse.uz to a local tmp/ directory.
2. Importimport-trades.tsParses 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 Candlesbuild-candles.tsAggregates 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. Analyzenpm startLaunches 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 addExchangeSchema API lets you register any MongoDB-backed data source as a named exchange, which is exactly how mongo-exchange is wired in this project.
  • Graph and UI packages@backtest-kit/graph and @backtest-kit/ui handle 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

PackageRole
playwrightHeadless Chromium scraping of uzse.uz trade pages
mongooseMongoDB ODM for trade-results and candle-items collections
backtest-kit + @backtest-kit/*Visual editor, Pine Script runtime, charting UI
functools-kitFunctional utilities used throughout the pipeline scripts
get-moment-stampTimestamp utility used in pipeline date calculations
garchGARCH volatility modelling for advanced indicators
volume-anomalyVolume anomaly detection indicator library
agent-swarm-kit + ollamaAI 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.

Build docs developers (and LLMs) love