A TypeError exception was raised with message "Cannot join tz-naive with
tz-aware DatetimeIndex". Removing old unnecessary workaround in
`holidays_at_time` function (Pandas already fixed that before 0.18)
fixes this issue.
Optimize session close lookups in MinuteResampleSessionBarReader:
- Adds `session_closes_in_range` method (along with
`session_opens_in_range`) to TradingCalendar to allow vectorized
retrieval of all values in a range of sessions.
- Improves code path for resampling a single session's worth of data (as
is the case when calling `get_value`), since we don't actually need to
look up the close minute.
When retrieving the open and close for a given session, we only care
about the scalar values, so using DataFrame.at instead of DataFrame.loc
is significantly faster.
Remove module scope invocations of `get_calendar('NYSE')`, which cuts
zipline import time in half on my machine. This make the zipline CLI
noticeably more responsive, and it reduces memory consumed at import
time from 130MB to 90MB.
Before:
$ time python -c 'import zipline'
real 0m1.262s
user 0m1.128s
sys 0m0.120s
After:
$ time python -c 'import zipline'
real 0m0.676s
user 0m0.536s
sys 0m0.132s
The new TradingCalendar method is called `minute_index_to_session_labels`.
It takes a DatetimeIndex of in-order market minutes and returns a
DatetimeIndex of the corresponding sessions.
The new method is approximately 100x faster than mapping
`minute_to_session_label` over a large DatetimeIndex.