Float-based rounding helpers ported from py-clob-client-v2.
These helpers intentionally use floats, not Decimal, because order amount parity with the official client is more important than decimal arithmetic aesthetics.
Summary
Functions
Returns the Python-client rounding config for a tick size.
Returns the number of decimal places in the shortest float string.
Rounds down to sig_digits decimal places.
Rounds normally to sig_digits decimal places.
Rounds up to sig_digits decimal places.
Converts a float token amount to CLOB 6-decimal integer units.
Types
@type round_config() :: %{ price: non_neg_integer(), size: non_neg_integer(), amount: non_neg_integer() }
@type tick_size() :: String.t()
Functions
@spec config!(tick_size()) :: round_config()
Returns the Python-client rounding config for a tick size.
@spec decimal_places(number()) :: non_neg_integer()
Returns the number of decimal places in the shortest float string.
@spec round_down(number(), non_neg_integer()) :: float()
Rounds down to sig_digits decimal places.
@spec round_normal(number(), non_neg_integer()) :: float()
Rounds normally to sig_digits decimal places.
@spec round_up(number(), non_neg_integer()) :: float()
Rounds up to sig_digits decimal places.
Converts a float token amount to CLOB 6-decimal integer units.