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)
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)
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)