IndexOptionSymbol converts holiday-separated last-trading and expiration dates using calendar days

Open
#10,159 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
58/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
csharp
Domain
backend, databases

Research direction

Start with IndexOptionSymbol.GetLastTradingDate and GetExpiryDate, then inspect how exchange calendars are represented and used by the shared helper. Check the InteractiveBrokersSymbolMapper.GetLeanSymbol IndexOption case and InteractiveBrokersBrokerage.CreateContract; add coverage for the December 2018 holiday in both conversion directions and mapper behavior. Done means those conversions return December 24 and December 26 while ordinary-session and PM-settled results remain correct.

Written by the indexing model from the issue text.

Description

priority:p2
Observed behavior

IndexOptionSymbol.GetLastTradingDate and GetExpiryDate use a fixed calendar-day offset for AM-settled index options. When a holiday separates the last trading session from expiration, both conversions can produce the holiday instead of the correct date.

A concrete case is VIXW expiration on 2018-12-26. Its preceding business day was 2018-12-24, since December 25 was closed. The helpers return December 25 in both directions:

Console.WriteLine(IndexOptionSymbol.GetLastTradingDate(
    "VIXW", new DateTime(2018, 12, 26)).ToString("yyyy-MM-dd"));
// Actual: 2018-12-25; expected: 2018-12-24

Console.WriteLine(IndexOptionSymbol.GetExpiryDate(
    "VIXW", new DateTime(2018, 12, 24)).ToString("yyyy-MM-dd"));
// Actual: 2018-12-25; expected: 2018-12-26

The fixed +1/-1 behavior is present on master (dbacbd727).

References
Affected callers and required result

The public Interactive Brokers integration consumes both conversions:

  • InteractiveBrokersSymbolMapper.GetLeanSymbol, in the IndexOption case, calls GetExpiryDate to construct Lean's contract symbol.
  • InteractiveBrokersBrokerage.CreateContract calls GetLastTradingDate to populate LastTradeDateOrContractMonth.

Thus this is not only a display-date discrepancy: those callers can construct a different expiration or send a non-trading date when given this holiday-separated contract.

The shared conversions should produce December 24 and December 26 respectively for the reproduction, while preserving existing ordinary-session and PM-settled results. Add holiday-separated cases in both directions and mapper coverage. As a suggestion, resolve these dates against the relevant exchange calendar in the shared Lean helper, so brokerage callers can reuse the correction instead of adding their own holiday rules.

Dominant language
C#
Stars
22.6k
Forks
5.4k
Avg merge
11h 39m
Merged PRs (30d)
104

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from QuantConnect/Lean

All issues in QuantConnect/Lean

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.