Constructors

  • Constructs from a DecimalInput (string | number | bigint).

    A generic number must be a safe integer. Use fromFloat explicitly for imprecise fractional input.

    Errors

    Throws ParamError on an invalid value or type.

    Parameters

    • value: string | number | bigint

    Returns Pnl

Methods

  • Returns void

  • Returns the sum of self and other.

    Errors

    Throws ParamError on overflow (or sign violation for unsigned types).

    Parameters

    Returns Pnl

  • 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.

    Returns Pnl

  • Compares against other: -1, 0, or 1.

    Parameters

    Returns number

  • Divides by a number | bigint scalar.

    Errors

    Throws ParamError on division by zero, overflow, or an invalid scalar.

    Parameters

    • scalar: number | bigint

    Returns Pnl

  • Returns true when both values are equal.

    Parameters

    Returns boolean

  • Returns void

  • Returns true when the value is exactly zero.

    Returns boolean

  • Computes the remainder against a number | bigint scalar.

    Errors

    Throws ParamError on division by zero, overflow, or an invalid scalar.

    Parameters

    • scalar: number | bigint

    Returns Pnl

  • Multiplies by a number | bigint scalar.

    bigint is exact; number is imprecise.

    Errors

    Throws ParamError on overflow or an invalid scalar.

    Parameters

    • scalar: number | bigint

    Returns Pnl

  • Returns the negation of this value.

    Errors

    Throws ParamError on arithmetic overflow.

    Returns Pnl

  • Returns self minus other.

    Errors

    Throws ParamError on overflow/underflow.

    Parameters

    Returns Pnl

  • Converts this P&L into a cash flow.

    Returns CashFlow

  • Returns the canonical decimal string for JSON serialization.

    Returns string

  • Converts this P&L into a position size.

    Returns PositionSize

  • Returns the canonical decimal string.

    Returns string

  • Builds a P&L value from a fee.

    Parameters

    Returns Pnl

  • Constructs from a JS number (imprecise; prefer fromString).

    Errors

    Throws ParamError on a non-finite or out-of-domain value.

    Parameters

    • value: number

    Returns Pnl

  • Constructs from a JS number then quantizes to scale.

    WARNING: the float source is imprecise; prefer fromStringRounded.

    Errors

    Throws ParamError on an invalid value, scale, or strategy.

    Parameters

    • value: number
    • scale: number
    • strategy: string

    Returns Pnl

  • Constructs from an exact integer (bigint).

    Errors

    Throws ParamError on an out-of-domain value.

    Parameters

    • value: bigint

    Returns Pnl

  • Constructs losslessly from a decimal string.

    Errors

    Throws ParamError on an invalid format or out-of-domain value.

    Parameters

    • value: string

    Returns Pnl

  • Parses a decimal string then quantizes to scale using strategy.

    Errors

    Throws ParamError on an invalid value, scale, or strategy.

    Parameters

    • value: string
    • scale: number
    • strategy: string

    Returns Pnl

  • Returns the zero value.

    Returns Pnl