Skip to content

feat: add REG_GB (London Stock Exchange) core region support#2156

Open
kaish114 wants to merge 5 commits intomicrosoft:mainfrom
kaish114:feat/add-reg-gb-core-region
Open

feat: add REG_GB (London Stock Exchange) core region support#2156
kaish114 wants to merge 5 commits intomicrosoft:mainfrom
kaish114:feat/add-reg-gb-core-region

Conversation

@kaish114
Copy link

@kaish114 kaish114 commented Mar 14, 2026

Summary

This PR adds core framework support for REG_GB (London Stock Exchange) as a new trading region in Qlib, complementing the Yahoo Finance data collector support added in #2155.

Changes:

  • qlib/constant.py: Add REG_GB = "gb" constant
  • qlib/config.py: Add REG_GB to _default_region_config with LSE-appropriate defaults (trade_unit=1, limit_threshold=None, deal_price="close")
  • qlib/utils/time.py: Add GB_TIME (08:00–16:30, no midday break) and wire REG_GB into get_min_cal, is_single_value, and time_to_day_index
  • tests/misc/test_utils.py: Add GBTimeUtils test class covering get_min_cal, is_single_value, and time_to_day_index for REG_GB

LSE trading hours: 08:00–16:30 Europe/London, continuous session (no lunch break), 510 one-minute bars per day.

Timezone & DST note

GB_TIME uses timezone-naive local hours (08:00–16:30), consistent with how all other regions (including REG_US which also observes DST) are handled in Qlib. The LSE always opens and closes at the same local time regardless of GMT/BST, so the 510-bar calendar is stable year-round. DST resolution for minute-level data is handled at collection time via _timezone = "Europe/London" in the Yahoo Finance collector (PR #2155). This is the same design assumption as the existing US region implementation.

Test plan

  • tests/misc/test_utils.py::TimeUtils::test_cal_sam_minute passes with REG_GB in the regions list
  • tests/misc/test_utils.py::GBTimeUtils — 10 new tests: calendar count (510 bars), open/close times, is_single_value (last bar, mid-session, sub-freq window), time_to_day_index (open, mid, last bar, out-of-range ValueError)
  • All 12 tests in tests/misc/test_utils.py pass
  • black -l 120 --target-version py311 — no changes needed

Add GB_TIME constant (08:00-16:30 Europe/London, no midday break) and
wire REG_GB into get_min_cal, is_single_value, and time_to_day_index.
Covers: 510-bar calendar count, open/close bar times, last-bar
single-value detection, mid-session multi-value, index arithmetic,
and out-of-range ValueError for GB (London Stock Exchange) region.
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