FpML Issues Tracker
closed
Minor
Always
Validation Rules
Admin
None
Summary
ird-10 contains some ambiguity that requires clarification.
The rule today is: " ird-10 (Mandatory) Context: CalculationPeriodDates (complex type) [isParametric] [calculationPeriodFrequency/rollConvention is a number] If firstRegularPeriodStartDate exists, then the start date is firstRegularPeriodStartDate, else the start date is effectiveDate/unadjustedDate. If calculationPeriodFrequency/rollConvention is less than or equal to the last day of the month in the start date, then the day of the start date must match it, else the day of the start date must be the last day of the month of that date. "
Areas for improvement: 1. The word "else" should probably be "or". If either is satisfied then the result is true. 2. "must match it" - what is "it"? Is it "calculationPeriodFrequency/rollConvention"? Please give the correct XPath for the value. 3. "that date" - what is "that"? Please give the correct XPath for the value.
Notes:
matthewdr
10/21/08 1:34 pm
Agreed at the VWG for ISDA to seek Harry’s guidance.
mgratacos
10/21/08 1:36 pm
Ask Harry to get input on how to rewrite the rule.
andrew
10/22/08 2:07 pm
If we define four functions:
defaultedNode (value-node,default-node) that returns the value-node if it exists otherwise returns the default-node
dayOfMonth(date) that returns the day of the month component of any date value (e.g. dayOfMonth(2008-10-22) == 22)
monthEndDate(date) that returns the date of the last day in the month that provided date falls in (e.g. monthEndDate(2008-10-22) == 2008-10-31.
min(integer x,integer y) returns x if x is less than y otherwise y.
And data type casting operators date (node), integer (node)
Then the test portion of ird-10 can be expressed as:
dayOfMonth (
date (
defaultedNode (firstRegularPeriodStartDate, effectiveDate/unadjustedDate)))
== min (
integer (calculationPeriodFrequency/rollConvention),
dayOfMonth (
monthEndDate (
date (
defaultedNode (firstRegularPeriodStartDate, effectiveDate/unadjustedDate)))))
Conversion into XQuery is left as an exercise for the implementor.
matthewdr
10/22/08 3:20 pm
### ‘day-from-date’ ####
There is a predefined function in XPath named ‘day-from-date’ that will extract the day portion from a date. This avoids us having to define our own function.
Example XPath: day-from-date(xs:date(‘2006-08-15’))
Example Result: 15
See: http://www.w3.org/TR/xpath-functions/#func-day-from-date
### ‘last-day-of-month’ ###
There is a predefined function in the functx library that will extract the last day of the month. This avoids us having to define our own function, because we can reference this function, or at least copy the definition.
Example XPath: functx:last-day-of-month(xs:date(‘2004-01-23’))
Example Result: 2004-01-31
See: http://www.xqueryfunctions.com/xq/functx_last-day-of-month.html
### defaulted node ###
This can be written out in bog standard XPath syntax without needing a function. Extract the first element by using the “[1]” syntax. This saves writing out a function.
Example Document:Hello!
Example XPath 1: (root, “Goodbye”)[1]
Example Result 1: Hello!
Example XPath 2: (start, “Goodbye”)[1]
Example Result 2: Goodbye!
NB The proposal contains “==” which is undefined in the FpML Validation Architecture. It is assumed to be equivalent to the XPath “eq” rather than “is”. According to the FpML Validation Architecture this is written out as “=”.
### Solution ###
dayFromDate((firstRegularPeriodStartDate, effectiveDate/unadjustedDate)[1]) = min(calculationPeriodFrequency/rollConvention, dayFromDate(functx:last-day-of-month((firstRegularPeriodStartDate, effectiveDate/unadjustedDate)[1])))
matthewdr
12/09/08 3:47 pm
The VWG asked for the natural language English version. That is below. This now completes the solution, which may be implemented.
ird-10 (Mandatory)
Context: CalculationPeriodDates (complex type)
The first day is the day of the month from firstRegularPeriodStartDate if it exists, otherwise from effectiveDate/unadjustedDate. The second day is the lesser of the rollConvention, and the firstRegularPeriodStartDate if it exist or the effectiveDate/unadjustedDate if it doesn’t. The first day must equal the second day.
lyteck
12/09/08 8:04 pm
The Valwg agreed to implement Matthew’s formal solution, and also agreed that English description needs to be revisited.
lyteck
12/09/08 8:04 pm
implemented both Formal and English description as proposed.
matthewdr
12/10/08 10:22 am
Tested, passed, closed.