Class FxSwap

  • All Implemented Interfaces:
    Resolvable<ResolvedFxSwap>, FxProduct, Product, Serializable, org.joda.beans.Bean, org.joda.beans.ImmutableBean

    public final class FxSwap
    extends Object
    implements FxProduct, Resolvable<ResolvedFxSwap>, org.joda.beans.ImmutableBean, Serializable
    An FX swap.

    An FX swap is a financial instrument that represents the exchange of an equivalent amount in two different currencies between counterparties on two different dates.

    The two exchanges are based on the same currency pair, with the two payment flows in the opposite directions.

    For example, an FX swap might represent the payment of USD 1,000 and the receipt of EUR 932 on one date, and the payment of EUR 941 and the receipt of USD 1,000 at a later date.

    See Also:
    Serialized Form
    • Method Detail

      • of

        public static FxSwap of​(FxSingle nearLeg,
                                FxSingle farLeg)
        Creates an FxSwap from two transactions.

        The transactions must be passed in with value dates in the correct order. The currency pair of each leg must match and have amounts flowing in opposite directions.

        Parameters:
        nearLeg - the earlier leg
        farLeg - the later leg
        Returns:
        the FX swap
      • of

        public static FxSwap of​(CurrencyAmount amount,
                                FxRate nearRate,
                                LocalDate nearDate,
                                FxRate farRate,
                                LocalDate farDate)
        Creates an FxSwap using two FX rates, near and far, specifying a date adjustment.

        The FX rate at the near date is specified as nearRate. The FX rate at the far date is specified as farRate. The FX rates must have the same currency pair.

        The two currencies are specified by the FX rates. The amount must be specified using one of the currencies of the near FX rate. The near date must be before the far date. Conventions will be used to determine the base and counter currency.

        Parameters:
        amount - the amount being exchanged, positive if being received in the near leg, negative if being paid
        nearRate - the near FX rate
        farRate - the far FX rate
        nearDate - the near value date
        farDate - the far value date
        Returns:
        the FX swap
        Throws:
        IllegalArgumentException - if the FX rate and amount do not have a currency in common, or if the FX rate currencies differ
      • of

        public static FxSwap of​(CurrencyAmount amount,
                                FxRate nearRate,
                                LocalDate nearDate,
                                FxRate farRate,
                                LocalDate farDate,
                                BusinessDayAdjustment paymentDateAdjustment)
        Creates an FxSwap using two FX rates, near and far, specifying a date adjustment.

        The FX rate at the near date is specified as nearRate. The FX rate at the far date is specified as farRate. The FX rates must have the same currency pair.

        The two currencies are specified by the FX rates. The amount must be specified using one of the currencies of the near FX rate. The near date must be before the far date. Conventions will be used to determine the base and counter currency.

        Parameters:
        amount - the amount being exchanged, positive if being received in the near leg, negative if being paid
        nearRate - the near FX rate
        farRate - the far FX rate
        nearDate - the near value date
        farDate - the far value date
        paymentDateAdjustment - the adjustment to apply to the payment dates
        Returns:
        the FX swap
        Throws:
        IllegalArgumentException - if the FX rate and amount do not have a currency in common, or if the FX rate currencies differ
      • ofForwardPoints

        public static FxSwap ofForwardPoints​(CurrencyAmount amount,
                                             FxRate nearRate,
                                             double decimalForwardPoints,
                                             LocalDate nearDate,
                                             LocalDate farDate)
        Creates an FxSwap using decimal forward points.

        The FX rate at the near date is specified as nearRate. The FX rate at the far date is equal to nearRate + forwardPoints. Thus "FX forward spread" might be a better name for the concept.

        The two currencies are specified by the near FX rate. The amount must be specified using one of the currencies of the near FX rate. The near date must be before the far date. Conventions will be used to determine the base and counter currency.

        Parameters:
        amount - the amount being exchanged, positive if being received in the near leg, negative if being paid
        nearRate - the near FX rate
        decimalForwardPoints - the decimal forward points, where the far FX rate is (nearRate + forwardPoints)
        nearDate - the near value date
        farDate - the far value date
        Returns:
        the FX swap
        Throws:
        IllegalArgumentException - if the FX rate and amount do not have a currency in common
      • ofForwardPoints

        public static FxSwap ofForwardPoints​(CurrencyAmount amount,
                                             FxRate nearRate,
                                             double decimalForwardPoints,
                                             LocalDate nearDate,
                                             LocalDate farDate,
                                             BusinessDayAdjustment paymentDateAdjustment)
        Creates an FxSwap using decimal forward points, specifying a date adjustment.

        The FX rate at the near date is specified as nearRate. The FX rate at the far date is equal to nearRate + forwardPoints Thus "FX forward spread" might be a better name for the concept.

        The two currencies are specified by the near FX rate. The amount must be specified using one of the currencies of the near FX rate. The near date must be before the far date. Conventions will be used to determine the base and counter currency.

        Parameters:
        amount - the amount being exchanged, positive if being received in the near leg, negative if being paid
        nearRate - the near FX rate
        decimalForwardPoints - the decimal forward points, where the far FX rate is (nearRate + forwardPoints)
        nearDate - the near value date
        farDate - the far value date
        paymentDateAdjustment - the adjustment to apply to the payment dates
        Returns:
        the FX swap
        Throws:
        IllegalArgumentException - if the FX rate and amount do not have a currency in common
      • getCurrencyPair

        public CurrencyPair getCurrencyPair()
        Gets the currency pair in conventional order.
        Specified by:
        getCurrencyPair in interface FxProduct
        Returns:
        the currency pair
      • resolve

        public ResolvedFxSwap resolve​(ReferenceData refData)
        Description copied from interface: Resolvable
        Resolves this object using the specified reference data.

        This converts the object implementing this interface to the equivalent resolved form. All ReferenceDataId identifiers in this instance will be resolved. The resolved form will typically be a type that is optimized for pricing.

        Resolved objects may be bound to data that changes over time, such as holiday calendars. If the data changes, such as the addition of a new holiday, the resolved form will not be updated. Care must be taken when placing the resolved form in a cache or persistence layer.

        Specified by:
        resolve in interface Resolvable<ResolvedFxSwap>
        Parameters:
        refData - the reference data to use when resolving
        Returns:
        the resolved instance
      • meta

        public static FxSwap.Meta meta()
        The meta-bean for FxSwap.
        Returns:
        the meta-bean, not null
      • metaBean

        public FxSwap.Meta metaBean()
        Specified by:
        metaBean in interface org.joda.beans.Bean
      • getNearLeg

        public FxSingle getNearLeg()
        Gets the foreign exchange transaction at the earlier date.

        This provides details of a single foreign exchange at a specific date. The payment date of this transaction must be before that of the far leg.

        Returns:
        the value of the property, not null
      • getFarLeg

        public FxSingle getFarLeg()
        Gets the foreign exchange transaction at the later date.

        This provides details of a single foreign exchange at a specific date. The payment date of this transaction must be after that of the near leg.

        Returns:
        the value of the property, not null
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object