def test_get_best_bid_price_with_no_ask(): book = OrderBook() order_stream1 = '1568390201|abbb11|a|AAPL|S|209.00000|100' order_stream2 = '1568390202|abbb13|a|AAPL|S|220.00000|1000' book.process_order(order_stream1) book.process_order(order_stream2) assert book.best_bid_and_ask('AAPL') == (0, 220)
def test_get_bid_and_ask_for_missing_ticker(): book = OrderBook() order_stream1 = '1568390201|abbb11|a|AAPL|S|209.00000|100' order_stream2 = '1568390202|abbb13|a|AAPL|S|220.00000|1000' book.process_order(order_stream1) book.process_order(order_stream2) assert book.best_bid_and_ask('ZZZZ') == (0, 0)
def test_get_best_bid_and_ask_prices(): book = OrderBook() order_stream1 = '1568390201|abbb11|a|AAPL|B|209.00000|100' order_stream2 = '1568390202|abbb12|a|AAPL|S|210.00000|10' order_stream3 = '1568390202|abbb13|a|AAPL|B|220.00000|1000' order_stream4 = '1568390202|abbb14|a|AAPL|S|230.00000|500' book.process_order(order_stream1) book.process_order(order_stream2) book.process_order(order_stream3) book.process_order(order_stream4) assert book.best_bid_and_ask('AAPL') == (209, 230)