Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge early closes and late opens properly in MHDB #7712

Merged

Conversation

jhonabreul
Copy link
Collaborator

Description

When late opens or early close times are different in a more specific entry, they following error is shown without exiting the algorithm:

image

A more specific entry (like Indices-usa-VIX) might contain some of the same early close/late open dates as the common entry (Indices-usa-[*]) but with different times. These changes make sure this is handle and the more specific ones take precedence.

For instance, in the following market hours database JSON string:

{
  "entries": {
    "Equity-usa-[*]": {
      "dataTimeZone": "America/New_York",
      "exchangeTimeZone": "America/New_York",
      "sunday": [],
      "monday": [...],
      "tuesday": [...],
      "wednesday": [...],
      "thursday": [...],
      "friday": [...],
      "saturday": [],
      "holidays": [],
      "earlyCloses": {
        "11/25/2015": "13:00:00",
        "11/25/2016": "13:00:00",
        "11/25/2017": "13:00:00",
        "11/25/2018": "13:00:00"
      },
      "lateOpens": {
        "11/25/2015": "11:00:00",
        "11/25/2016": "11:00:00",
        "11/25/2017": "11:00:00",
        "11/25/2018": "11:00:00"
      }
    },
    "Equity-usa-GOOG": {
      "dataTimeZone": "America/New_York",
      "exchangeTimeZone": "America/New_York",
      "sunday": [],
      "monday": [...],
      "tuesday": [...],
      "wednesday": [...],
      "thursday": [...],
      "friday": [...],
      "saturday": [],
      "holidays": [],
      "earlyCloses": {
        "11/25/2017": "13:30:00",
        "11/25/2018": "13:30:00",
        "11/25/2019": "13:30:00"
      },
      "lateOpens": {
        "11/25/2017": "11:30:00",
        "11/25/2018": "11:30:00",
        "11/25/2019": "11:30:00"
      }
    }
  }
}

The resulting MarketHoursDatabase instance would have the following early closes and late opens, where the times for the dates 11/25/2017 and 11/25/2018 would take the times as they appear in the specific entry Equity-usa-GOOG:

      "earlyCloses": {
        "11/25/2015": "13:00:00",
        "11/25/2016": "13:00:00",
        "11/25/2017": "13:30:00",
        "11/25/2018": "13:30:00",
        "11/25/2019": "13:30:00"
      },
      "lateOpens": {
        "11/25/2015": "11:00:00",
        "11/25/2016": "11:00:00",
        "11/25/2017": "11:30:00",
        "11/25/2018": "11:30:00",
        "11/25/2019": "11:30:00"
      }

Related Issue

N/A

Motivation and Context

N/A

Requires Documentation Change

N/A

How Has This Been Tested?

Unit tests

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Refactor (non-breaking change which improves implementation)
  • Performance (non-breaking change which improves performance. Please add associated performance test and results)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Non-functional change (xml comments/documentation/etc)

Checklist:

  • My code follows the code style of this project.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • My branch follows the naming convention bug-<issue#>-<description> or feature-<issue#>-<description>

A more specific entry might contain some of the same early close/late open dates as the common entry but with different times. This makes sure this is handle and the more specific ones take precedence.
Copy link
Member

@Martin-Molinero Martin-Molinero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! Thank you 👍

@jhonabreul jhonabreul merged commit 1c93df8 into QuantConnect:master Jan 22, 2024
4 of 5 checks passed
@jhonabreul jhonabreul deleted the bug-mhdb-duplicate-early-closes branch January 22, 2024 18:45
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.

2 participants