pub struct Precise;Expand description
A struct wrapper matching CCXT Precise class usage (e.g. Precise::string_add).
Implementations§
Source§impl Precise
impl Precise
Sourcepub fn new(v: Value) -> Value
pub fn new(v: Value) -> Value
TS-style new Precise(s) — parses s into an integer (the
digit string) + decimals (count of digits to the right of the
decimal point). Returns a Value::Map carrying those two
fields plus a __precise marker that stringify_param /
Value::reduce recognise — that’s what makes
precise.decimals = subtract(...) followed by precise.reduce()
(as transpiled phemex’s toEn does) work end-to-end.
Source§impl Precise
impl Precise
pub fn string_add(a: &str, b: &str) -> Option<String>
pub fn string_sub(a: &str, b: &str) -> Option<String>
pub fn string_mul(a: &str, b: &str) -> Option<String>
pub fn string_div(a: &str, b: &str) -> Option<String>
pub fn string_mod(a: &str, b: &str) -> Option<String>
pub fn string_eq(a: &str, b: &str) -> Option<bool>
pub fn string_gt(a: &str, b: &str) -> Option<bool>
pub fn string_ge(a: &str, b: &str) -> Option<bool>
pub fn string_lt(a: &str, b: &str) -> Option<bool>
pub fn string_le(a: &str, b: &str) -> Option<bool>
pub fn string_abs(a: &str) -> Option<String>
pub fn string_neg(a: &str) -> Option<String>
pub fn string_to_precision(a: &str, decimals: u32, mode: u8) -> Option<String>
Source§impl Precise
impl Precise
Sourcepub fn stringAdd(a: &Value, b: &Value) -> Value
pub fn stringAdd(a: &Value, b: &Value) -> Value
Mirrors TS Precise.stringAdd: when one operand is undefined /
null it returns the OTHER side (treating the missing value as the
arithmetic identity). Bitget’s parsePosition relies on this when
keepMarginRate is missing (UTA response uses mmr instead), so
Precise.stringAdd(undefined, feeToClose) should yield feeToClose.
Sourcepub fn stringSub(a: &Value, b: &Value) -> Value
pub fn stringSub(a: &Value, b: &Value) -> Value
Mirrors TS Precise.stringSub: either operand undefined → undefined.
Sourcepub fn stringMul(a: &Value, b: &Value) -> Value
pub fn stringMul(a: &Value, b: &Value) -> Value
Mirrors TS Precise.stringMul: any undefined operand → undefined
(matches the typescript x * undefined === NaN → undefined chain).
pub fn stringDiv(a: &Value, b: &Value) -> Value
Sourcepub fn stringDivPrec(a: &Value, b: &Value, precision: &Value) -> Value
pub fn stringDivPrec(a: &Value, b: &Value, precision: &Value) -> Value
Precise.stringDiv (a, b, precision) — truncating division to a
given number of decimal places.