示例#1
0
    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)
示例#2
0
    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)
    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)
示例#4
0
    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)
示例#5
0
    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)
    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)
示例#7
0
    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)