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.

The bulk fetch scripts automate the full historical data collection process by chaining download-trades and import-trades in a tight loop, iterating through every calendar month from 8 February 2018 to 20 April 2026 for ISIN UZ7011340005. Running one of these scripts unattended is the easiest way to populate trade-results with the complete dataset before building candles.
Fetching over eight years of monthly data involves roughly 100 sequential Playwright sessions and can take many hours depending on your network speed and the responsiveness of uzse.uz. Consider running the script in a tmux or screen session so it survives terminal disconnections.

Scripts

Two equivalent scripts are provided — choose the one that matches your operating system.
ScriptPlatform
scripts/linux/fetch.shLinux / macOS
scripts/win/fetch.batWindows (cmd)

Usage

# Linux/macOS
bash scripts/linux/fetch.sh

# Windows
scripts\win\fetch.bat
No arguments are required. Both scripts run from the project root.

What the Scripts Do

Each script iterates every month in the range, calling the two pipeline scripts in sequence. One iteration looks like this:
npx -y tsx scripts/download-trades.ts UZ7011340005 08.02.2018 28.02.2018
npx -y tsx scripts/import-trades.ts
The first month begins on 08.02.2018 (the earliest available trade date) and the last month ends on 20.04.2026. Every intermediate month uses the first and last calendar day of that month as the begin and end arguments. After each import-trades run the tmp/*.html files are deleted automatically, keeping disk usage minimal throughout the long run.

Regenerating the Scripts

If you need to extend the date range or change the ISIN, regenerate the shell script from the parser sequence snippet in the README:
const lines = ['#!/bin/bash', 'cd \"$(dirname \"$0\")/../..\"', ''];
const start = new Date(2018, 1, 1);
const end   = new Date(2026, 3, 1);
let d = new Date(start);

while (d <= end) {
  const y = d.getFullYear();
  const m = d.getMonth();
  const isFirstMonth = (y === 2018 && m === 1);
  const isLastMonth  = (y === 2026 && m === 3);
  const beginDay = isFirstMonth ? '08' : '01';
  const lastDay  = new Date(y, m + 1, 0).getDate();
  const endDay   = isLastMonth ? '20' : lastDay;
  const mm       = String(m + 1).padStart(2, '0');
  const beginStr = String(beginDay).padStart(2, '0') + '.' + mm + '.' + y;
  const endStr   = String(endDay).padStart(2, '0')   + '.' + mm + '.' + y;

  lines.push('npx -y tsx scripts/download-trades.ts UZ7011340005 ' + beginStr + ' ' + endStr);
  lines.push('npx -y tsx scripts/import-trades.ts');
  lines.push('');

  d.setMonth(m + 1);
}

require('fs').mkdirSync('./scripts/linux', { recursive: true });
require('fs').writeFileSync('./scripts/linux/fetch.sh', lines.join('\n'), 'utf8');
console.log('Done, lines:', lines.length);
Run this snippet with node from the project root to produce a fresh scripts/linux/fetch.sh. Adapt the start, end, and ISIN string as needed, then manually mirror any changes into scripts/win/fetch.bat for Windows compatibility.

Using the Pre-Built Data Dump

If you want to skip the multi-hour scraping process entirely, you can import the pre-built JSON dumps directly into MongoDB with mongoimport:
mongoimport --db backtest --collection trade-results \
  --file backtest.trade-results.json --jsonArray

mongoimport --db backtest --collection candle-items \
  --file backtest.candle-items.json --jsonArray
The backtest.candle-items.json dump contains pre-built OHLCV candles for all eleven timeframes. Importing it lets you jump straight to the Pine Script analysis layer without running build-candles at all.

Next Steps

Once trade-results is populated — whether via the bulk fetch scripts or the JSON dump — you can:

Build Candles

Aggregate raw trades into OHLCV candlestick data across all eleven timeframes.

Check Gaps

Scan for missing trading days to verify data completeness before running analysis.

Build docs developers (and LLMs) love