A JSON / JavaScript financial risk and pricing library
Here are three reasons for using a financial risk and pricing library in JavaScript.
JSON.parse
and JSON.stingify
functions, making any parsing and serialization logic obsolete for most applications. var JsonRisk=require('path/to/json_risk.js');
<script src="path/to/json_risk.min.js"></script>
var bond= {
maturity: new Date(2028,0,1), //final maturity of the bond
notional: 100.0, //notional
fixed_rate: 0.05, //interest rate 5%
tenor: 12, //yearly interest payments
bdc: "following", //business day convention
dcc: "act/act", //day count convention
calendar: "TARGET" //holiday calendar
};
var discount_curve={
labels: ["1Y", "2Y", "3Y", "10Y"], //times encoded as labels
zcs: [0.01, 0.02, 0.025, 0.1] //zero-coupon rates act/365 annual compounding
};
var spread_curve={
labels: ["1Y", "2Y", "3Y", "10Y"], //times encoded as labels
zcs: [0.01, 0.011, 0.012, 0.11] //zero-coupon rates act/365 annual compounding
};
JsonRisk.valuation_date=new Date(2019,11,31); //as-of date for calculation
var present_value=JsonRisk.pricer_bond(bond,discount_curve, spread_curve);
See the documentation for details and examples.
JSON Risk supports the instrument types below:
Callable bond pricing is implemented with a Linear Gauss Markov (or, equivalently, Hull-White) model in the spirit of Hagan, Patrick; EVALUATING AND HEDGING EXOTIC SWAP INSTRUMENTS VIA LGM (2019).
JSON Risk supports the day count conventions
JSON Risk supports the business day conventions
JSON Risk supports one built-in calendar (TARGET) as of now.
Adding custom calendars is as simple as
var holidays = [
new Date(2018,11,1), //javascript date object
"2018/12/12", //valid YYYY/MM/DD date string
"2019-12-01", //valid YYYY/MM/DD date string
"01.12.2020" //valid DD.MM.YYYY date string
];
JsonRisk.add_calendar("CUSTOM", holidays);
Saturdays and Sundays are considered holidays in all custom calendars.
This project is maintained by