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.
import-trades.ts is the second step in the data pipeline. It reads every trades_page_*.html file produced by the download step, extracts trade rows from the HTML tables using regex parsing, and inserts them one by one into the trade-results MongoDB collection. Re-importing the same files is safe — each record is fingerprinted with a SHA1 hash and duplicates are silently skipped.
Usage
trades_page_*.html files in the tmp/ directory (sorted numerically by page number) and processes them in order.
Run download-trades first to populate
tmp/ with HTML pages before executing this script. If no matching files are found the script exits with an error.Requirements
MongoDB must be running and accessible. The connection URI is read from theMONGO_URI environment variable, which defaults to mongodb://localhost:27017/backtest when not set.
Parsed Fields
Each<tr> row in the HTML table is parsed into the following fields:
| Field | Type | Description |
|---|---|---|
time | Date | Trade timestamp, parsed from Russian-language date text |
symbol | string | ISIN code extracted from the security cell, e.g. UZ7011340005 |
issuer | string | Full name of the issuing company |
securityType | string | Type of security (e.g. ordinary share) |
market | string | Market segment the trade occurred in |
platform | string | Trading platform or session |
tradePrice | number | Execution price per unit |
quantity | number | Number of securities exchanged |
volume | number | Total monetary volume of the trade |
hash | string | SHA1 fingerprint used as the unique deduplication key |
Russian Date Parsing
UZSE renders trade timestamps in Russian, for example:Deduplication via SHA1
Before inserting, a SHA1 fingerprint is computed for every row from the concatenation of:urlKey is derived from the page’s query string as begin|end|search_key. The hash field carries a unique index in MongoDB. Any insert that triggers error code 11000 (duplicate key) is counted as skipped — it is not treated as a failure.
Output
Progress is printed per file, followed by a final summary:.html file from tmp/ to keep the working directory clean.
Process Flow
Discover HTML files
Reads
tmp/ and collects all files matching trades_page_*.html, sorted by page number ascending.Connect to MongoDB
Opens a Mongoose connection using
MONGO_URI and waits for the connection to be ready.Parse and insert rows
For each file, the HTML is parsed with regex to extract table rows. Each row is hashed and inserted into the
trade-results collection. Duplicate hashes are skipped with a counter increment.