Money | WebHare Platform SDK
WebHare Platform SDK
    Preparing search index...

    A decimal based JS money type

    Index

    Constructors

    • Parameters

      • value: MoneyParameter = "0"

      Returns Money

    Properties

    value: string

    finmath-compatible value

    Methods

    • format a price amount. extend # of decimals to specified # if not enough

      Parameters

      Returns string

    • Returns string

    • Returns number

    • Returns string

    • Adds numbers together

      Parameters

      • left: MoneyParameter
      • ...right: MoneyParameter[]

      Returns Money

    • Test whether two values have a specific relation

      Parameters

      • left: MoneyParameter
      • relation: MoneyTestTypes

        One of '<', '<=', '==', '!=', '>', '>=''

      • right: MoneyParameter

      Returns boolean

      TRUE if the relation holds

      console.log(Money.check(1, '\<', 2)); // prints 'true'
      
    • Compares two numbers

      Parameters

      • left: MoneyParameter
      • right: MoneyParameter

      Returns -1 | 0 | 1

      Returns 0 if amount1 === amount2, -1 if amount1 < amount2, 1 if amount1 > amount2

    • Divides two values, (currently with up to 5 decimals of precision)

      Parameters

      • numerator: MoneyParameter

        Value to divide

      • divider: MoneyParameter

      Returns Money

      Divided value

    • Parameters

      • value: number

      Returns Money

    • Returns a percentage of an amount

      Parameters

      • amount: MoneyParameter

        Original amount

      • percentage: MoneyParameter

      Returns Money

      Percentage of the amount

    • Parameters

      • value: unknown

      Returns value is Money

    • Returns the maximum of all the arguments

      Parameters

      • amount: MoneyParameter

        First value

      • ...amounts: MoneyParameter[]

        Rest of the values

      Returns Money

      The highest value among amount and amounts

    • Returns the minimum of all the arguments

      Parameters

      • amount: MoneyParameter

        First value

      • ...amounts: MoneyParameter[]

        Rest of the values

      Returns Money

      The lowest value among amount and amounts

    • Multiplies two numbers together

      Parameters

      • left: MoneyParameter
      • right: MoneyParameter

      Returns Money

    • Rounds a value to a multiple of a unit, with a specific rounding mode

      Parameters

      • amount: MoneyParameter
      • roundto: MoneyParameter
      • mode: MoneyRoundingMode

        Rounding mode. Possible values:

        • none: No rounding
        • toward-zero: Round toward zero
        • down: Round toward negative infity
        • up: Round toward positive infity
        • half-toward-zero: Round nearest multiple, round half of a multiple toward zero
        • half-down: Round nearest multiple, round half of a multiple toward negative infinity
        • half-up: Round nearest multiple, round half of a multiple toward positive infity

      Returns Money

      The rounded value

    • Subtracts a number from another number

      Parameters

      • left: MoneyParameter
      • right: MoneyParameter

      Returns Money