def test_subchain_to_json(): # pretty basic, just testing that it doesn't break n = NewOrderCommand(121234, 1234235.123, 2342, "user_x", MARKET, BID_SIDE, FAR, Price("34.52"), 1000) oec = OrderEventChain(n, LOGGER, MonotonicIntID()) # now ack it ack = AcknowledgementReport(121235, 1234235.123, 2342, "user_x", MARKET, n, Price("34.52"), 1000, None) oec.apply_acknowledgement_report(ack) assert oec.most_recent_event() == ack # now check I can get a to_json of the subchain no problem oec.most_recent_subchain().to_json()
def test_new_iceberg_order_ack(): n = NewOrderCommand(121234, 1234235.123, 2342, "user_x", MARKET, BID_SIDE, FAR, Price("34.52"), 1000, 50) oec = OrderEventChain(n, LOGGER, MonotonicIntID()) # no ack yet assert oec.most_recent_event() == n # check exposure assert len(oec.open_exposure_requests()) == 1 assert oec.most_recent_requested_exposure() == oec.open_exposure_requests()[-1] assert oec.current_exposure() is None assert oec.most_recent_requested_exposure() == Exposure(Price("34.52"), 1000, 121234) # visible qty should be nothing still assert oec.visible_qty() == 0 # now ack it ack = AcknowledgementReport(121235, 1234235.123, 2342, "user_x", MARKET, n, Price("34.52"), 1000, 50) oec.apply_acknowledgement_report(ack) assert oec.most_recent_event() == ack # check exposure assert len(oec.open_exposure_requests()) == 0 assert oec.most_recent_requested_exposure() is None assert oec.current_exposure() == Exposure(Price("34.52"), 1000, 121235) # check visible qty assert oec.visible_qty() == 50