public final class MarketTenor extends Object implements Comparable<MarketTenor>, Serializable
In Strata, a Tenor is the actual tenor of an instrument, from start to end.
This class represents the code used in the market which also effectively describes the start date.
Four key dates are needed to understand how this code works.
The period from start date to end date is represented by Tenor.
MarketTenor includes the tenor, but also allows the market conventional spot lag to be overridden.
MarketTenor represents the 4 special cases used in the market as well as more normal tenors:
Note that if the market conventional spot lag is 1 day, TN and SN would resolve to the same dates. Note also that SN and SW exist for clarity, they might also be expressed as 1D and 1W with the spot implied. Other date combinations are possible in theory but tend not to exist in the market, for example a three day trade starting tomorrow, something which might require a code like T3D.
| Modifier and Type | Field and Description |
|---|---|
static MarketTenor |
ON
A tenor code for Overnight, meaning from today to tomorrow.
|
static MarketTenor |
SN
A tenor code for Spot-Next, meaning from the spot date to the next day.
|
static MarketTenor |
SW
A tenor code for Spot-Week, meaning one week starting from the spot date.
|
static MarketTenor |
TN
A tenor code for Tomorrow-Next, meaning from tomorrow to the next day.
|
| Modifier and Type | Method and Description |
|---|---|
DaysAdjustment |
adjustSpotLag(DaysAdjustment marketConventionalSpotLag)
Adjusts the market conventional spot lag to match the market tenor.
|
int |
compareTo(MarketTenor other)
Compares this market tenor to another market tenor.
|
boolean |
equals(Object obj)
Checks if this market tenor equals another market tenor.
|
String |
getCode()
Gets the market tenor code.
|
Tenor |
getTenor()
Gets the tenor of the instrument.
|
int |
hashCode()
Returns a suitable hash code for the market tenor.
|
boolean |
isNonStandardSpotLag()
Checks if the market tenor implies a non-standard spot lag.
|
static MarketTenor |
ofSpot(Tenor tenor)
Obtains an instance from a
Tenor with spot implied. |
static MarketTenor |
ofSpotDays(int days)
Obtains an instance from a number of days from spot.
|
static MarketTenor |
ofSpotMonths(int months)
Obtains an instance from a number of months from spot.
|
static MarketTenor |
ofSpotYears(int years)
Obtains an instance from a number of years from spot.
|
static MarketTenor |
parse(String toParse)
Parses a formatted string representing the market tenor.
|
String |
toString()
Returns a formatted string representing the market tenor.
|
public static final MarketTenor ON
public static final MarketTenor TN
public static final MarketTenor SN
public static final MarketTenor SW
public static MarketTenor ofSpot(Tenor tenor)
Tenor with spot implied.
A tenor of 1D will return SN. A tenor of 1W will return SW. Other tenors will return a market tenor with the same code as the tenor.
tenor - the tenorpublic static MarketTenor ofSpotDays(int days)
A tenor of 1D will return SN. A tenor of 7D will return SW.
days - the tenor in dayspublic static MarketTenor ofSpotMonths(int months)
months - the tenor in monthspublic static MarketTenor ofSpotYears(int years)
years - the tenor in yearspublic static MarketTenor parse(String toParse)
This parses ON, TN, SN, SW and all formats accepted by Tenor.parse(String).
toParse - the string representing the tenorIllegalArgumentException - if the tenor cannot be parsedpublic String getCode()
public Tenor getTenor()
The tenor for ON, TN and SN is 1 day and for SW is 1 week.
public boolean isNonStandardSpotLag()
This returns true for ON and TN as they need special date handling. SN and SW return false as they imply market conventional spot.
public DaysAdjustment adjustSpotLag(DaysAdjustment marketConventionalSpotLag)
The resulting lag will be 0 days for ON and 1 day for TN. Otherwise the input lag will be unchanged.
marketConventionalSpotLag - the market conventional spot lagpublic int compareTo(MarketTenor other)
Comparing tenors is a hard problem in general, but for commonly used tenors the outcome is as expected.
This uses the same sort order as Tenor with ON and TN first.
compareTo in interface Comparable<MarketTenor>other - the other tenorpublic boolean equals(Object obj)
The comparison checks the code.
public int hashCode()
Copyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.