JSON Risk supports the parameter types below:
Fields:
Regular example:
{
type: "FX",
value: [1.038]
}
Vector pricing example with three scenarios:
{
type: "FX",
value: [1.038, 1.045, 0.9934]
}
Fields:
Optional:
Date
, first date must correspond to valuation date)Period string
values)All arrays must be sorted by times in ascending order
Example with times and discount factors:
{
type: "yield",
days: [1, 2, 10],
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]
}
Vector pricing example with four scenarios:
{
type: "yield",
days: [1, 2, 10],
dfs: [
[-0.00023, 0.00001, 0.0045],
[-0.00024, 0.00001, 0.0045],
[-0.00023, 0.00002, 0.0045],
[-0.00023, 0.00001, 0.0046]
]
}
Fields:
Optional:
Period string
values)Period string
values)All arrays must be sorted by times (expiry, term) in ascending order
Example with three expiries and two terms:
{
type: "swaption",
expiries: [1, 2, 5],
terms: [0.5, 1],
values: [
[0.002, 0.003],
[0.0021, 0.0032],
[0.0025, 0.0035],
]
}
Equivalent example with labels:
{
type: "swaption",
labels_expiry: ["1Y", "2Y", "5Y"],
labels_term: ["6M", "1Y"],
values: [
[0.002, 0.003],
[0.0021, 0.0032],
[0.0025, 0.0035],
]
}
Vector pricing example with two scenarios:
{
type: "swaption",
expiries: [1, 2, 5],
terms: [0.5, 1],
values: [
[
[0.002, 0.003],
[0.0021, 0.0032],
[0.0025, 0.0035],
],
[
[0.0025, 0.0035],
[0.0026, 0.0037],
[0.0030, 0.0040],
]
]
}
JSON risk interprets zero coupon rates with the convention act/365
and annual compounding. That is, discount factors are calculated with the formula
dfs[i]=Math.pow(1 + zcs[i], -times[i])
when converting from zero coupon rates.
Internally, JSON risk always calculates with times. Times represent years. JSON risk converts
365
, consistent with the act/365
day count conventionact/365
day count convention12
, weekly values by 52
and daily values by 365
, consistent with the act/365
day count convention. Yearly values are not further converted, e.g., the period string "1Y"
just represents one.When delivering yield curve or surface data from a source system, the easiest way to achieve maximum accuracy is to supply days and either discount factors or zero coupon rates with the convention act/365
and annual compounding. Correct delivery of times or dates achieves the same accuracy. Labels can also achieve maximum accuracy if delivered as exact daily labels. For example, if a yield curve has a two-day spot offset, the one-year value could actually correspond to 367 days. In that case delivering the label "367D"
instead "1Y"
yields exact results. Delivering "1Y"
means pricing only approximately in that case.
JSON risk is published under the MIT License.
Library
Minified Library
App (.tar.gz)
App (.tar.bz2)
App (.zip)
This project is maintained by