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.
scripts/check-gaps.ts scans the raw trade-results collection in MongoDB and reports every calendar date between the first and last recorded trade that has no trading activity. Running it after importing new data and before building candles lets you confirm that your dataset is complete and that any gaps you find are genuine exchange closures rather than missing downloads.
Usage
No arguments are required. Run the script withtsx from the project root:
MONGO_URI environment variable (default: mongodb://localhost:27017/backtest), performs its analysis, prints the results to stdout, and then disconnects cleanly.
What It Outputs
The script prints two lines of summary followed by a labeled list of every missing date:- Trading days in DB — the count of distinct calendar dates on which at least one trade record exists
- Missing days — every date in the continuous range from the first to the last trading day that has no records, annotated with its Russian day-of-week abbreviation
Day-of-Week Labels
The script uses Russian language day-of-week abbreviations, matching the locale of the UZSE data source:| Label | Day |
|---|---|
Вс | Sunday |
Пн | Monday |
Вт | Tuesday |
Ср | Wednesday |
Чт | Thursday |
Пт | Friday |
Сб | Saturday |
A missing day labeled
Вс (Sunday) or Сб (Saturday) is always expected — UZSE does not trade on weekends. Missing days on weekdays warrant closer investigation.How It Works
The script follows a straightforward three-step process:Load all trade timestamps
TradeModel.find({}, { time: 1 }) retrieves every document from the trade-results collection, projecting only the time field to keep memory usage low.Extract unique trading dates
Each
time value is converted to a YYYY-MM-DD key using a zero-padded formatter, and the results are deduplicated into a Set. This gives the exact set of calendar dates on which trading occurred.Why Gaps Occur
Not all gaps indicate missing data. Common reasons include:- Weekends — UZSE is closed every Saturday and Sunday; these will always appear as missing days
- Public holidays — Uzbek national holidays (Nowruz, Independence Day, etc.) result in exchange closures
- Exchange-ordered trading halts — The most notable example is the August 2023 Hamkorbank halt, during which trading was suspended for approximately ten days following the registration of a new share issuance that tripled the bank’s authorized capital. This type of gap reflects a deliberate corporate or regulatory event, not missing data
Gaps in trade-results vs. candle-items
Finding gaps in thetrade-results collection does not mean your candle data will have gaps. The build-candles.ts script handles missing days automatically:
- For any day with no trade records, it synthesizes a candle with
open = high = low = close = last_closeandvolume = 0 - This ensures the
candle-itemscollection has a continuous, unbroken time series suitable for indicator calculations
check-gaps.ts is therefore a data validation tool, not a repair tool. Use it to understand your dataset and to provide context when interpreting indicator signals near gap periods — not to fix the candle output.
When to Run
Runcheck-gaps.ts in the following situations:
- After importing new trade data — confirm that the newly added date range is complete and that no download pages were skipped
- Before building candles — understand which gaps will be synthesized so you can contextualize the resulting candles correctly
- When investigating unusual indicator signals — a spike or flat region in a Pine Script indicator near a known gap date is likely an artifact of the gap-fill candle rather than a genuine market signal
Applying Pine Script Indicators
Learn how gap-filled candles affect indicator calculations and how to interpret signals around non-trading periods.