Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/backtest-kit/uzse-backtest-app/llms.txt

Use this file to discover all available pages before exploring further.

This quickstart walks you through the complete UZSE Backtest App pipeline — from a fresh clone to a live Pine Script chart in the browser — in roughly 10–15 minutes, depending on how many pages of trades the date range returns. By the end you will have a running MongoDB instance, one month of HMKB trade data imported and built into 11 OHLCV timeframes, and the backtest-kit editor open and ready for indicators.
1

Clone the repository and install dependencies

The project is not published to npm. Clone it, enter the directory, and install all Node.js dependencies:
git clone https://github.com/backtest-kit/uzse-backtest-app.git
cd uzse-backtest-app
npm install
Node.js 18 or newer is required. Check your version with node --version before continuing.
2

Start MongoDB with Docker

The project ships a Docker Compose file at docker/mongo/docker-compose.yaml that runs MongoDB Community Server 8.0 and persists data to a local mongo_data/ volume.
version: '3.8'
services:
  mongodb:
    image: mongodb/mongodb-community-server:8.0.4-ubi8
    container_name: node-ollama-agent-swarm-mongo-server
    ports:
      - '27017:27017'
    volumes:
      - ./mongo_data:/data/db
    restart: always
volumes:
  mongo_data:
Start the container:
cd docker/mongo && docker compose up -d
MongoDB will be available at mongodb://localhost:27017/backtest. All scripts connect to this URI by default; override it with the MONGO_URI environment variable if needed.
Run docker compose logs -f from the docker/mongo directory to confirm MongoDB has finished starting before proceeding.
3

Download a month of UZSE trades

Return to the project root, then run download-trades.ts with the HMKB ticker’s ISIN (UZ7011340005) and a one-month date range. Dates use DD.MM.YYYY format.
cd ../..
npx tsx scripts/download-trades.ts UZ7011340005 01.03.2026 31.03.2026
The script launches a headless Chromium browser, paginates through the trade_results endpoint on uzse.uz, and saves each page as tmp/trades_page_N.html. The terminal will report the total page count and progress as files are written.
The tmp/ directory is created automatically if it does not exist. Any existing *.html files there are deleted at the start of each run, so you always start with a clean slate for the date range you specified.
4

Import the trades into MongoDB

Once the HTML files are in tmp/, parse and insert them into the trade-results collection:
npx tsx scripts/import-trades.ts
The script reads every trades_page_*.html file in order, extracts rows from the HTML tables, converts Russian-language date strings to UTC timestamps, and inserts each record. Duplicate detection is handled by a SHA-1 hash of the trade’s key fields, so re-running this command is completely safe — duplicate records are silently skipped and counted separately in the output. The tmp/ directory is cleaned up automatically after a successful import.Sample output:
Found 4 file(s)
MongoDB connected
trades_page_1.html: 50 rows
trades_page_2.html: 50 rows
trades_page_3.html: 50 rows
trades_page_4.html: 23 rows
Done. Inserted: 173, skipped (duplicates): 0
Tmp cleaned.
5

Build OHLCV candlesticks

With trades in MongoDB, generate candlesticks for all supported timeframes:
npx tsx scripts/build-candles.ts HMKB UZ7011340005
The first argument is the display symbol (HMKB) written into the candle-items collection; the second is the ISIN used to query the trade-results collection. The script builds all 11 timeframes1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, and 1d — in a single pass. Intraday gaps and non-trading days (weekends and holidays) are automatically filled using the previous close price so the series is continuous.Progress is printed inline as each day is processed:
MongoDB connected
Range: 2026-03-01 — 2026-03-31 (31 days)
[31/31] 2026-03-31  trades:12  real_min:12  candles:2402  inserted:74462  skipped:0
Done. Inserted: 74462, skipped (duplicates): 0
Like the import step, candle building is idempotent. The candle-items collection has a unique index on { symbol, interval, timestamp }, so re-running the script for the same date range simply skips existing candles without creating duplicates.
6

Start the editor

Launch the backtest-kit editor from the project root:
npm start
This runs node ./node_modules/@backtest-kit/cli/build/index.mjs --editor, which starts a local web server and opens the backtest-kit editor in your browser. Select HMKB from the symbol list, choose a timeframe, and paste any Pine Script indicator into the editor panel to run it against the UZSE candlestick data you just built.
The editor reads candlestick data directly from MongoDB. Make sure the Docker container from Step 2 is still running before you start the editor.

Next Steps

Download Trades

Learn date formatting, all CLI arguments, how pagination and retries work, and how to generate a batch fetch script that covers years of history in one shot.

Build Candles

Deep dive into the gap-filling algorithm, how higher timeframes are aggregated from the 1m series, and the idempotency guarantee.

Editor

Configure the backtest-kit editor, load symbols, switch timeframes, and apply Pine Script indicators to your UZSE charts.

Batch Fetch

Use the parser sequence script to auto-generate a shell script that downloads and imports multiple years of trade history month by month.

Build docs developers (and LLMs) love