Class MarketTenor

  • All Implemented Interfaces:
    Serializable, Comparable<MarketTenor>

    public final class MarketTenor
    extends Object
    implements Comparable<MarketTenor>, Serializable
    A code used in the market to indicate both the start date and tenor of a financial instrument.

    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.

    • Trade date, the date that the trade is agreed
    • Spot date, the base for date calculations, typically 2 business days after the trade date, known as the spot lag
    • Start date, the date on which accrual starts, generally the spot date unless forward starting
    • End date, the date on which accrual ends

    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:

    • ON - Overnight, from today to tomorrow, spot lag of 0 and tenor of 1 day
    • TN - Tomorrow-Next, from tomorrow to the next day, spot lag of 1 and tenor of 1 day
    • SN - Spot-Next, from spot to the next day, market conventional spot lag and tenor of 1 day
    • SW - Spot-Week, from spot for one week, market conventional spot lag and tenor of 1 week
    • "Normal" tenors - 2W, 1M, 1Y etc - from spot for the specified period, market conventional spot lag

    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.

    See Also:
    Serialized Form
    • Field Detail

      • ON

        public static final MarketTenor ON
        A tenor code for Overnight, meaning from today to tomorrow.
      • TN

        public static final MarketTenor TN
        A tenor code for Tomorrow-Next, meaning from tomorrow to the next day.
      • SN

        public static final MarketTenor SN
        A tenor code for Spot-Next, meaning from the spot date to the next day. The spot date is usually two working days after today, but this varies by currency.
      • SW

        public static final MarketTenor SW
        A tenor code for Spot-Week, meaning one week starting from the spot date. The spot date is usually two working days after today, but this varies by currency.
    • Method Detail

      • ofSpot

        public static MarketTenor ofSpot​(Tenor tenor)
        Obtains an instance from a 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.

        Parameters:
        tenor - the tenor
        Returns:
        the tenor
      • ofSpotDays

        public static MarketTenor ofSpotDays​(int days)
        Obtains an instance from a number of days from spot.

        A tenor of 1D will return SN. A tenor of 7D will return SW.

        Parameters:
        days - the tenor in days
        Returns:
        the tenor
      • ofSpotMonths

        public static MarketTenor ofSpotMonths​(int months)
        Obtains an instance from a number of months from spot.
        Parameters:
        months - the tenor in months
        Returns:
        the tenor
      • ofSpotYears

        public static MarketTenor ofSpotYears​(int years)
        Obtains an instance from a number of years from spot.
        Parameters:
        years - the tenor in years
        Returns:
        the tenor
      • parse

        public static MarketTenor parse​(String toParse)
        Parses a formatted string representing the market tenor.

        This parses ON, TN, SN, SW and all formats accepted by Tenor.parse(String).

        Parameters:
        toParse - the string representing the tenor
        Returns:
        the tenor
        Throws:
        IllegalArgumentException - if the tenor cannot be parsed
      • getCode

        public String getCode()
        Gets the market tenor code.
        Returns:
        the code
      • getTenor

        public Tenor getTenor()
        Gets the tenor of the instrument.

        The tenor for ON, TN and SN is 1 day and for SW is 1 week.

        Returns:
        the tenor of the instrument
      • isNonStandardSpotLag

        public boolean isNonStandardSpotLag()
        Checks if the market tenor implies a non-standard spot lag.

        This returns true for ON and TN as they need special date handling. SN and SW return false as they imply market conventional spot.

        Returns:
        true if this market tenor is short
      • adjustSpotLag

        public DaysAdjustment adjustSpotLag​(DaysAdjustment marketConventionalSpotLag)
        Adjusts the market conventional spot lag to match the market tenor.

        The resulting lag will be 0 days for ON and 1 day for TN. Otherwise the input lag will be unchanged.

        Parameters:
        marketConventionalSpotLag - the market conventional spot lag
        Returns:
        true if this market tenor is short
      • compareTo

        public int compareTo​(MarketTenor other)
        Compares this market tenor to another market tenor.

        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.

        Specified by:
        compareTo in interface Comparable<MarketTenor>
        Parameters:
        other - the other tenor
        Returns:
        negative if this is less than the other, zero if equal and positive if greater
      • equals

        public boolean equals​(Object obj)
        Checks if this market tenor equals another market tenor.

        The comparison checks the code.

        Overrides:
        equals in class Object
        Parameters:
        obj - the other market tenor, null returns false
        Returns:
        true if equal
      • hashCode

        public int hashCode()
        Returns a suitable hash code for the market tenor.
        Overrides:
        hashCode in class Object
        Returns:
        the hash code
      • toString

        public String toString()
        Returns a formatted string representing the market tenor.
        Overrides:
        toString in class Object
        Returns:
        the formatted market tenor