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_subchain_getters_partial_fill_before_ack(): # 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 aggressive partial fill pf = PartialFillReport(121236, 1234237.123, 2342, "user_x", MARKET, n, 44, Price("34.52"), BID_SIDE, 99999, 1000 - 44) oec.apply_partial_fill_report(pf) # now ack it ack = AcknowledgementReport(121235, 1234235.123, 2342, "user_x", MARKET, n, Price("34.52"), 1000-44, None) oec.apply_acknowledgement_report(ack) subchain = oec.most_recent_subchain() assert subchain.open_event() == n assert subchain.first_execution_report() == pf assert subchain.fills() == [pf] assert subchain.last_event() == ack