@openpit/engine
    Preparing search index...

    Class PositionSize

    Index
    • 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 PositionSize

    • Returns void

    • Returns the sum of self and other.

      Errors

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

      Parameters

      Returns PositionSize

    • Adds a quantity on the given side.

      Errors

      Throws ParamError on overflow or when side is invalid.

      Parameters

      Returns PositionSize

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

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

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

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

    • Returns the negation of this value.

      Errors

      Throws ParamError on arithmetic overflow.

      Returns PositionSize

    • Returns the close [Quantity, ("BUY"|"SELL")|undefined] pair.

      The side is undefined when the position is flat.

      Returns [Quantity, "BUY" | "SELL" | undefined]

    • Returns the canonical decimal string for JSON serialization.

      Returns string

    • Returns the open [Quantity, "BUY"|"SELL"] pair as a 2-element array.

      Returns [Quantity, "BUY" | "SELL"]

    • Returns the canonical decimal string.

      Returns string

    • Builds a position size from a fee.

      Parameters

      Returns PositionSize

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

      Errors

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

      Parameters

      • value: number

      Returns PositionSize

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

    • Constructs from an exact integer (bigint).

      Errors

      Throws ParamError on an out-of-domain value.

      Parameters

      • value: bigint

      Returns PositionSize

    • Builds a position size from a P&L value.

      Parameters

      Returns PositionSize

    • Builds a signed position size from a quantity and a side.

      Errors

      Throws ParamError when side is not "BUY"/"SELL".

      Parameters

      Returns PositionSize

    • Constructs losslessly from a decimal string.

      Errors

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

      Parameters

      • value: string

      Returns PositionSize

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