mirror of
https://github.com/wassname/catalyst.git
synced 2026-08-05 12:50:21 +08:00
Locks down the ability to easily override the algo's portfolio.
Starting down the path of making the portfolio completely read-only with respect to the handle_data in algo. The portfolio should only be changed during the course of running the algorithm by the simulator. This doesn't do a 100% protection, i.e. an algo could use _portfolio, or the set_attr property, but hoping this helps guides algo writing to treat the portfolio as read-only.
This commit is contained in:
@@ -66,7 +66,7 @@ class TradingAlgorithm(object):
|
||||
self.done = False
|
||||
self.order = None
|
||||
self.frame_count = 0
|
||||
self.portfolio = None
|
||||
self._portfolio = None
|
||||
self.datetime = None
|
||||
|
||||
self.registered_transforms = {}
|
||||
@@ -217,8 +217,12 @@ class TradingAlgorithm(object):
|
||||
'args': args,
|
||||
'kwargs': kwargs}
|
||||
|
||||
@property
|
||||
def portfolio(self):
|
||||
return self._portfolio
|
||||
|
||||
def set_portfolio(self, portfolio):
|
||||
self.portfolio = portfolio
|
||||
self._portfolio = portfolio
|
||||
|
||||
def set_order(self, order_callable):
|
||||
self.order = order_callable
|
||||
|
||||
Reference in New Issue
Block a user