Returns the sum of self and other.
Throws ParamError on overflow (or sign violation for unsigned
types).
Returns a fresh wrapper holding the same value.
Value types are cheap to copy. Ordinary setters already borrow/clone wrapper inputs; this method is a convenience when an explicit second wrapper object is useful.
Divides by a number | bigint scalar.
Throws ParamError on division by zero, overflow, or an invalid
scalar.
Returns true when the value is exactly zero.
Computes the remainder against a number | bigint scalar.
Throws ParamError on division by zero, overflow, or an invalid
scalar.
Multiplies by a number | bigint scalar.
bigint is exact; number is imprecise.
Throws ParamError on overflow or an invalid scalar.
Returns the close [Quantity, ("BUY"|"SELL")|undefined] pair.
The side is undefined when the position is flat.
Returns the canonical decimal string for JSON serialization.
Returns the open [Quantity, "BUY"|"SELL"] pair as a 2-element array.
Returns the canonical decimal string.
StaticfromStaticfromConstructs from a JS number (imprecise; prefer fromString).
Throws ParamError on a non-finite or out-of-domain value.
StaticfromConstructs from a JS number then quantizes to scale.
WARNING: the float source is imprecise; prefer
fromStringRounded.
Throws ParamError on an invalid value, scale, or strategy.
StaticfromStaticfromStaticfromBuilds a signed position size from a quantity and a side.
Throws ParamError when side is not "BUY"/"SELL".
StaticfromConstructs losslessly from a decimal string.
Throws ParamError on an invalid format or out-of-domain value.
StaticfromParses a decimal string then quantizes to scale using
strategy.
Throws ParamError on an invalid value, scale, or strategy.
StaticzeroReturns the zero value.
Constructs from a
DecimalInput(string | number | bigint).A generic
numbermust be a safe integer. UsefromFloatexplicitly for imprecise fractional input.Errors
Throws
ParamErroron an invalid value or type.