-
Notifications
You must be signed in to change notification settings - Fork 373
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
sessions_window with high negative count cycles back indices #124
Comments
Made sure that `end_idx` in `sessions_window` method is always positive so that it does not loop-back when indexing on all_sessions when the count/lookback period is greater than the length of total historical dates. More details in quantopian#124.
Hey @pavitrakumar78 - thank you for this report/PR! I very much agree that count should not cycle back when count is large. However, I think my personal preference here is to Thoughts @ssanderson @llllllllll ? |
@gerrymanoim But I was also drawing from how arrays in python work in general. For example, in python doing |
Hey @pavitrakumar78 - apologies for the slow reply. I agree with you - this should behave as list slicing does. |
Hi,
I've been experimenting with
sessions_window
and I found that when thecount
parameter is negative and greater than the total number of days in the trading calendar, the result cycles back and returns the dates between the end date and till the exact overflow value.Example:
Upon checking the code for this in trading_calendar.py,
start_idx
is 7345 for the calendar I've chosen in the above example andend_idx
becomes 7345 + (-8500) = -1155 and thus the output will beall_sessions[-1155: 7345 + 1]
which is not what I expected. The total length ofall_sessions
is 7839 - so, converting the negative indices to normal indices, we getall_sessions[7839-1155: 7345 + 1]
which isall_sessions[6684: 7345 + 1]
which explains why I got 662 dates.What I expect is
all_sessions[0: 7345 + 1]
which can be obtained by addingend_idx = max(0, end_idx)
right before the indexing onall_sessions
(created a pull request for the same - #125). I'm not yet sure if this affects any other functionality, but tl;dr version is, when we query dates where the lookback/negative count is greater than the length of historical dates, it should just return all the available dates till the end date instead of looping back on the indices.The text was updated successfully, but these errors were encountered: