def test_to_dict_returns_expected_dict(self): # Arrange tick = TradeTick( instrument_id=AUDUSD_SIM.id, price=Price.from_str("1.00000"), size=Quantity.from_int(10000), aggressor_side=AggressorSide.BUY, trade_id=TradeId("123456789"), ts_event=0, ts_init=0, ) # Act result = TradeTick.to_dict(tick) # Assert assert result == { "type": "TradeTick", "instrument_id": "AUD/USD.SIM", "price": "1.00000", "size": "10000", "aggressor_side": "BUY", "trade_id": "123456789", "ts_event": 0, "ts_init": 0, }
def test_from_dict_returns_expected_tick(self): # Arrange tick = TradeTick( instrument_id=AUDUSD_SIM.id, price=Price.from_str("1.00000"), size=Quantity.from_int(10000), aggressor_side=AggressorSide.BUY, trade_id=TradeId("123456789"), ts_event=0, ts_init=0, ) # Act result = TradeTick.from_dict(TradeTick.to_dict(tick)) # Assert assert tick == result