本文整理汇总了Python中zipline.finance.blotter.Blotter.batch_order方法的典型用法代码示例。如果您正苦于以下问题:Python Blotter.batch_order方法的具体用法?Python Blotter.batch_order怎么用?Python Blotter.batch_order使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zipline.finance.blotter.Blotter
的用法示例。
在下文中一共展示了Blotter.batch_order方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_batch_order_matches_multiple_orders
# 需要导入模块: from zipline.finance.blotter import Blotter [as 别名]
# 或者: from zipline.finance.blotter.Blotter import batch_order [as 别名]
def test_batch_order_matches_multiple_orders(self):
"""
Ensure the effect of order_batch is the same as multiple calls to
order.
"""
blotter1 = Blotter(self.sim_params.data_frequency,
self.asset_finder)
blotter2 = Blotter(self.sim_params.data_frequency,
self.asset_finder)
for i in range(1, 4):
order_arg_lists = [
(self.asset_24, i * 100, MarketOrder()),
(self.asset_25, i * 100, LimitOrder(i * 100 + 1)),
]
order_batch_ids = blotter1.batch_order(order_arg_lists)
order_ids = []
for order_args in order_arg_lists:
order_ids.append(blotter2.order(*order_args))
self.assertEqual(len(order_batch_ids), len(order_ids))
self.assertEqual(len(blotter1.open_orders),
len(blotter2.open_orders))
for (asset, _, _), order_batch_id, order_id in zip(
order_arg_lists, order_batch_ids, order_ids
):
self.assertEqual(len(blotter1.open_orders[asset]),
len(blotter2.open_orders[asset]))
self.assertEqual(order_batch_id,
blotter1.open_orders[asset][i-1].id)
self.assertEqual(order_id,
blotter2.open_orders[asset][i-1].id)