本文整理汇总了Python中zipline.finance.blotter.Blotter.order_value方法的典型用法代码示例。如果您正苦于以下问题:Python Blotter.order_value方法的具体用法?Python Blotter.order_value怎么用?Python Blotter.order_value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zipline.finance.blotter.Blotter
的用法示例。
在下文中一共展示了Blotter.order_value方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TradingAlgorithm
# 需要导入模块: from zipline.finance.blotter import Blotter [as 别名]
# 或者: from zipline.finance.blotter.Blotter import order_value [as 别名]
#.........这里部分代码省略.........
for perf in daily_perfs]
daily_stats = pd.DataFrame(daily_perfs, index=daily_dts)
return daily_stats
def add_transform(self, transform_class, tag, *args, **kwargs):
"""Add a single-sid, sequential transform to the model.
:Arguments:
transform_class : class
Which transform to use. E.g. mavg.
tag : str
How to name the transform. Can later be access via:
data[sid].tag()
Extra args and kwargs will be forwarded to the transform
instantiation.
"""
self.registered_transforms[tag] = {'class': transform_class,
'args': args,
'kwargs': kwargs}
def record(self, **kwargs):
"""
Track and record local variable (i.e. attributes) each day.
"""
for name, value in kwargs.items():
self._recorded_vars[name] = value
def order(self, sid, amount, limit_price=None, stop_price=None):
return self.blotter.order(sid, amount, limit_price, stop_price)
def order_value(self, sid, value, limit_price=None, stop_price=None):
last_price = self.trading_client.current_data[sid].price
return self.blotter.order_value(sid, value, last_price,
limit_price=limit_price,
stop_price=stop_price)
@property
def recorded_vars(self):
return copy(self._recorded_vars)
@property
def portfolio(self):
return self._portfolio
def set_portfolio(self, portfolio):
self._portfolio = portfolio
def set_logger(self, logger):
self.logger = logger
def set_datetime(self, dt):
assert isinstance(dt, datetime), \
"Attempt to set algorithm's current time with non-datetime"
assert dt.tzinfo == pytz.utc, \
"Algorithm expects a utc datetime"
self.datetime = dt
def get_datetime(self):
"""
Returns a copy of the datetime.
"""
date_copy = copy(self.datetime)
assert date_copy.tzinfo == pytz.utc, \