feat: add REG_GB (London Stock Exchange) core region support#2156
Open
kaish114 wants to merge 5 commits intomicrosoft:mainfrom
Open
feat: add REG_GB (London Stock Exchange) core region support#2156kaish114 wants to merge 5 commits intomicrosoft:mainfrom
kaish114 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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