The DSB Tenor Calculator tool is a standalone Javascript utility that developers can use to calculate the Tenor value of an instrument, given the Effective Date, and Expiry Date of an instrument. See DSB Term of Contract FAQ and ESMA Reference Data FAQ for more details.
To use the javascript utility in browser applications, download the browserified javascript - tenor-calculator.min.js and include in the HTML, eg:
<script src="tenor-calculator.min.js"></script>
This will create a global variable TenorCalculator
, with one method calculateTenor
that you can call in your code, like this:
var tenor = TenorCalculator.calculateTenor('2019-01-01', '2019-01-03');
To use the javascript utility in nodeJS applications, download the source file tenor-calculator.js and import as:
const TenorCalculator = require('./lib/tenor-calculator.js')
const EXPIRY_DATE_ADJUSTED = false; // only unadjusted expiry date is supported for now
let effectiveDate = '2019-02-04';
let expiryDate = '2019-02-07';
let esmaTenor = TenorCalculator.calculateTenor(effectiveDate, expiryDate, END_DATE_ADJUSTED);
This will return a JSON object with properties value
, unit
and basis
, eg:
{
'value': 3
'unit': 'DAYS',
'basis': 'Whole Weeks"
}
See sample/index.html for a sample HTML implementation of the tenor calculator javascript utility which you can play around with.
See links below for a more detailed documentation on how the Tenor Calculator works.