You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
DollarDecimal serialization can emit scientific notation (Kalshi may reject) #191
The Kalshi API documents <dollars_string> and fixed-point count wire formats with positional digits (examples: "0.5600", "100.00"). Any Decimal whose representation lands in scientific form will be sent to the server as e.g. "1E-2", either rejected with a 400 or — worse — accepted by a permissive parser at a different numeric value.
The risk surface is small for current price ranges (typical Decimals '0.0001'–'1.0000' stay in positional form), but real for:
FixedPointCount on large batch orders (count_fp, volume_fp accumulated cost in big positions)
Any arithmetic the user performs on Decimals before passing them in (a.scaleb, a * b with mixed exponents)
Future high-precision fields the spec may add
Location
kalshi/types.py:31-33
Evidence
# kalshi/types.pydef_decimal_to_str(value: Decimal) ->str:
"""Serialize Decimal back to string for API requests."""returnstr(value)
Recommended fix
Format positionally:
def_decimal_to_str(value: Decimal) ->str:
returnf'{value:f}'# forces fixed-point, never scientific
Decimal.__format__('f') handles all finite Decimals correctly and is the documented positional format. Add unit tests covering:
Activity