MAINT: Allow algo.run() to write to db

This commit is contained in:
Stewart Douglas
2015-08-14 14:39:41 -04:00
committed by jfkirk
parent 1ef2274d11
commit 7be2cf8652
2 changed files with 35 additions and 11 deletions
+5 -1
View File
@@ -31,6 +31,7 @@ from six import (
)
from operator import attrgetter
from zipline.errors import (
AddTermPostInit,
OrderDuringInitialize,
@@ -192,7 +193,6 @@ class TradingAlgorithm(object):
# set the capital base
self.capital_base = kwargs.pop('capital_base', DEFAULT_CAPITAL_BASE)
self.sim_params = kwargs.pop('sim_params', None)
if self.sim_params is None:
self.sim_params = create_simulation_parameters(
@@ -500,6 +500,8 @@ class TradingAlgorithm(object):
# if DataFrame provided, map columns to sids and wrap
# in DataFrameSource
copy_frame = source.copy()
self.trading_environment.write_data(
equities_identifiers=source.columns)
copy_frame.columns = \
self.asset_finder.map_identifier_index_to_sids(
source.columns, source.index[0]
@@ -510,6 +512,8 @@ class TradingAlgorithm(object):
# If Panel provided, map items to sids and wrap
# in DataPanelSource
copy_panel = source.copy()
self.trading_environment.write_data(
equities_identifiers=source.items)
copy_panel.items = self.asset_finder.map_identifier_index_to_sids(
source.items, source.major_axis[0]
)