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

Normalize Date timezone #8420

Merged

Conversation

Marinovsky
Copy link
Collaborator

Description

Some C# methods call python methods with date parameters that do not have the same timezone. Thus, when the C# dates are converted into python datetime objects, some of them have a timezone and others don't so an exception is thrown when compared (can't compare offset-naive and offset-aware datetimes). For that reason, since python datetime objects do not have a timezone by default, I modified some of the C# methods I mentioned so that they didn't have a timezone too (DateTime.Kind = Unspecified). However, there are other C# methods that have this same bug (such as OrderEvent.UtcTime) but making a change in that class would be a breaking change, so I skipped them.

Related Issue

Closes #8402

Motivation and Context

With this change, users will be able to compare dates directly in python (for some methods such as FuncDateRule())

Requires Documentation Change

N/A

How Has This Been Tested?

I modified a python regression algorithm that was handling the timezone bug manually and I also made a unit test asserting the dates returned by ScheduleManager.GetDatesDeferred() were normalized.

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>

@Martin-Molinero Martin-Molinero merged commit 5ac7d00 into QuantConnect:master Nov 25, 2024
7 checks passed
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.

Thanks!

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.

TimeZone Mis-Match Between Start and End Times
2 participants