mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-02 06:28:38 +08:00
MAINT: Factor out column conversion in HistoryContainer.
We can't be sure that security identifiers can be converted to int. In fact, most of the times they are strings. This adds an identity function that can be overwritten if such a conversion is necessary (as on Quantopian).
This commit is contained in:
@@ -246,6 +246,13 @@ class HistoryContainer(object):
|
||||
)
|
||||
return rp
|
||||
|
||||
def convert_columns(self, values):
|
||||
"""
|
||||
If columns have a specific type you want to enforce, overwrite this
|
||||
method and return the transformed values.
|
||||
"""
|
||||
return values
|
||||
|
||||
def create_return_frames(self, algo_dt):
|
||||
"""
|
||||
Populates the return frame cache.
|
||||
@@ -257,7 +264,8 @@ class HistoryContainer(object):
|
||||
index = pd.to_datetime(index_at_dt(history_spec, algo_dt))
|
||||
frame = pd.DataFrame(
|
||||
index=index,
|
||||
columns=map(int, self.buffer_panel.minor_axis.values),
|
||||
columns=self.convert_columns(
|
||||
self.buffer_panel.minor_axis.values),
|
||||
dtype=np.float64)
|
||||
self.return_frames[spec_key] = frame
|
||||
|
||||
|
||||
Reference in New Issue
Block a user