本文整理汇总了Python中zipline.finance.blotter.Blotter.cancel_all_orders_for_asset方法的典型用法代码示例。如果您正苦于以下问题:Python Blotter.cancel_all_orders_for_asset方法的具体用法?Python Blotter.cancel_all_orders_for_asset怎么用?Python Blotter.cancel_all_orders_for_asset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zipline.finance.blotter.Blotter
的用法示例。
在下文中一共展示了Blotter.cancel_all_orders_for_asset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_cancel
# 需要导入模块: from zipline.finance.blotter import Blotter [as 别名]
# 或者: from zipline.finance.blotter.Blotter import cancel_all_orders_for_asset [as 别名]
def test_cancel(self):
blotter = Blotter('daily', self.asset_finder)
oid_1 = blotter.order(self.asset_24, 100, MarketOrder())
oid_2 = blotter.order(self.asset_24, 200, MarketOrder())
oid_3 = blotter.order(self.asset_24, 300, MarketOrder())
# Create an order for another asset to verify that we don't remove it
# when we do cancel_all on 24.
blotter.order(self.asset_25, 150, MarketOrder())
self.assertEqual(len(blotter.open_orders), 2)
self.assertEqual(len(blotter.open_orders[self.asset_24]), 3)
self.assertEqual(
[o.amount for o in blotter.open_orders[self.asset_24]],
[100, 200, 300],
)
blotter.cancel(oid_2)
self.assertEqual(len(blotter.open_orders), 2)
self.assertEqual(len(blotter.open_orders[self.asset_24]), 2)
self.assertEqual(
[o.amount for o in blotter.open_orders[self.asset_24]],
[100, 300],
)
self.assertEqual(
[o.id for o in blotter.open_orders[self.asset_24]],
[oid_1, oid_3],
)
blotter.cancel_all_orders_for_asset(self.asset_24)
self.assertEqual(len(blotter.open_orders), 1)
self.assertEqual(list(blotter.open_orders), [self.asset_25])