27 lines
920 B
Python
27 lines
920 B
Python
"""Exchange-filter rounding: floor qty to step, round price to tick, min-notional gate."""
|
|
from __future__ import annotations
|
|
|
|
from fxhnt.domain.execution.rounding import meets_min_notional, round_price, round_qty
|
|
from fxhnt.ports.crypto_exchange import SymbolFilter
|
|
|
|
F = SymbolFilter(symbol="X", step_size=0.001, tick_size=0.1, min_notional=5.0)
|
|
|
|
|
|
def test_round_qty_floors_to_step() -> None:
|
|
assert round_qty(0.0037, F) == 0.003 # floor, never round up past intent
|
|
assert round_qty(1.2345, F) == 1.234
|
|
|
|
|
|
def test_round_price_to_tick() -> None:
|
|
assert round_price(100.07, F) == 100.1
|
|
assert round_price(100.04, F) == 100.0
|
|
|
|
|
|
def test_min_notional_gate() -> None:
|
|
assert meets_min_notional(0.06, 100.0, F) is True # 6 USD >= 5
|
|
assert meets_min_notional(0.04, 100.0, F) is False # 4 USD < 5
|
|
|
|
|
|
def test_round_qty_below_step_is_zero() -> None:
|
|
assert round_qty(0.0009, F) == 0.0
|