001package net.objectlab.kit.datecalc.common; 002 003import java.util.List; 004 005import net.objectlab.kit.datecalc.common.ccy.CurrencyCalculatorConfig; 006 007/** 008 * A DateCalculator specialised for a currency pair. Implementations should be thread safe and immutable. 009 * 010 * 'E' will be parameterized to be a Date-like class, i.e. java.util.Date or 011 * java.util.Calendar (and LocalDate or YearMonthDay for Joda-time / JDK8). 012 * 013 * @author Benoit Xhenseval 014 * 015 * @param <E> 016 * a representation of a date, typically JDK: Date, Calendar; 017 * Joda:LocalDate, YearMonthDay; JDK8: LocalDate 018 * @since 1.4.0 019 */ 020public interface CurrencyDateCalculator<E> { 021 /** 022 * Calculate the Spot Date taking into account the working weeks, holidays and spot lag (T+1, T+2 etc), the 023 * calculator also takes into account special rules for Latin American Currencies or Arabic currencies. 024 * @param startDate the start date which may be adjusted for the ccy pair if enabled. 025 * @return the Spot Date 026 */ 027 E calculateSpotDate(E startDate); 028 029 /** 030 * Calculate the Tenor Date from Spot Date taking into account the working weeks, holidays and spot lag (T+1, T+2 etc). 031 * @param startDate the start date which may be adjusted for the ccy pair if enabled. 032 * @param tenor e.g. 1M 033 * @return the Tenor Date 034 */ 035 E calculateTenorDate(E startDate, Tenor tenor); 036 037 /** 038 * Calculate a list of Tenor Dates from Spot Date taking into account the working weeks, holidays and spot lag (T+1, T+2 etc). 039 * @param startDate the start date which may be adjusted for the ccy pair if enabled. 040 * @param tenors the list of tenors ('chronological order is not mandatory) 041 * @return the Tenor Dates (same order as the list of Tenors) 042 */ 043 List<E> calculateTenorDates(E startDate, List<Tenor> tenors); 044 045 String getName(); 046 047 String getCcy1(); 048 049 ReadOnlyHolidayCalendar<E> getCcy1Calendar(); 050 051 WorkingWeek getCcy1Week(); 052 053 String getCcy2(); 054 055 ReadOnlyHolidayCalendar<E> getCcy2Calendar(); 056 057 WorkingWeek getCcy2Week(); 058 059 /** 060 * If enabled show the CrossCcy calendar that may be used on Spot or Tenor dates (in some cases, it is required that GBP/EUR AND USD [the 061 * crossCcy] have all a working day in common for the Spot/Tenor date). This is configurable {@link CurrencyDateCalculatorBuilder#brokenDateAllowed(boolean)}. 062 */ 063 ReadOnlyHolidayCalendar<E> getCrossCcyCalendar(); 064 065 /** 066 * The cross currency used by this calculator. 067 */ 068 String getCrossCcy(); 069 070 WorkingWeek getCrossCcyWeek(); 071 072 /** 073 * @return the Spot Lag (0,1,2) used by this calculator. 074 */ 075 SpotLag getSpotLag(); 076 077 /** 078 * @return true if the calculator adjusts the start date based on the working week and holidays for the currency pair (not the crossCcy). 079 * {@link CurrencyDateCalculatorBuilder#adjustStartDateWithCurrencyPair(boolean)} 080 */ 081 boolean isAdjustStartDateWithCurrencyPair(); 082 083 /** 084 * @return true if the calculator allows a broken date (i.e. a Spot or Tenor date that can fall on a weekend or holiday for the crossCcy). 085 * {@link CurrencyDateCalculatorBuilder#brokenDateAllowed(boolean)} 086 */ 087 boolean isBrokenDateAllowed(); 088 089 /** 090 * @return true if the calculator is using the CrossCcy holidays for T+1 for Ccy1. 091 * {@link CurrencyCalculatorConfig#getCurrenciesSubjectToCrossCcyForT1(String)} 092 */ 093 boolean isUseCrossCcyOnT1ForCcy1(); 094 095 /** 096 * @return true if the calculator is using the CrossCcy holidays for T+1 for Ccy2. 097 * {@link CurrencyCalculatorConfig#getCurrenciesSubjectToCrossCcyForT1(String)} 098 */ 099 boolean isUseCrossCcyOnT1ForCcy2(); 100}