mirror of
https://github.com/wassname/catalyst.git
synced 2026-09-12 12:12:04 +08:00
PERF: Speedup minute to session sampling.
The minute to session sampling reading was creating two DataFrame objects, the first to hold the minute data, and then a second returned by the `DataFrame.groupby` to sample down to sessions. Instead use the arrays returned by the minute readers `load_raw_arrays` and implement sampling logic which takes advantage that the minutes being passed start with the first minute of the first session and end with the last minute of the last session. On my machine this takes the tests in `test/test_continuous_futures` from ~4.0 to about ~0.1 seconds.
This commit is contained in:
@@ -15,7 +15,7 @@ from .core import (
|
||||
)
|
||||
from ..data.data_portal import DataPortal
|
||||
from ..data.resample import (
|
||||
minute_to_session,
|
||||
minute_frame_to_session_frame,
|
||||
MinuteResampleSessionBarReader
|
||||
)
|
||||
from ..data.us_equity_pricing import (
|
||||
@@ -679,8 +679,9 @@ class WithEquityDailyBarData(WithTradingEnvironment):
|
||||
assets = cls.asset_finder.retrieve_all(cls.asset_finder.equities_sids)
|
||||
minute_data = dict(cls.make_equity_minute_bar_data())
|
||||
for asset in assets:
|
||||
yield asset.sid, minute_to_session(minute_data[asset.sid],
|
||||
cls.trading_calendars[Equity])
|
||||
yield asset.sid, minute_frame_to_session_frame(
|
||||
minute_data[asset.sid],
|
||||
cls.trading_calendars[Equity])
|
||||
|
||||
@classmethod
|
||||
def make_equity_daily_bar_data(cls):
|
||||
|
||||
Reference in New Issue
Block a user