"""Crypto exchange port DTOs are immutable value objects with the fields the layer depends on."""
from __future__ import annotations

from fxhnt.ports.crypto_exchange import ChildOrder, Fill, OrderBook, PerpPosition, SymbolFilter


def test_dtos_construct() -> None:
    f = SymbolFilter(symbol="BTCUSDT", step_size=0.001, tick_size=0.1, min_notional=5.0)
    ob = OrderBook(symbol="BTCUSDT", bid=100.0, ask=100.2, bid_qty=3.0, ask_qty=4.0)
    p = PerpPosition(symbol="BTCUSDT", qty=-0.5, entry_price=101.0, leverage=3)
    o = ChildOrder(symbol="BTCUSDT", side="BUY", qty=0.01, order_type="LIMIT", price=100.0,
                   reduce_only=False, post_only=True, client_id="fxhnt-1-BTCUSDT-maker", time_in_force="GTX")
    fi = Fill(client_id=o.client_id, symbol="BTCUSDT", side="BUY", qty=0.01, price=100.05, fee=0.001,
              status="FILLED")
    assert ob.mid == 100.1 and p.qty == -0.5 and o.post_only and fi.status == "FILLED"
