Class PricingUtil


  • public class PricingUtil
    extends java.lang.Object
    Helper class that contains Pricing Calculation functions, including FX calculations.
    • Constructor Summary

      Constructors 
      Constructor Description
      PricingUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static io.token.proto.common.money.MoneyProtos.Money feeAsMoney​(io.token.proto.common.pricing.PricingProtos.TransferQuote quote)
      Converts quote fees into MoneyProtos.Money representation.
      static io.token.proto.common.pricing.PricingProtos.TransferQuote.FxRate findFxRate​(java.util.List<io.token.proto.common.pricing.PricingProtos.TransferQuote.FxRate> rates, java.lang.String currency1, java.lang.String currency2)
      Returns an FX rate that matches the specified currencies.
      static io.token.proto.common.money.MoneyProtos.Money minus​(io.token.proto.common.money.MoneyProtos.Money left, io.token.proto.common.money.MoneyProtos.Money right)
      Subtracts two money amounts.
      static io.token.proto.common.money.MoneyProtos.Money performFx​(io.token.proto.common.money.MoneyProtos.Money amount, java.lang.String currency, io.token.proto.common.pricing.PricingProtos.TransferQuote.FxRate fxRate)
      Performs FX conversion of a given amount using the specified fx rate.
      static io.token.proto.common.money.MoneyProtos.Money performFx​(io.token.proto.common.money.MoneyProtos.Money amount, java.lang.String currency, java.util.List<io.token.proto.common.pricing.PricingProtos.TransferQuote.FxRate> fxRates)
      Performs FX conversion of a given amount.
      static io.token.proto.common.money.MoneyProtos.Money plus​(io.token.proto.common.money.MoneyProtos.Money left, io.token.proto.common.money.MoneyProtos.Money right)
      Adds up two money amounts.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PricingUtil

        public PricingUtil()
    • Method Detail

      • findFxRate

        @Nullable
        public static io.token.proto.common.pricing.PricingProtos.TransferQuote.FxRate findFxRate​(java.util.List<io.token.proto.common.pricing.PricingProtos.TransferQuote.FxRate> rates,
                                                                                                  java.lang.String currency1,
                                                                                                  java.lang.String currency2)
        Returns an FX rate that matches the specified currencies.
        Parameters:
        rates - a list of fx rates
        currency1 - currency to find fx rate for
        currency2 - currency to find fx rate for
        Returns:
        the fx rate if found, an empty fx rate if not
      • performFx

        public static io.token.proto.common.money.MoneyProtos.Money performFx​(io.token.proto.common.money.MoneyProtos.Money amount,
                                                                              java.lang.String currency,
                                                                              io.token.proto.common.pricing.PricingProtos.TransferQuote.FxRate fxRate)
                                                                       throws PricingException
        Performs FX conversion of a given amount using the specified fx rate.
        Parameters:
        amount - the amount to be converted
        currency - the target currency
        fxRate - the fx rate for the conversion
        Returns:
        a converted amount
        Throws:
        PricingException - if currency mismatch or arithmetic error
      • performFx

        public static io.token.proto.common.money.MoneyProtos.Money performFx​(io.token.proto.common.money.MoneyProtos.Money amount,
                                                                              java.lang.String currency,
                                                                              java.util.List<io.token.proto.common.pricing.PricingProtos.TransferQuote.FxRate> fxRates)
                                                                       throws PricingException
        Performs FX conversion of a given amount.
        Parameters:
        amount - the amount to be converted
        currency - the target currency
        fxRates - a list of fx rates
        Returns:
        the converted money amount
        Throws:
        PricingException - if currency mismatch, arithmetic error, or if FX rate unknown
      • feeAsMoney

        public static io.token.proto.common.money.MoneyProtos.Money feeAsMoney​(io.token.proto.common.pricing.PricingProtos.TransferQuote quote)
        Converts quote fees into MoneyProtos.Money representation.
        Parameters:
        quote - the quote to use
        Returns:
        fess as money
      • plus

        public static io.token.proto.common.money.MoneyProtos.Money plus​(io.token.proto.common.money.MoneyProtos.Money left,
                                                                         io.token.proto.common.money.MoneyProtos.Money right)
        Adds up two money amounts.
        Parameters:
        left - the left amount
        right - the right amount
        Returns:
        a new money object
      • minus

        public static io.token.proto.common.money.MoneyProtos.Money minus​(io.token.proto.common.money.MoneyProtos.Money left,
                                                                          io.token.proto.common.money.MoneyProtos.Money right)
        Subtracts two money amounts.
        Parameters:
        left - the left amount
        right - the right amount
        Returns:
        a new money object