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

GetTradingDays Throws Error When Looping Through Results #5543

Closed
4 tasks done
DerekMelchin opened this issue May 12, 2021 · 0 comments · Fixed by #5588
Closed
4 tasks done

GetTradingDays Throws Error When Looping Through Results #5543

DerekMelchin opened this issue May 12, 2021 · 0 comments · Fixed by #5588
Assignees

Comments

@DerekMelchin
Copy link
Collaborator

Expected Behavior

We can loop through the results after calling GetTradingDays.

trading_days_obj = self.TradingCalendar.GetTradingDays(datetime(2020, 4, 28), datetime(2020, 4, 10))
days = [x for x in trading_days_obj]

Actual Behavior

Looping through trading_days_obj throws

Runtime Error: ArgumentOutOfRangeException : Specified argument was out of the range of valid values. (Parameter 'count')
at System.Linq.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument)
at System.Linq.Enumerable.Range(Int32 start, Int32 count)
at QuantConnect.TradingCalendar.PopulateTradingDays(DateTime start, DateTime end)+MoveNext() in /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/Lean/Common/TradingCalendar.cs:line 83

at Python.Runtime.Iterator.tp_iternext(IntPtr ob)
at
days = [x for x at trading_days_obj]
File "main.py" in main.py:line 12

ArgumentOutOfRangeException : Specified argument was out of the range of valid values. (Parameter 'count')
at System.Linq.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument)
at System.Linq.Enumerable.Range(Int32 start, Int32 count)
at QuantConnect.TradingCalendar.PopulateTradingDays(DateTime start, DateTime end)+MoveNext() in /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/Lean/Common/TradingCalendar.cs:line 83

at Python.Runtime.Iterator.tp_iternext(IntPtr ob) (Open Stacktrace)

Potential Solution

N/A

Reproducing the Problem

Run this algorithm

class TestingAlgorithm(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2020,4,29)  
        self.SetEndDate(2020,5,6) 
        self.SetCash(100000) 
        self.UniverseSettings.Resolution = Resolution.Daily
        self.aapl = self.AddEquity("AAPL")
        
    def OnData(self, data):
        trading_days_obj = self.TradingCalendar.GetTradingDays(datetime(2020, 4, 28), datetime(2020, 4, 10))
        days = [x for x in trading_days_obj]

System Information

QC Cloud

Checklist

  • I have completely filled out this template
  • I have confirmed that this issue exists on the current master branch
  • I have confirmed that this is not a duplicate issue by searching issues
  • I have provided detailed steps to reproduce the issue
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 a pull request may close this issue.

2 participants