Interest Rate Gap Implementation

Overview


Basic Implementation


Implementing a basic gap analysis is fairly straightforward.

First, define a set of buckets. THis code uses the calendar library.


let cr = await import('/lib/calendar/v1.0.0/calendar.mjs');

let today = '2020-01-01';
let buckets = [cr.addMonths(today, 3),cr.addMonths(today, 6),cr.addMonths(today, 12),cr.addMonths(today, 24),cr.addMonths(today, 12*5),cr.addMonths(today, 12*30)]
					


Next, the $group api is used to group each asset by its date bucket.


let gaps = $group(assets, p=>{
  for(let i=0;i<buckets.length-1;i++){
    let date = buckets[i];
    let next = buckets[i+1];
    if(p.maturity >= date && p.maturity <= next) return next;
  }
})();
					
Try it!

Contents