コード例 #1
0
    def testCancelAllOpenOrders(self):
        order1 = Order(accountId='accountId',
                       side=Side.BUY,
                       symbol='symbol1',
                       price=13.2,
                       share=10,
                       orderId='id1')
        order2 = Order(accountId='accountId',
                       side=Side.BUY,
                       symbol='symbol1',
                       price=13.25,
                       share=10,
                       orderId='id2')

        tc = TradingCenter()
        tc._TradingCenter__openOrders = {'symbol1': [order1, order2]}

        tc.cancelAllOpenOrders()
        print(tc._TradingCenter__openOrders)
        print(tc._TradingCenter__closedOrders)
        self.assertEquals({}, tc._TradingCenter__openOrders)
        self.assertEquals({
            'id1': order1,
            'id2': order2
        }, tc._TradingCenter__closedOrders)
コード例 #2
0
    def testGetOpenOrdersBySymbol(self):
        order1 = Order(accountId = 'accountId', side = Side.BUY, symbol = 'symbol1', price = 13.2, share = 10, orderId = 'id1')
        order2 = Order(accountId = 'accountId', side = Side.BUY, symbol = 'symbol1', price = 13.25, share = 10, orderId = 'id2')

        tc = TradingCenter()
        tc._TradingCenter__openOrders = {'symbol1': [order1, order2]}
        orders = tc.getOpenOrdersBySymbol('symbol1')
        self.assertEquals([order1, order2], orders)
コード例 #3
0
    def testCancelAllOpenOrders(self):
        order1 = Order(accountId = 'accountId', side = Side.BUY, symbol = 'symbol1', price = 13.2, share = 10, orderId = 'id1')
        order2 = Order(accountId = 'accountId', side = Side.BUY, symbol = 'symbol1', price = 13.25, share = 10, orderId = 'id2')

        tc = TradingCenter()
        tc._TradingCenter__openOrders = {'symbol1': [order1, order2]}

        tc.cancelAllOpenOrders()
        self.assertEquals({}, tc._TradingCenter__openOrders)
        self.assertEquals({'id1': order1, 'id2': order2}, tc._TradingCenter__closedOrders)