Package org.drip.analytics.support
Class Helper
java.lang.Object
org.drip.analytics.support.Helper
public class Helper
extends java.lang.Object
Helper contains the collection of the analytics related utility functions used by the modules.
Following are some of the functionality that it exposes:
- Yield to Discount Factor, and vice versa
- Map Bloomberg Day Count Codes to Credit Analytics Day Count Codes
- Generate rule-based curve node manifest measure bumps
- Generate loss periods using a variety of different schemes
- Aggregate/disaggregate/merge coupon period lists
- Create fixings objects, rate index from currency/coupon/frequency
- String Tenor/Month Code/Work-out
- Standard Treasury Bench-mark off of Maturity
- Module = Product Core Module
- Library = Fixed Income Analytics
- Project = Date, Cash Flow, and Cash Flow Period Measure Generation Utilities
- Package = Assorted Support and Helper Utilities
- Author:
- Lakshmi Krishnamurthy
-
Field Summary
Fields Modifier and Type Field Description static int
LEFT_TENOR_EQUALS
Tenor Comparator - Left Tenor Matches Rightstatic int
LEFT_TENOR_GREATER
Tenor Comparator - Left Tenor Greater than Rightstatic int
LEFT_TENOR_LESSER
Tenor Comparator - Left Tenor Lesser than Right -
Constructor Summary
Constructors Constructor Description Helper()
-
Method Summary
Modifier and Type Method Description static boolean
AccumulateMeasures(CaseInsensitiveTreeMap<java.lang.Double> mapOutput, java.lang.String strPrefix, CaseInsensitiveTreeMap<java.lang.Double> mapInput)
Append the Prefixed Map Entries of the specified Input Map onto the Output Mapstatic java.util.Set<CompositePeriod>
AggregateComponentPeriods(Component[] aComp)
Aggregate the period lists for an array of componentsstatic java.lang.String
AggregateTenor(java.lang.String strBaseTenor, java.lang.String strRollTenor)
Aggregate the Base and the Roll Tenors onto a Composite Tenorstatic java.lang.String
BaseTsyBmk(int iValueDate, int iMaturityDate)
Return the standard on-the-run benchmark treasury string from the valuation and the maturity datesstatic double
BondFuturesPriceAUDBillStyle(JulianDate dtValue, Bond bond, double dblReferenceIndex)
Compute the Bond Futures Price AUD Bill Style from the Reference Index Levelstatic double[]
BumpQuotes(double[] adblQuotesIn, double dblBump, boolean bIsProportional)
Bump the input array quotesstatic java.lang.String
CalcRateIndex(java.lang.String strCouponCurrency, int iCouponFreq)
Calculate the rate index from the coupon currency and the frequencystatic LatentStateFixingsContainer
CreateFixingsObject(Bond bond, JulianDate dtFixing, double dblFixing)
Create the Latent State Fixings object from the bond, the fixings date, and the fixing.static double
DF2Yield(int iFreqIn, double dblDF, double dblTime)
Calculate the yield from the specified discount factor to the given time.static double
DIStylePriceFromRate(double dblDIRate, int iStartDate, int iEndDate, java.lang.String strCalendar)
Compute the DI-Style Price given the Ratestatic double
DIStyleRateFromPrice(double dblDIPrice, int iStartDate, int iEndDate, java.lang.String strCalendar)
Compute the DI-Style Rate given the Pricestatic JulianDate[]
FromTenor(JulianDate dtSpot, java.lang.String[] astrTenor)
Convert the Array of Tenors into Dates off of a Spotstatic java.lang.String
GetDayCountFromBBGCode(java.lang.String strBBGDC)
Get the DRIP day count from the Bloomberg codestatic java.lang.String
GetMonthCodeFromFreq(int iFreq)
Retrieve the month code from input frequencystatic java.lang.String
GetTenorFromFreq(int iFreq)
Retrieve the tenor from the frequencystatic void
Init()
Initialize IR switcher and Bloomberg day count mapsstatic java.lang.String
IntervalHMSMS(long lElapsedNanos)
Converts the Nano-Second Interval into aH:bM:cS:dMS Formatstatic boolean
LabelMatch(LatentStateLabel lslLeft, LatentStateLabel lslRight)
Do the Left and the Right Labels Match?static java.util.List<CompositePeriod>
MergePeriodLists(java.util.List<CompositePeriod> lsPeriod1, java.util.List<CompositePeriod> lsPeriod2)
Merge two lists of periodsstatic double
NominalYieldToPostTaxEquivalent(double dblNominalYield, double dblTaxRate)
Convert the Nominal Yield to the Post Tax Equivalent Yieldstatic double[]
NormalizedEqualWeightedArray(int iNumElement)
Construct a Normalized, Equally Weighted Array from the Specified Number of Elementsstatic double
OISFromLIBORSwapFedFundBasis(double dblLIBORSwapRate, double dblFedFundLIBORSwapBasis)
Compute the uncompounded OIS Rate from the LIBOR Swap Rate and the LIBOR Swap Rate - Fed Fund Basis.static double
OISFromLIBORSwapFedFundBasis2(double dblLIBORSwapRate, double dblFedFundLIBORSwapBasis)
Compute the Daily Compounded OIS Rate from the LIBOR Swap Rate and the LIBOR Swap Rate - Fed Fund Basis.static double[]
ParallelNodeBump(double[] adblNode, double dblBump)
Generate an Array of Bumped Nodesstatic java.lang.String
ParseFromBBGDCCode(java.lang.String strBBGDCCode)
Convert the Bloomberg day count code to DRIP day count code.static double
PostTaxEquivalentYieldToNominal(double dblPostTaxEquivalentYield, double dblTaxRate)
Convert the Post Tax Equivalent Yield to the Nominal Yieldstatic java.lang.String
RateIndexFromCcyAndCouponFreq(java.lang.String strCcy, int iCouponFreq)
Calculate the rate index from currency and coupon frequencystatic JulianDate[]
SpotDateArray(JulianDate dtSpot, int iCount)
Generate an Array of Repeated Spot Datesstatic java.lang.String
SwitchIRCurve(java.lang.String strCurveIn)
Switch the given IR curve if necessarystatic int
TenorCompare(java.lang.String strTenorLeft, java.lang.String strTenorRight)
Compare the Left and the Right Tenorsstatic int[]
TenorToDate(JulianDate dtSpot, java.lang.String[] astrTenor)
Retrieve the Date Array From the Tenor Arraystatic int
TenorToDays(java.lang.String strTenor)
Retrieve the Number of Days from the Tenorstatic int
TenorToFreq(java.lang.String strTenor)
Retrieve the Annual Frequency from the Tenorstatic int
TenorToMonths(java.lang.String strTenor)
Retrieve the Number of Months from the Tenorstatic double
TenorToYearFraction(java.lang.String strTenor)
Retrieve the Year Fraction from the Tenorstatic double[]
TenorToYearFraction(java.lang.String[] astrTenor, boolean bForward)
Retrieve the Year Fraction from the Tenor Arraystatic int
TenorToYears(java.lang.String strTenor)
Retrieve the Number of Years from the Tenorstatic double[]
TweakManifestMeasure(double[] adblQuotesIn, ManifestMeasureTweak ntp)
Tweak the Manifest Measures (gor the given set of nodes) in accordance with the specified tweak parametersstatic java.lang.String
WorkoutTypeToString(int iWOType)
Turn the work out type to stringstatic double
Yield2DF(int iFreqIn, double dblYield, double dblTime)
Calculate the discount factor from the specified frequency, yield, and accrual year fractionMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
LEFT_TENOR_GREATER
public static int LEFT_TENOR_GREATERTenor Comparator - Left Tenor Greater than Right -
LEFT_TENOR_LESSER
public static int LEFT_TENOR_LESSERTenor Comparator - Left Tenor Lesser than Right -
LEFT_TENOR_EQUALS
public static int LEFT_TENOR_EQUALSTenor Comparator - Left Tenor Matches Right
-
-
Constructor Details
-
Helper
public Helper()
-
-
Method Details
-
Init
public static final void Init()Initialize IR switcher and Bloomberg day count maps -
Yield2DF
public static final double Yield2DF(int iFreqIn, double dblYield, double dblTime) throws java.lang.ExceptionCalculate the discount factor from the specified frequency, yield, and accrual year fraction- Parameters:
iFreqIn
- Input frequency - if zero, set to semi-annual.dblYield
- YielddblTime
- Time in DC years- Returns:
- the discount factor
- Throws:
java.lang.Exception
- if input are invalid.
-
DF2Yield
public static final double DF2Yield(int iFreqIn, double dblDF, double dblTime) throws java.lang.ExceptionCalculate the yield from the specified discount factor to the given time.- Parameters:
iFreqIn
- Yield calculation frequency - defaults to semi-annual if zero.dblDF
- Discount FactordblTime
- Time to which the yield/DF are specified- Returns:
- Implied yield
- Throws:
java.lang.Exception
- Thrown if yield cannot be computed
-
OISFromLIBORSwapFedFundBasis
public static final double OISFromLIBORSwapFedFundBasis(double dblLIBORSwapRate, double dblFedFundLIBORSwapBasis) throws java.lang.ExceptionCompute the uncompounded OIS Rate from the LIBOR Swap Rate and the LIBOR Swap Rate - Fed Fund Basis. The calculation is from the following Bloomberg Publication: - Lipman, H. and F. Mercurio (2012): OIS Discounting and Dual-Curve Stripping Methodology at Bloomberg- Parameters:
dblLIBORSwapRate
- LIBOR Swap RatedblFedFundLIBORSwapBasis
- Fed Fund - LIBOR Swap Rate Basis- Returns:
- The Uncompounded OIS Rate
- Throws:
java.lang.Exception
- Thrown if the Inputs are invalid
-
OISFromLIBORSwapFedFundBasis2
public static final double OISFromLIBORSwapFedFundBasis2(double dblLIBORSwapRate, double dblFedFundLIBORSwapBasis) throws java.lang.ExceptionCompute the Daily Compounded OIS Rate from the LIBOR Swap Rate and the LIBOR Swap Rate - Fed Fund Basis. The calculation is from the following Bloomberg Publication: - Lipman, H. and F. Mercurio (2012): OIS Discounting and Dual-Curve Stripping Methodology at Bloomberg- Parameters:
dblLIBORSwapRate
- LIBOR Swap RatedblFedFundLIBORSwapBasis
- Fed Fund - LIBOR Swap Rate Basis- Returns:
- The Daily Compounded OIS Rate
- Throws:
java.lang.Exception
- Thrown if the Inputs are invalid
-
DIStylePriceFromRate
public static final double DIStylePriceFromRate(double dblDIRate, int iStartDate, int iEndDate, java.lang.String strCalendar) throws java.lang.ExceptionCompute the DI-Style Price given the Rate- Parameters:
dblDIRate
- The DI RateiStartDate
- The Start DateiEndDate
- The End DatestrCalendar
- The Calendar- Returns:
- The DI-Style Price
- Throws:
java.lang.Exception
- Thrown if the DI-Style Price cannot be calculated
-
DIStyleRateFromPrice
public static final double DIStyleRateFromPrice(double dblDIPrice, int iStartDate, int iEndDate, java.lang.String strCalendar) throws java.lang.ExceptionCompute the DI-Style Rate given the Price- Parameters:
dblDIPrice
- The DI PriceiStartDate
- The Start DateiEndDate
- The End DatestrCalendar
- The Calendar- Returns:
- The DI-Style Rate
- Throws:
java.lang.Exception
- Thrown if the DI-Style Price cannot be calculated
-
NominalYieldToPostTaxEquivalent
public static final double NominalYieldToPostTaxEquivalent(double dblNominalYield, double dblTaxRate) throws java.lang.ExceptionConvert the Nominal Yield to the Post Tax Equivalent Yield- Parameters:
dblNominalYield
- The Nominal YielddblTaxRate
- The Tax Rate- Returns:
- The Post Tax Equivalent Yield
- Throws:
java.lang.Exception
- Thrown if the Inputs are Invalid
-
PostTaxEquivalentYieldToNominal
public static final double PostTaxEquivalentYieldToNominal(double dblPostTaxEquivalentYield, double dblTaxRate) throws java.lang.ExceptionConvert the Post Tax Equivalent Yield to the Nominal Yield- Parameters:
dblPostTaxEquivalentYield
- The Post Tax Equivalent YielddblTaxRate
- The Tax Rate- Returns:
- The Nominal Yield
- Throws:
java.lang.Exception
- Thrown if the Inputs are Invalid
-
BaseTsyBmk
public static final java.lang.String BaseTsyBmk(int iValueDate, int iMaturityDate)Return the standard on-the-run benchmark treasury string from the valuation and the maturity dates- Parameters:
iValueDate
- the Valuation dateiMaturityDate
- the Maturity date- Returns:
- the standard on-the-run benchmark treasury string
-
WorkoutTypeToString
public static final java.lang.String WorkoutTypeToString(int iWOType)Turn the work out type to string- Parameters:
iWOType
- One of the WO_TYPE_* fields in the WorkoutInfo class- Returns:
- String representation of the work out type field
-
ParseFromBBGDCCode
public static final java.lang.String ParseFromBBGDCCode(java.lang.String strBBGDCCode)Convert the Bloomberg day count code to DRIP day count code.- Parameters:
strBBGDCCode
- String representing the Bloomberg day count code.- Returns:
- String representing the DRIP day count code.
-
GetTenorFromFreq
public static final java.lang.String GetTenorFromFreq(int iFreq)Retrieve the tenor from the frequency- Parameters:
iFreq
- Integer frequency- Returns:
- String representing the tenor
-
TenorToYears
public static final int TenorToYears(java.lang.String strTenor) throws java.lang.ExceptionRetrieve the Number of Years from the Tenor- Parameters:
strTenor
- The Specified Tenor- Returns:
- The Number of Years
- Throws:
java.lang.Exception
- Thrown if the Inputs are Invalid
-
TenorToMonths
public static final int TenorToMonths(java.lang.String strTenor) throws java.lang.ExceptionRetrieve the Number of Months from the Tenor- Parameters:
strTenor
- The Specified Tenor- Returns:
- The Number of Months
- Throws:
java.lang.Exception
- Thrown if the Inputs are Invalid
-
TenorToDays
public static final int TenorToDays(java.lang.String strTenor) throws java.lang.ExceptionRetrieve the Number of Days from the Tenor- Parameters:
strTenor
- The Specified Tenor- Returns:
- The Number of Days
- Throws:
java.lang.Exception
- Thrown if the Inputs are Invalid
-
TenorToYearFraction
public static final double TenorToYearFraction(java.lang.String strTenor) throws java.lang.ExceptionRetrieve the Year Fraction from the Tenor- Parameters:
strTenor
- The Specified Tenor- Returns:
- The Year Fraction
- Throws:
java.lang.Exception
- Thrown if the Inputs are Invalid
-
TenorToYearFraction
public static final double[] TenorToYearFraction(java.lang.String[] astrTenor, boolean bForward) throws java.lang.ExceptionRetrieve the Year Fraction from the Tenor Array- Parameters:
astrTenor
- The Specified Tenor ArraybForward
- TRUE - Generated the Incremental Forward Year Fraction- Returns:
- The Year Fraction Array
- Throws:
java.lang.Exception
- Thrown if the Inputs are Invalid
-
TenorToFreq
public static final int TenorToFreq(java.lang.String strTenor) throws java.lang.ExceptionRetrieve the Annual Frequency from the Tenor- Parameters:
strTenor
- The Specified Tenor- Returns:
- The Annual Frequency
- Throws:
java.lang.Exception
- Thrown if the Inputs are Invalid
-
TenorToDate
Retrieve the Date Array From the Tenor Array- Parameters:
dtSpot
- The Spot Date ArrayastrTenor
- The Specified Tenor Array- Returns:
- The Date Array From the Tenor Array
-
TenorCompare
public static final int TenorCompare(java.lang.String strTenorLeft, java.lang.String strTenorRight) throws java.lang.ExceptionCompare the Left and the Right Tenors- Parameters:
strTenorLeft
- Left TenorstrTenorRight
- Right Tenor- Returns:
- Results of the Comparison
- Throws:
java.lang.Exception
- Thrown if the Comparison cannot be done
-
GetMonthCodeFromFreq
public static final java.lang.String GetMonthCodeFromFreq(int iFreq)Retrieve the month code from input frequency- Parameters:
iFreq
- Integer frequency- Returns:
- String representing the month code
-
CalcRateIndex
public static final java.lang.String CalcRateIndex(java.lang.String strCouponCurrency, int iCouponFreq)Calculate the rate index from the coupon currency and the frequency- Parameters:
strCouponCurrency
- String representing the coupon currencyiCouponFreq
- Integer representing the coupon frequency- Returns:
- String representing the rate index
-
GetDayCountFromBBGCode
public static final java.lang.String GetDayCountFromBBGCode(java.lang.String strBBGDC)Get the DRIP day count from the Bloomberg code- Parameters:
strBBGDC
- String representing the Bloomberg day count convention- Returns:
- String representing DRIP day count
-
RateIndexFromCcyAndCouponFreq
public static final java.lang.String RateIndexFromCcyAndCouponFreq(java.lang.String strCcy, int iCouponFreq)Calculate the rate index from currency and coupon frequency- Parameters:
strCcy
- String representing coupon currencyiCouponFreq
- Integer representing coupon frequency- Returns:
- String representing the rate index
-
SwitchIRCurve
public static final java.lang.String SwitchIRCurve(java.lang.String strCurveIn)Switch the given IR curve if necessary- Parameters:
strCurveIn
- String representing the input curve- Returns:
- String representing the switched curve
-
CreateFixingsObject
public static final LatentStateFixingsContainer CreateFixingsObject(Bond bond, JulianDate dtFixing, double dblFixing)Create the Latent State Fixings object from the bond, the fixings date, and the fixing.- Parameters:
bond
- The input bonddtFixing
- The Fixings DatedblFixing
- Double representing the fixing- Returns:
- The Latent State Fixings Instance
-
BumpQuotes
public static final double[] BumpQuotes(double[] adblQuotesIn, double dblBump, boolean bIsProportional)Bump the input array quotes- Parameters:
adblQuotesIn
- Array of the input double quotesdblBump
- Bump amountbIsProportional
- True - Bump is proportional- Returns:
- Bumped array output
-
TweakManifestMeasure
Tweak the Manifest Measures (gor the given set of nodes) in accordance with the specified tweak parameters- Parameters:
adblQuotesIn
- Array of quotes to be bumpedntp
- NodeTweakParams input- Returns:
- Bumped array output
-
MergePeriodLists
public static final java.util.List<CompositePeriod> MergePeriodLists(java.util.List<CompositePeriod> lsPeriod1, java.util.List<CompositePeriod> lsPeriod2)Merge two lists of periods- Parameters:
lsPeriod1
- Period 1lsPeriod2
- Period 2- Returns:
- The Merged Period List
-
AggregateComponentPeriods
Aggregate the period lists for an array of components- Parameters:
aComp
- Array of Components- Returns:
- The Aggregated Period Set
-
AccumulateMeasures
public static final boolean AccumulateMeasures(CaseInsensitiveTreeMap<java.lang.Double> mapOutput, java.lang.String strPrefix, CaseInsensitiveTreeMap<java.lang.Double> mapInput)Append the Prefixed Map Entries of the specified Input Map onto the Output Map- Parameters:
mapOutput
- The Output MapstrPrefix
- The Entry PrefixmapInput
- The Input Map- Returns:
- TRUE - At least one entry appended
-
LabelMatch
Do the Left and the Right Labels Match?- Parameters:
lslLeft
- Left Cash Flow Period LabellslRight
- Right Cash Flow Period Label- Returns:
- TRUE - The Labels Match
-
BondFuturesPriceAUDBillStyle
public static final double BondFuturesPriceAUDBillStyle(JulianDate dtValue, Bond bond, double dblReferenceIndex) throws java.lang.ExceptionCompute the Bond Futures Price AUD Bill Style from the Reference Index Level- Parameters:
dtValue
- The Valuation Datebond
- The Bond InstancedblReferenceIndex
- The Reference Index- Returns:
- The Bond Futures Price AUD Bill Style
- Throws:
java.lang.Exception
- Thrown if the Bond Futures Price AUD Bill Style cannot be computed
-
NormalizedEqualWeightedArray
public static final double[] NormalizedEqualWeightedArray(int iNumElement)Construct a Normalized, Equally Weighted Array from the Specified Number of Elements- Parameters:
iNumElement
- Number of Elements- Returns:
- The Normalized, Equally Weighted Array
-
AggregateTenor
public static final java.lang.String AggregateTenor(java.lang.String strBaseTenor, java.lang.String strRollTenor)Aggregate the Base and the Roll Tenors onto a Composite Tenor- Parameters:
strBaseTenor
- The Base TenorstrRollTenor
- The Roll Tenor- Returns:
- The Agrregated Composite Tenor
-
FromTenor
Convert the Array of Tenors into Dates off of a Spot- Parameters:
dtSpot
- Spot DateastrTenor
- Array of Tenors- Returns:
- Array of Dates
-
SpotDateArray
Generate an Array of Repeated Spot Dates- Parameters:
dtSpot
- Spot DateiCount
- Repeat Count- Returns:
- Array of the Repeated Spot Dates
-
ParallelNodeBump
public static final double[] ParallelNodeBump(double[] adblNode, double dblBump)Generate an Array of Bumped Nodes- Parameters:
adblNode
- Array of Unbumped NodesdblBump
- Bump Amount- Returns:
- Array of Bumped Nodes
-
IntervalHMSMS
public static final java.lang.String IntervalHMSMS(long lElapsedNanos)Converts the Nano-Second Interval into aH:bM:cS:dMS Format- Parameters:
lElapsedNanos
- The Elapsed Nano Time- Returns:
- The Nano-Second Interval in the aH:bM:cS:dMS Format
-