Skip to content

Read and update the market-hours.json market hours database - #795

Merged
Martin-Molinero merged 1 commit into
masterfrom
equity-23x5-session
Dec 4, 2026
Merged

Martin-Molinero merged 1 commit into
masterfrom
equity-23x5-session

Conversation

@Martin-Molinero

@Martin-Molinero Martin-Molinero commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

LEAN moves its market hours database to a new file, Data/market-hours/market-hours.json (QuantConnect/Lean#10287). market-hours-database.json, the file it replaces, stays in LEAN for a short time and is then deleted.

What changes

  • Daily update. The CLI downloads market-hours.json and market-hours-database.json, each on its own. A file that can't be downloaded, or that the CLI can't read, keeps its local copy and doesn't stop the other one from updating. A file that doesn't exist in LEAN is not an error: LEAN has only one of the two when it is ahead of or behind this version of the CLI.
  • Reading. market-hours.json is read first, in the version of its format the CLI supports, and market-hours-database.json when it doesn't exist. When the file doesn't hold that version, the error says to update the CLI.
  • Entries. In the new file they are grouped by security type, and each one is for a market and one or more tickers, where * is every ticker of the market without an entry of its own. The CLI keeps looking them up as <security type>-<market>-<ticker>, so the code that uses the database doesn't change.
  • Same as LEAN, the names of the entries and of their properties are not case sensitive, and the first entry is used when a ticker is defined more than once.

Order of merging

This works before and after the LEAN pull request is merged, and after market-hours-database.json is deleted from LEAN.

How has this been tested

New tests cover:

  • Reading market-hours.json, and market-hours-database.json when it doesn't exist.
  • A file that doesn't hold the version the CLI reads, and an entry without its market or tickers.
  • An update where only one of the files exists, where a download fails and where a downloaded file is not valid.

The whole test suite ran locally on this commit: 2,963 passed, 75 skipped.

Related pull requests

🤖 Generated with Claude Code

- The daily update downloads market-hours.json and
  market-hours-database.json, each on its own: a file that can't be
  downloaded or read keeps its local copy and doesn't stop the other
- market-hours.json is read first, in the version of its format the CLI
  supports, and market-hours-database.json when it doesn't exist
- Its entries are grouped by security type and each one is for a market
  and one or more tickers, where * is every ticker of the market
  without an entry of its own

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@Martin-Molinero
Martin-Molinero merged commit c357b71 into master Dec 4, 2026
64 checks passed
@Martin-Molinero
Martin-Molinero deleted the equity-23x5-session branch December 4, 2026 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant