added default positions for portfolio object.

This commit is contained in:
fawce
2012-07-19 23:31:14 -04:00
parent 03b17bbfb5
commit 5dd35a4709
2 changed files with 12 additions and 2 deletions
+8 -2
View File
@@ -64,6 +64,11 @@ class TradeSimulationClient(Component):
# self.algorithm.initialize()
self.algorithm.initialize()
# we need to provide the performance tracker with the
# sids referenced in the algorithm, so portfolio can
# initialize with all possible sids.
self.perf.set_sids(self.algorithm.get_sid_filter())
def open(self):
self.result_feed = self.connect_result()
@@ -175,11 +180,12 @@ class TradeSimulationClient(Component):
- Set the current portfolio for the algorithm as per protocol.
- Construct data based on backlog of events, send to algorithm.
"""
current_portfolio = self.perf.get_portfolio()
self.algorithm.set_portfolio(current_portfolio)
# current_portfolio = self.perf.get_portfolio()
# self.algorithm.set_portfolio(current_portfolio)
data = self.get_data()
if len(data) > 0:
data.portfolio = self.perf.get_portfolio()
# data injection pipeline for log rerouting
# any fields injected here should be added to
+4
View File
@@ -198,6 +198,10 @@ class PerformanceTracker(object):
keep_transactions = True
)
def set_sids(self, sid_list):
for sid in sid_list:
self.cumulative_performance.positions[sid] = Position(sid)
def get_portfolio(self):
return self.cumulative_performance.as_portfolio()