当前位置: 首页>>代码示例>>Python>>正文


Python Blotter.execute_cancel_policy方法代码示例

本文整理汇总了Python中zipline.finance.blotter.Blotter.execute_cancel_policy方法的典型用法代码示例。如果您正苦于以下问题:Python Blotter.execute_cancel_policy方法的具体用法?Python Blotter.execute_cancel_policy怎么用?Python Blotter.execute_cancel_policy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在zipline.finance.blotter.Blotter的用法示例。


在下文中一共展示了Blotter.execute_cancel_policy方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_blotter_never_cancel

# 需要导入模块: from zipline.finance.blotter import Blotter [as 别名]
# 或者: from zipline.finance.blotter.Blotter import execute_cancel_policy [as 别名]
    def test_blotter_never_cancel(self):
        blotter = Blotter('minute', cancel_policy=NeverCancel())

        blotter.order(self.asset_24, 100, MarketOrder())

        self.assertEqual(len(blotter.new_orders), 1)
        self.assertEqual(blotter.new_orders[0].status, ORDER_STATUS.OPEN)

        blotter.execute_cancel_policy(BAR)
        self.assertEqual(blotter.new_orders[0].status, ORDER_STATUS.OPEN)

        blotter.execute_cancel_policy(SESSION_END)
        self.assertEqual(blotter.new_orders[0].status, ORDER_STATUS.OPEN)
开发者ID:SJCosgrove,项目名称:quantopianresearch,代码行数:15,代码来源:test_blotter.py

示例2: test_blotter_never_cancel

# 需要导入模块: from zipline.finance.blotter import Blotter [as 别名]
# 或者: from zipline.finance.blotter.Blotter import execute_cancel_policy [as 别名]
    def test_blotter_never_cancel(self):
        blotter = Blotter("minute", self.env.asset_finder, cancel_policy=NeverCancel())

        blotter.order(blotter.asset_finder.retrieve_asset(24), 100, MarketOrder())

        self.assertEqual(len(blotter.new_orders), 1)
        self.assertEqual(blotter.new_orders[0].status, ORDER_STATUS.OPEN)

        blotter.execute_cancel_policy(BAR)
        self.assertEqual(blotter.new_orders[0].status, ORDER_STATUS.OPEN)

        blotter.execute_cancel_policy(DAY_END)
        self.assertEqual(blotter.new_orders[0].status, ORDER_STATUS.OPEN)
开发者ID:lghknight,项目名称:zipline,代码行数:15,代码来源:test_blotter.py

示例3: test_blotter_eod_cancellation

# 需要导入模块: from zipline.finance.blotter import Blotter [as 别名]
# 或者: from zipline.finance.blotter.Blotter import execute_cancel_policy [as 别名]
    def test_blotter_eod_cancellation(self):
        blotter = Blotter('minute', cancel_policy=EODCancel())

        # Make two orders for the same asset, so we can test that we are not
        # mutating the orders list as we are cancelling orders
        blotter.order(self.asset_24, 100, MarketOrder())
        blotter.order(self.asset_24, -100, MarketOrder())

        self.assertEqual(len(blotter.new_orders), 2)
        order_ids = [order.id for order in blotter.open_orders[self.asset_24]]

        self.assertEqual(blotter.new_orders[0].status, ORDER_STATUS.OPEN)
        self.assertEqual(blotter.new_orders[1].status, ORDER_STATUS.OPEN)

        blotter.execute_cancel_policy(BAR)
        self.assertEqual(blotter.new_orders[0].status, ORDER_STATUS.OPEN)
        self.assertEqual(blotter.new_orders[1].status, ORDER_STATUS.OPEN)

        blotter.execute_cancel_policy(SESSION_END)
        for order_id in order_ids:
            order = blotter.orders[order_id]
            self.assertEqual(order.status, ORDER_STATUS.CANCELLED)
开发者ID:SJCosgrove,项目名称:quantopianresearch,代码行数:24,代码来源:test_blotter.py

示例4: test_blotter_eod_cancellation

# 需要导入模块: from zipline.finance.blotter import Blotter [as 别名]
# 或者: from zipline.finance.blotter.Blotter import execute_cancel_policy [as 别名]
    def test_blotter_eod_cancellation(self):
        blotter = Blotter("minute", self.env.asset_finder, cancel_policy=EODCancel())
        asset_24 = blotter.asset_finder.retrieve_asset(24)

        # Make two orders for the same sid, so we can test that we are not
        # mutating the orders list as we are cancelling orders
        blotter.order(asset_24, 100, MarketOrder())
        blotter.order(asset_24, -100, MarketOrder())

        self.assertEqual(len(blotter.new_orders), 2)
        order_ids = [order.id for order in blotter.open_orders[asset_24]]

        self.assertEqual(blotter.new_orders[0].status, ORDER_STATUS.OPEN)
        self.assertEqual(blotter.new_orders[1].status, ORDER_STATUS.OPEN)

        blotter.execute_cancel_policy(BAR)
        self.assertEqual(blotter.new_orders[0].status, ORDER_STATUS.OPEN)
        self.assertEqual(blotter.new_orders[1].status, ORDER_STATUS.OPEN)

        blotter.execute_cancel_policy(DAY_END)
        for order_id in order_ids:
            order = blotter.orders[order_id]
            self.assertEqual(order.status, ORDER_STATUS.CANCELLED)
开发者ID:lghknight,项目名称:zipline,代码行数:25,代码来源:test_blotter.py


注:本文中的zipline.finance.blotter.Blotter.execute_cancel_policy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。