Class FxSwapTemplate
- java.lang.Object
-
- com.opengamma.strata.product.fx.type.FxSwapTemplate
-
- All Implemented Interfaces:
TradeTemplate
,Serializable
,org.joda.beans.Bean
,org.joda.beans.ImmutableBean
public final class FxSwapTemplate extends Object implements TradeTemplate, org.joda.beans.ImmutableBean, 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
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FxSwapTemplate.Builder
The bean-builder forFxSwapTemplate
.static class
FxSwapTemplate.Meta
The meta-bean forFxSwapTemplate
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static FxSwapTemplate.Builder
builder()
Returns a builder used to create an instance of the bean.FxSwapTrade
createTrade(LocalDate tradeDate, BuySell buySell, double notional, double nearFxRate, double forwardPoints, ReferenceData refData)
Creates a trade based on this template.boolean
equals(Object obj)
FxSwapConvention
getConvention()
Gets the underlying FX Swap convention.CurrencyPair
getCurrencyPair()
Gets the currency pair of the template.Period
getPeriodToFar()
Gets the period between the spot value date and the far date.Period
getPeriodToNear()
Gets the period between the spot value date and the near date.int
hashCode()
static FxSwapTemplate.Meta
meta()
The meta-bean forFxSwapTemplate
.FxSwapTemplate.Meta
metaBean()
static FxSwapTemplate
of(Period periodToFar, FxSwapConvention convention)
Obtains a template based on the specified period and convention.static FxSwapTemplate
of(Period periodToNear, Period periodToFar, FxSwapConvention convention)
Obtains a template based on the specified periods and convention.FxSwapTemplate.Builder
toBuilder()
Returns a builder that allows this bean to be mutated.String
toString()
-
-
-
Method Detail
-
of
public static FxSwapTemplate of(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 dateconvention
- the market convention- Returns:
- the template
-
of
public static FxSwapTemplate of(Period periodToNear, 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 dateperiodToFar
- the period between the spot date and the far dateconvention
- 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(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 tradebuySell
- the buy/sell flagnotional
- the notional amount, in the first currency of the currency pairnearFxRate
- the FX rate for the near legforwardPoints
- the FX points to be added to the FX rate at the far legrefData
- 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 forFxSwapTemplate
.- 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 interfaceorg.joda.beans.Bean
-
getPeriodToNear
public 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 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
-
-