Esempio n. 1
0
 def test_cancelled_orders_in_spread_calc(self):
     book = OrderBook()
     limit_buy_order = Order(ID_GENERATOR, 1, 195, "LIMIT", 100)
     limit_sell_order = Order(ID_GENERATOR, 2, 200, "LIMIT", -50)
     book.add_order(limit_sell_order)
     book.add_order(limit_buy_order)
     self.assertEqual(book.current_spread(), 5)
     limit_sell_order.cancel()
     self.assertEqual(book.current_spread(), 0)
Esempio n. 2
0
 def test_should_give_correct_bid_ask(self):
     book = OrderBook()
     self.assertEqual(book.current_spread(), 0)
     limit_buy_order = Order(ID_GENERATOR, 1, 100, "LIMIT", 100)
     limit_sell_order = Order(ID_GENERATOR, 2, 105, "LIMIT", -100)
     book.add_order(limit_buy_order)
     book.add_order(limit_sell_order)
     self.assertEqual(book.current_spread(), 5)
     limit_buy_order2 = Order(ID_GENERATOR, 3, 102, "LIMIT", 100)
     book.add_order(limit_buy_order2)
     self.assertEqual(book.current_spread(), 3)