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.

download-trades.ts is the first step in the data-ingestion pipeline. It launches a headless Chromium browser via Playwright, navigates to the UZSE trade results search, auto-detects the total number of result pages, and saves every page as an HTML file in tmp/ for the downstream import-trades.ts script to parse.

Synopsis

npx tsx scripts/download-trades.ts <symbol> <begin> <end> [mktId]

Parameters

symbol
string
required
ISIN code of the security to query, e.g. UZ7011340005. This value is passed directly as the search_key query parameter to the UZSE trade results endpoint.
begin
string
required
Start date of the range in DD.MM.YYYY format, e.g. 01.03.2026. Inclusive.
end
string
required
End date of the range in DD.MM.YYYY format, e.g. 31.03.2026. Inclusive.
mktId
string
Market sector code passed as mkt_id. Defaults to STK when omitted. Common values:
ValueDescription
STKEquities market
BONBonds market

Constants

The following retry and timeout constants are compiled into the script:
ConstantValueDescription
TIMEOUT30000msMaximum wait time per page navigation before triggering a retry
RETRIES10Maximum number of fetch attempts per page before aborting
RETRY_DELAY30000msPause between retry attempts

Behavior

The script performs the following steps in order:
  1. Clears tmp/ — deletes every existing .html file from the tmp/ directory before starting, ensuring a clean slate.
  2. Launches Chromium — opens a headless Playwright browser instance.
  3. Fetches page 1 — navigates to the first results page and saves it as tmp/trades_page_1.html. Scans the HTML for the pagination class="last next" anchor to determine totalPages.
  4. Downloads pages 2..N — iterates from page 2 to totalPages, saving each as tmp/trades_page_N.html. Each fetch is retried up to RETRIES times with RETRY_DELAY between attempts on timeout.
  5. Closes browser — disposes the Playwright browser after all pages are saved.

URL Pattern

Each page is fetched from:
https://uzse.uz/trade_results?begin={begin}&end={end}&mkt_id={mktId}&page={p}&search_key={symbol}

Output Files

Saved under tmp/ relative to the project root:
tmp/trades_page_1.html
tmp/trades_page_2.html
tmp/trades_page_N.html
The tmp/ directory is created automatically if it does not exist. All files written here are consumed and deleted by import-trades.ts after parsing.

Exit Codes

CodeMeaning
0All pages downloaded successfully
1Missing required arguments, or an unrecoverable error

Examples

# Download March 2026 trades for Hamkorbank
npx tsx scripts/download-trades.ts UZ7011340005 01.03.2026 31.03.2026

# Download a single day
npx tsx scripts/download-trades.ts UZ7011340005 17.04.2026 17.04.2026

# Download bonds market data
npx tsx scripts/download-trades.ts UZ7011340005 01.01.2026 31.01.2026 BON
For large date ranges that span many pages, the retry logic handles transient UZSE server timeouts automatically. If downloads are consistently slow, the script will pause for 30 s between attempts and try up to 10 times per page.

Build docs developers (and LLMs) love