Class FxSwapTemplate

  • All Implemented Interfaces:
    TradeTemplate, java.io.Serializable, org.joda.beans.Bean, org.joda.beans.ImmutableBean

    public final class FxSwapTemplate
    extends java.lang.Object
    implements TradeTemplate, org.joda.beans.ImmutableBean, java.io.Serializable
    A template for creating an FX swap trade.

    This defines almost all the data necessary to create a FxSwapTrade. The trade date, notional, FX rate and forward points are required to complete the template and create the trade. As such, it is often possible to get a market price for a trade based on the template.

    The convention is defined by four dates.

    • Trade date, the date that the trade is agreed
    • Spot date, the base for date calculations, typically 2 business days in the joint calendar of both currencies after the trade date
    • Near date, the date on which the near leg of the swap is exchanged, typically equal to the spot date
    • Far date, the date on which the far leg of the swap is exchanged, typically a number of months or years after the spot date
    Some of these dates are specified by the convention embedded within this template.
    See Also:
    Serialized Form
    • Method Detail

      • of

        public static FxSwapTemplate of​(java.time.Period periodToFar,
                                        FxSwapConvention convention)
        Obtains a template based on the specified period and convention.

        The near date is equal to the spot date. The period from the spot date to the far date is specified

        For example, a '6M' FX swap has a near leg on the spot date and a period from spot to the far date of 6 months

        Parameters:
        periodToFar - the period between the spot date and the far date
        convention - the market convention
        Returns:
        the template
      • of

        public static FxSwapTemplate of​(java.time.Period periodToNear,
                                        java.time.Period periodToFar,
                                        FxSwapConvention convention)
        Obtains a template based on the specified periods and convention.

        Both the period from the spot date to the near date and far date are specified.

        For example, a '3M x 6M' FX swap has a period from spot to the start date of 3 months and a period from spot to the far date of 6 months

        Parameters:
        periodToNear - the period between the spot date and the near date
        periodToFar - the period between the spot date and the far date
        convention - the market convention
        Returns:
        the template
      • getCurrencyPair

        public CurrencyPair getCurrencyPair()
        Gets the currency pair of the template.
        Returns:
        the currency pair
      • createTrade

        public FxSwapTrade createTrade​(java.time.LocalDate tradeDate,
                                       BuySell buySell,
                                       double notional,
                                       double nearFxRate,
                                       double forwardPoints,
                                       ReferenceData refData)
        Creates a trade based on this template.

        This returns a trade based on the specified date. The notional is unsigned, with buy/sell determining the direction of the trade. If buying the FX Swap, the amount in the first currency of the pair is received in the near leg and paid in the far leg, while the second currency is paid in the near leg and received in the far leg.

        Parameters:
        tradeDate - the date of the trade
        buySell - the buy/sell flag
        notional - the notional amount, in the first currency of the currency pair
        nearFxRate - the FX rate for the near leg
        forwardPoints - the FX points to be added to the FX rate at the far leg
        refData - the reference data, used to resolve the trade dates
        Returns:
        the trade
        Throws:
        ReferenceDataNotFoundException - if an identifier cannot be resolved in the reference data
      • meta

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

        public static FxSwapTemplate.Builder builder()
        Returns a builder used to create an instance of the bean.
        Returns:
        the builder, not null
      • metaBean

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

        public java.time.Period getPeriodToNear()
        Gets the period between the spot value date and the near date.

        For example, a '3M x 6M' FX swap has a period from spot to the near date of 3 months

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

        public java.time.Period getPeriodToFar()
        Gets the period between the spot value date and the far date.

        For example, a '3M x 6M' FX swap has a period from spot to the far date of 6 months

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

        public FxSwapConvention getConvention()
        Gets the underlying FX Swap convention.

        This specifies the market convention of the FX Swap to be created.

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

        public FxSwapTemplate.Builder toBuilder()
        Returns a builder that allows this bean to be mutated.
        Returns:
        the mutable builder, not null
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object