def test_order_working(self): # Arrange uuid = uuid4() event = OrderWorking( account_id=AccountId("SIM", "000"), cl_ord_id=ClientOrderId("O-2020872378423"), order_id=OrderId("123456"), symbol=Symbol("BTC/USDT", Exchange("BINANCE")), order_side=OrderSide.BUY, order_type=OrderType.LIMIT, quantity=Quantity("0.561000"), price=Price("21015.00"), time_in_force=TimeInForce.DAY, expire_time=None, working_time=UNIX_EPOCH, event_id=uuid, event_timestamp=UNIX_EPOCH, ) # Act self.assertEqual( f"OrderWorking(account_id=SIM-000, cl_ord_id=O-2020872378423, " f"order_id=123456, BUY 0.561000 BTC/USDT.BINANCE LIMIT @ 21015.00 DAY, " f"id={uuid})", str(event)) self.assertEqual( f"OrderWorking(account_id=SIM-000, cl_ord_id=O-2020872378423, " f"order_id=123456, BUY 0.561000 BTC/USDT.BINANCE LIMIT @ 21015.00 DAY, " f"id={uuid})", repr(event))
def test_equality_of_subclass(self): # Arrange id1 = Venue("BINANCE") id2 = Exchange("BINANCE") id3 = Symbol("BINANCE", Venue("BINANCE")) # Invalid id4 = Brokerage("BINANCE") # Act # Assert self.assertTrue(id1 == id1) self.assertTrue(id2 == id2) self.assertTrue(id1 == id2) self.assertTrue(id2 == id1) self.assertTrue(id1 != id3) self.assertTrue(id2 != id3) self.assertTrue(id2 != id4)
def test_order_initialized(self): # Arrange uuid = uuid4() event = OrderInitialized( cl_ord_id=ClientOrderId("O-2020872378423"), strategy_id=StrategyId("SCALPER", "001"), symbol=Symbol("BTC/USDT", Exchange("BINANCE")), order_side=OrderSide.BUY, order_type=OrderType.LIMIT, quantity=Quantity("0.561000"), time_in_force=TimeInForce.DAY, event_id=uuid, event_timestamp=UNIX_EPOCH, options={"Price": "15200.10"} ) # Act # Assert self.assertEqual(f"OrderInitialized(cl_ord_id=O-2020872378423, strategy_id=SCALPER-001, event_id={uuid})", str(event)) self.assertEqual(f"OrderInitialized(cl_ord_id=O-2020872378423, strategy_id=SCALPER-001, event_id={uuid})", repr(event))
def test_order_filled(self): # Arrange uuid = uuid4() event = OrderFilled( account_id=AccountId("SIM", "000"), cl_ord_id=ClientOrderId("O-2020872378423"), order_id=OrderId("123456"), execution_id=ExecutionId("1"), position_id=PositionId("2"), strategy_id=StrategyId("SCALPER", "001"), symbol=Symbol("BTC/USDT", Exchange("BINANCE")), order_side=OrderSide.BUY, fill_qty=Quantity("0.561000"), cum_qty=Quantity("0.561000"), leaves_qty=Quantity(0), fill_price=Price("15600.12445"), currency=USDT, is_inverse=False, commission=Money("12.20000000", USDT), liquidity_side=LiquiditySide.MAKER, execution_time=UNIX_EPOCH, event_id=uuid, event_timestamp=UNIX_EPOCH, ) # Act self.assertEqual( f"OrderFilled(account_id=SIM-000, cl_ord_id=O-2020872378423, " f"order_id=123456, position_id=2, strategy_id=SCALPER-001, " f"symbol=BTC/USDT.BINANCE, side=BUY-MAKER, fill_qty=0.561000, " f"fill_price=15600.12445 USDT, cum_qty=0.561000, leaves_qty=0, " f"commission=12.20000000 USDT, id={uuid})", str(event)) # noqa self.assertEqual( f"OrderFilled(account_id=SIM-000, cl_ord_id=O-2020872378423, " f"order_id=123456, position_id=2, strategy_id=SCALPER-001, " f"symbol=BTC/USDT.BINANCE, side=BUY-MAKER, fill_qty=0.561000, " f"fill_price=15600.12445 USDT, cum_qty=0.561000, leaves_qty=0, " f"commission=12.20000000 USDT, id={uuid})", repr(event)) # noqa