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

Implements Calendar (Weekly/Monthly) Consolidator #3022

Conversation

AlexCatarino
Copy link
Member

Implements consolidators that group bars by a calendar unit (week or month).

Related Issue

Closes #3007 #3008

Motivation and Context

Weekly and monthly consolidator can be used to create a bar with one-week and one-month duration respectively.

Requires Documentation Change

Include examples of this consolidator.

How Has This Been Tested?

Unit tests

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • 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 pass.
  • My branch follows the naming convention bug-<issue#>-<description> or feature-<issue#>-<description>

@AlexCatarino AlexCatarino force-pushed the feature-3007-calendar-consolidators branch 2 times, most recently from da3d247 to c089df8 Compare March 22, 2019 21:57
Copy link
Member

@jaredbroad jaredbroad left a comment

Choose a reason for hiding this comment

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

Very beautiful and complete PR; just would like to discuss/review the API to minimize confusion and duplication

@@ -88,6 +88,14 @@ def Initialize(self):
self.Consolidate("SPY", Resolution.Hour, self.HourBarHandler)
self.Consolidate("EURUSD", Resolution.Daily, self.DailyEurUsdBarHandler)

# API convenience method for easily receiving weekly-consolidated data
self.WeeklyConsolidate("SPY", self.CalendarTradeBarHandler)
Copy link
Member

Choose a reason for hiding this comment

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

Let's see if we can find a way to call this without adding these period methods to the API; maybe something like:
self.Consolidate("SPY", Calendar.Monthly, self.HourBarHandler)

Or self.Consolidate("SPY", Func<>, self.HourBarHandler) which returns the endtime of the bar.

@AlexCatarino AlexCatarino force-pushed the feature-3007-calendar-consolidators branch 2 times, most recently from 7af1dbc to 2777f92 Compare April 8, 2019 21:08
Implements consolidators that group bars by a calendar unit (week or month).
Replaces Enum `CalendarType` for static class with the same name. This class defines two properties (`Weekly` and `Monthly`) that can be used to define the previous calendar date (Monday or 1st of current month) which will correspont to the `Time` of a `IBaseData` object.

Refactor `PeriodCountConsolidatorBase` to define use `GetRoundedBarTime` based on a period specification that depends on the constructor overload: `integer`, `TimeSpan` or `Func<DateTime, CalendarInfo>`. The last one can be set with the `CalendarType` properties.
@AlexCatarino AlexCatarino force-pushed the feature-3007-calendar-consolidators branch from 2777f92 to 0202df3 Compare April 8, 2019 21:10
@jaredbroad jaredbroad merged commit 4f47df2 into QuantConnect:master Apr 10, 2019
@AlexCatarino AlexCatarino deleted the feature-3007-calendar-consolidators branch April 10, 2019 21:40
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.

Implement Weekly Consolidator
2 participants