Fix bug when consolidating hourly bars into daily ones #8442
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.
Description
When hourly bars were consolidated into daily ones, the first hourly bar was skipped as well as the last two. This happened because of the format of the hourly bars in the DB. While according to the exchange hours, US equities open at 09:30 and close at 16, but for every equity, its hour data in the DB starts at 09 and finish at 16:00. Thus, not all the hourly bars were taken into account when consolidating a daily bar. This PR aims to fix that bug by covering this specific case in
MarketHourAwareConsolidator.Update()
andPeriodCountConsolidatorBase.GetRoundedBarTime()
.Related Issue
Closes #8415, #8416
Motivation and Context
With this change, daily consolidated bars from hourly bars will match daily bars from DB
Requires Documentation Change
N/A
How Has This Been Tested?
I created a regression test to assert the bug was solved. In the regression test, I create two RelativeStrengthIndex indicators but register just one, using the symbol in hour resolution but a daily consolidator. After one month, I request data for the symbol in daily resolution and manually update the second indicator, so that I can compare the values of both indicator and assert they are the same. It's worth saying I used a RelativeStrengthIndex indicator since that indicator depends on its previous values, thus if the first value is different, so will the next values
Types of changes
Checklist:
bug-<issue#>-<description>
orfeature-<issue#>-<description>