JSON Risk supports the parameter types below:
A Parameter set stores the parameters above along with scenarios. Parameters and scenarios are described in this document. The JSON representation of a parameter set contains the fields below
The tags field is supported by all parameter types and is used for matching scenarios with params. It is an Array of strings.
Fields:
Number)Example:
{
type: "scalar",
value: 1.038
}
Fields:
String, SHOULD be "yield")Numbers) Note: If times are not provided, but optional days, dates or labels are provided, times are reconstructed from days (preferrably), dates (if days are not given) or labels (if neither times, days ot dates are given)Numbers) Note: If discount factors are not provided, but optional zero coupon rates are, then discount factors are calculated from zero coupon ratesOptional:
Date, first date must correspond to valuation date)Period string values)Number)String, must be "linear_zc" for linear interpolation on zero coupon rates, "linear_rt" for raw interpolation, or "linear_df" for linear interpolation on discount factors, or "bessel" or "hermite", both referring to Bessel-Hermite cubic spline interpolation. Linear on discounts is the default. All these options are case insensitive.)String, must be "a" or "annual" for annual compounding, or "c" or "continuous" for continuous compounding, all case insensitive.)Boolean flag indicating if extrapolation on the short end should be flat on zero rates instead of being implied by the interpolation method, defaults to true. When interpolation is linear on discounts or raw, extrapolation is always flat. )Boolean flag indicating if extrapolation on the long end should be flat on zero rates instead of being implied by the interpolation method, defaults to true. When interpolation is linear on discounts or raw, extrapolation is always flat.)Axis arrays must be sorted by times in ascending order
Example with times and discount factors:
{
type: "yield",
times: [1.0, 2.0, 10.0],
dfs: [1.0003, 0.99994, 0.9992]
}
Example with days and discount factors:
{
type: "yield",
days: [365, 730, 3650],
dfs: [1.0003, 0.99994, 0.9992]
}
Example with dates and discount factors:
{
type: "yield",
dates: ["2019/01/01", "2020/01/01", "2021/01/01", "2030/01/01"],
dfs: [1, 1.0003, 0.99994, 0.9992]
}
Example with labels and zero coupon rates:
{
type: "yield",
labels: ["1Y", "2Y", "10Y"],
zcs: [-0.00023, 0.00001, 0.0045]
}
Example with interpolation, extrapolation and continuous compounding:
{
type: "yield",
times: [1.0, 2.0, 10.0],
zcs: [-0.00023, 0.00001, 0.0045],
compounding: "c",
intp: "bessel",
short_end_flat: true,
long_end_flat: false
}
This surface is used for the valuation of swaptions.
Fields:
String, SHOULD be "expiry_term")Numbers) Note: If expiries are not provided, but optional labels_expiry are provided, expiries are reconstructed from labels_expiryNumbers) Note: If terms are not provided, but optional labels_expiry are provided, terms are reconstructed from labels_expiryNumbers)Optional:
Period string values)Period string values)Axis arrays must be sorted by times (expiry, term) in ascending order
Example with expiries and terms:
{
type: "expiry_term",
expiries: [1.0, 2.0, 5.0],
terms: [0.5, 1.0],
values: [
[0.002, 0.003],
[0.0021, 0.0032],
[0.0025, 0.0035],
]
}
Example with labels:
{
type: "expiry_term",
labels_expiry: ["1Y", "2Y", "5Y"],
labels_term: ["6M", "1Y"],
values: [
[0.002, 0.003],
[0.0021, 0.0032],
[0.0025, 0.0035],
]
}
This surface is used for the valuation of caplets and floorlets as well as stock and index options. The type determines if moneyness is parametrised as relative or absolute strikes.
Fields:
String, MUST be "expiry_rel_strike" or "expiry_abs_strike")Numbers) Note: If expiries are not provided, but optional labels_expiry are provided, expiries are reconstructed from labels_expiryNumbers)Numbers)Optional:
Period string values)Axis arrays must be sorted by times (expiry) and moneyness in ascending order
Example with expiries and relative strikes:
{
type: "expiry_rel_strike",
expiries: [1.0, 2.0, 5.0],
moneyness: [-0.01, -0.005, 0.0, 0.005, 0.001],
values: [
[0.002, 0.003, 0.004, 0.004],
[0.0021, 0.0032, 0.0043, 0.0045],
[0.0025, 0.0035, 0.0044, 0.0045],
]
}
Example with labels and absolute strikes:
{
type: "expiry_abs_strike",
labels_expiry: ["1Y", "2Y", "5Y"],
moneyness: [90.0, 95.0, 100.0, 105.0, 110.0],
values: [
[0.002, 0.003, 0.004, 0.004],
[0.0021, 0.0032, 0.0043, 0.0045],
[0.0025, 0.0035, 0.0044, 0.0045],
]
}
Calendars are stored as objects. The keys are the names of each calendar, and the corresponding value must be a list of holidays, e.g., an Array of Date instances. An example:
{
"EXAMPLE_CALENDAR1": [
"2025/01/01",
"2026/01/01",
"2027/01/01",
"2028/01/01",
"2029/01/01",
],
"EXAMPLE_CALENDAR2": [
"2025/05/01",
"2026/05/01",
"2027/05/01",
"2028/05/01",
"2029/05/01",
],
}
A scenario group must have a name that consists of letters, numbers, dashes and underscores only. A scenario group consists of one or more scenarios. A single scenario consists of a name and one or more rules. The rules are used to determine the risk factors (i.e., parameters) to which the scenarios should be applied and what shock to apply.
Here is an outline of the structure of a scenario:
Find below an example of a scenario group in JSON format.
[
{
"name": "EXAMPLE_SCENARIO",
"rules": [
{
"model": "additive",
"labels_x": [
"1W",
"3M"
],
"labels_y": [
"1M"
],
"values": [
[
0.0001,
0
]
],
"risk_factors": [
"TEST"
],
"tags": [
"yield"
],
},
{ /* more rules */ }
]
},
{ /* more scenarios */ }
] JSON risk is published under the MIT License.
This project is maintained by