Skip to content

Commit

Permalink
Merge pull request #1609 from quantopian/use-custom-business-day-for-…
Browse files Browse the repository at this point in the history
…session-loop-logic

MAINT: Use session index freq for loop logic.
  • Loading branch information
ehebert committed Dec 5, 2016
2 parents 4765136 + 31d31bf commit c166bb0
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions zipline/assets/roll_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,25 +89,25 @@ def get_rolls(self, root_symbol, start, end, offset):
tc = self.trading_calendar
sessions = tc.sessions_in_range(tc.minute_to_session_label(start),
tc.minute_to_session_label(end))
freq = sessions.freq
if first == front:
curr = first_contract << 1
else:
curr = first_contract << 2
sess = sessions[-1]
while sess > start and curr is not None:
session_loc = sessions.searchsorted(sess)
session = sessions[-1]

while session > start and curr is not None:
front = curr.contract.sid
back = curr.next.contract.sid
while session_loc > 0:
session = sessions[session_loc]
prev = sessions[session_loc - 1]
while session > start:
prev = session - freq
if back != self._active_contract(oc, front, back, prev):
rolls.insert(0, ((curr >> offset).contract.sid, session))
break
session_loc -= 1
session = prev
curr = curr.prev
if curr is not None:
sess = curr.contract.auto_close_date
session = curr.contract.auto_close_date
return rolls


Expand Down

0 comments on commit c166bb0

Please sign in to comment.