diff --git a/sdks/python/pmxt/_hosted_mappers.py b/sdks/python/pmxt/_hosted_mappers.py index 30f0adab..dfa13cfd 100644 --- a/sdks/python/pmxt/_hosted_mappers.py +++ b/sdks/python/pmxt/_hosted_mappers.py @@ -15,7 +15,7 @@ from .errors import InvalidOrder from .models import Balance, BuiltOrder, Order, Position, UserTrade -SIX_DEC_SCALE = 1_000_000 +_SIX_DEC_SCALE = 1_000_000 _T = TypeVar("_T") @@ -23,7 +23,7 @@ def to_6dec(amount: float | str | Decimal) -> int: """Convert a decimal amount to integer micro-units with no rounding.""" d = Decimal(str(amount)) - scaled = d * SIX_DEC_SCALE + scaled = d * _SIX_DEC_SCALE if scaled != scaled.to_integral_value(): raise InvalidOrder(f"amount precision exceeds 6 decimals: {amount!r}") return int(scaled) diff --git a/sdks/python/tests/test_hosted_mappers.py b/sdks/python/tests/test_hosted_mappers.py index 95082577..af9f65dc 100644 --- a/sdks/python/tests/test_hosted_mappers.py +++ b/sdks/python/tests/test_hosted_mappers.py @@ -29,6 +29,11 @@ def _mapper(*names): to_6dec = _hosted_mappers.to_6dec +def test_six_decimal_scale_is_module_private(): + assert not hasattr(_hosted_mappers, "SIX_DEC_SCALE") + assert _hosted_mappers._SIX_DEC_SCALE == 1_000_000 + + def _iso_ms(value: str) -> int: return int(datetime.fromisoformat(value.replace("Z", "+00:00")).timestamp() * 1000)