-
Notifications
You must be signed in to change notification settings - Fork 32
CDM functions that require custom implementations
This page contains CDM functions that have Java implementations, and discusses what new DSL syntax would be required to migrate to functions expressed only in Rosetta. It is not an exhaustive (or comprehensive or up-to-date) list of functions with Java implementations.
Generates a result vector by applying the supplied arithmetic operation to each element of the supplied left and right vectors in turn. i.e. result[n] = left[n] right[n], where is the arithmetic operation defined by ArithmeticOperationEnum.
// Requires DSL get-item(index)
func VectorOperation:
inputs:
arithmeticOp ArithmeticOperationEnum (1..1)
left number (0..*)
right number (0..*)
output:
result number (0..*)
Generates a result vector by starting with the supplied base value (typically 1), and then multiplying it in turn by each growth factor, which is typically a number just above 1. For instance, a growth factor of 1.1 represents a 10% increase, and 0.9 a 10% decrease. The results will show the successive results of applying the successive growth factors, with the first value of the list being the supplied baseValue, and final value of the results list being the product of all of the supplied values. i.e. result[1] = baseValue * factor[1], result[n] = result[n-1] * factor[n]. The resulting list will have the one more element than the supplied list of factors.
// Requires DSL get-item(index)
func VectorGrowthOperation:
inputs:
baseValue number (1..1)
factor number (0..*)
output:
result number (0..*)
// Requires DSL remove-item(index)
func PopOffDateList:
inputs:
dates date (0..*)
output:
newList date (0..*)
func UpdateAmountForEachQuantity: <"Updates all quantities on each price quantity with the new amount.">
inputs:
priceQuantity PriceQuantity (0..*) <"List of price quantities to update.">
amount number (1..1) <"The new amount.">
output:
updatedPriceQuantity PriceQuantity (0..*) <"List of price quantities with all quantity amounts updated.">
func UpdateAmountForEachMatchingQuantity: <"Updates any quantity from the list of new quantities if the unit of amount matches.">
inputs:
priceQuantity PriceQuantity (1..*) <"List of price quantities to update.">
change PriceQuantity (1..*)
direction QuantityChangeDirectionEnum (1..1)
output:
updatedPriceQuantity PriceQuantity (1..*) <"List of price quantities with quantity amounts updated.">
condition: direction <> QuantityChangeDirectionEnum -> Increase
// Require DSL changes to prevent overwriting of reference metadata (not supported in DSL)
// Access to reference metadata (not supported in DSL)
func FpmlIrd8: <"FpML validation rule ird-8 - If the same party is specified as the payer and receiver, then different accounts must be specified.">
inputs:
tradableProduct TradableProduct (1..1)
accounts Account (0..*)
output:
success boolean (1..1) <"Validation result">
func RoundToNearest:
inputs:
value number (1..1)
nearest number (1..1)
roundingMode RoundingModeEnum (1..1)
output:
roundedValue number (1..1)
condition: nearest > 0
func RoundToPrecision: <"Round a rate to the supplied precision, using the supplied rounding direction">
inputs:
value number (1..1) <"The original (unrounded) number.">
precision int (1..1) <"The number of decimal digits of precision.">
roundingMode RoundingDirectionEnum (1..1) <"The method of rounding (up/down/nearest).">
output:
roundedValue number (1..1) <"The value to the desired precision">
condition: precision >= 0
func Now: <"Current date time.">
output: now zonedDateTime (1..1)
func Today: <"Current date.">
output: today date (1..1)
func AddDays: <"Adds the specified number of calendar days to the supplied date. A negative number will generate a date before the supplied date.">
inputs:
inputDate date (1..1) <"The base date for the calculation.">
numDays int (1..1) <"The number of days to add.">
output:
resultDate date (1..1) <"The date shifted by the specified number of days.">
func DateDifference: <"Subtracts the two supplied dates to return the number of calendar days between them. A negative number implies first is after second.">
inputs:
firstDate date (1..1) <"The earlier date.">
secondDate date (1..1) <"The later date.">
output:
difference int (1..1) <"The number of calendar days second date is after firstDate. Negative means secondDate is before firstDate.">
func LeapYearDateDifference: <"Subtracts the two supplied dates to return the number of leap year calendar days between them. A negative number implies firstDate is after secondDate.">
inputs:
firstDate date (1..1) <"The left side of the subtraction.">
secondDate date (1..1) <"The right side of the subtraction.">
output:
difference int (1..1) <"The number of leap year calendar days secondDate is after firstDate. Negative means secondDate is before firstDate.">
func DayOfWeek: <"Returns the day of week corresponding to the supplied date.">
inputs:
date date (1..1) <"The date for which the weekday is needed.">
output:
dayOfWeek DayOfWeekEnum (1..1) <"The day of the week as an enumerated value.">
func CalculationPeriodRange:
inputs:
startDate date (0..1) // should be AdjustableOrRelativeDate
endDate date (0..1) // should be AdjustableOrRelativeDate
dateAdjustments BusinessDayAdjustments (0..1)
output:
result CalculationPeriodData (1..1)
func CalculationPeriod: <"2006 ISDA Definition Section 4.13. 'Calculation Period' means, in respect of a Swap Transaction and a party, each period from, and including, one Period End Date of that party to, but excluding, the next following applicable Period End Date during the Term of the Swap Transaction, except that (a) the initial Calculation Period for the party will commence on, and include, the Effective Date and (b) the final Calculation Period for the party will end on, but exclude, the Termination Date.">
inputs:
calculationPeriodDates CalculationPeriodDates (1..1)
date date (1..1)
output:
result CalculationPeriodData (1..1)
func CalculationPeriods: <"2006 ISDA Definition Section 4.13. 'Calculation Period' means, in respect of a Swap Transaction and a party, each period from, and including, one Period End Date of that party to, but excluding, the next following applicable Period End Date during the Term of the Swap Transaction, except that (a) the initial Calculation Period for the party will commence on, and include, the Effective Date and (b) the final Calculation Period for the party will end on, but exclude, the Termination Date.">
inputs:
calculationPeriodDates CalculationPeriodDates (1..1)
output:
result CalculationPeriodData (0..*)
// Data providers (external data)
func BusinessCenterHolidays:
// data provider - implementation provides dates from data source
inputs:
businessCenter BusinessCenterEnum (1..1)
output:
holidayDates date (0..*)
func IndexValueObservation: <"Retrieve the values of the supplied index on the specified observation date.">
// data provider - implementation provides observed value from data source
inputs:
observationDate date (1..1)
floatingRateOption FloatingRateOption (1..1)
output:
observedValue number (1..1)