feat: add REG_GB (London Stock Exchange) core region support#2156
feat: add REG_GB (London Stock Exchange) core region support#2156kaish114 wants to merge 5 commits intomicrosoft:mainfrom
Conversation
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.
CI failures are pre-existing infrastructure issues, not related to this PRAll failing checks trace back to two pre-existing issues in the CI environment — neither is caused by changes in this PR. 1.
|
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: AddREG_GB = "gb"constantqlib/config.py: AddREG_GBto_default_region_configwith LSE-appropriate defaults (trade_unit=1,limit_threshold=None,deal_price="close")qlib/utils/time.py: AddGB_TIME(08:00–16:30, no midday break) and wireREG_GBintoget_min_cal,is_single_value, andtime_to_day_indextests/misc/test_utils.py: AddGBTimeUtilstest class coveringget_min_cal,is_single_value, andtime_to_day_indexforREG_GBLSE trading hours: 08:00–16:30 Europe/London, continuous session (no lunch break), 510 one-minute bars per day.
Timezone & DST note
GB_TIMEuses timezone-naive local hours (08:00–16:30), consistent with how all other regions (includingREG_USwhich 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_minutepasses withREG_GBin the regions listtests/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)tests/misc/test_utils.pypassblack -l 120 --target-version py311— no changes needed