Repository navigation
Add the Hang Seng Index's afternoon-only severe weather sessions - #10253
Conversation
On days HKEX cancelled the morning session for a typhoon signal or a black rainstorm warning and traded in the afternoon, the HKFE index calendar now opens at the afternoon session's actual start, from HKEX's notices for each date. Closes #10242 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Approved. This is a data-only fix for the ten dates that #10242 asks about, and nothing else on the HKFE calendars changes.
What I checked:
- Times: each of the ten afternoon opens matches the resumption time in its linked HKEX notice.
- Minute data: I scanned every Hang Seng Index minute file from December 2006 onward. The only weekdays whose first bar is after 12:00 are these ten, each at exactly the time in the table, plus 2008-02-11, which the PR leaves out on purpose.
- How the calendar resolves:
Index-hkfe-HSItakes its late opens fromIndex-hkfe-[*]. The only other place calendars inherit from is an option's underlying, and no HKFE option entries exist, so no other calendar picks these dates up.SecurityExchangeHoursdrops the morning segment and starts the afternoon at the late-open time, including when that time equals the regular 13:00 start. None of the dates is a holiday or an early close. - Tests: without these entries, the new tests fail at
Segments.Single(). CI is green.
I set risk:low. It's an 11-line data change that's easy to revert. It replaces sessions that never traded with HKEX's published hours, and leaves every other date as it was. It's backed by per-date tests, green CI and an end-to-end run, and the data was checked against HKEX's notices.
The futures calendar has the same gap, which #10251 already tracks, so it doesn't hold this change.
There was a problem hiding this comment.
Approved. I compared minute-resolution Hang Seng Index backtests with and without the fix for all four reopening times (13:00, 13:30, 14:00, and 14:30 HKT). On each date, AfterMarketOpen and the first real bar matched the published open, and all 150 spurious morning fill-forward bars disappeared. The surrounding trading days kept the same scheduled opens and morning bar counts. Focused tests: 278 passed, 1 skipped; all 10 new cases rejected the base calendar.
One non-blocking test suggestion below. Small description correction: HKEX confirmed that July 24, 2003 was scheduled for 10:30 but actually opened at 10:32. It remains outside this afternoon-only fix.
…er test Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Approved. 9f05d98 only changes the test: each case now names its own ordinary trading day instead of asking the calendar under test for one. I checked all ten control days against the Hang Seng Index minute data. Each one is a full session, both morning and afternoon, and it's the last trading day before its event. For 2013-09-23 that's 2013-09-19, because 2013-09-20 has no data. CI is green on this commit, and the calendar data is unchanged since my earlier approval.
There was a problem hiding this comment.
Approved. The regression now uses known trading days rather than asking the calendar under test to select them. I verified morning and afternoon HSI minute data on all ten control dates, including September 19, 2013 in place of the September 20 holiday. The focused market-hours tests passed: 278 passed, 1 skipped.
Closes #10242
Description
On ten weekdays HKEX cancelled the morning session because of Typhoon Signal No. 8 or a Black Rainstorm Warning, then traded in the afternoon. The HKFE index calendar (
Index-hkfe-[*], whichIndex-hkfe-HSIinherits) now has a late open on each of them, at the time HKEX's own notice gives for the afternoon start. Lean's existing late-open handling drops the morning session and starts the afternoon segment at that time. No other date or entry changes.How the list was built:
Related gaps on the same calendars, found while doing this and left out of this change:
Future-hkfe-[*]) have the same gap as this issue. The derivatives market's resumption times differ, so it needs its own per-date sources.How Has This Been Tested?
New
MarketHoursDatabaseTests.HangSengIndexTradesOnlyInTheAfternoonOnSevereWeatherDays, one case per date. Each case resolves the HSI exchange hours from the data folder and checks that:All 10 cases pass. Against the base branch's
market-hours-database.json, all 10 fail.MarketHoursDatabaseTests,SecurityExchangeHoursTestsandMarketHoursDatabaseJsonConverterTests: 278 passed, 1 skipped.Full suite as CI runs it (
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter "TestCategory!=TravisExclude&TestCategory!=ResearchRegressionTests"): 40047 passed, 0 failed, 112 skipped.Tested end to end: a minute-resolution HSI backtest over 2009-09-14 to 2009-09-16 and over 2023-10-06 to 2023-10-10.
AfterMarketOpenscheduled event both come at the real afternoon open (14:30 and 14:00), and the exchange is closed at 10:15. The surrounding days are unchanged.