bondPricer

Syntax

bondPricer(instrument, pricingDate, discountCurve, [spreadCurve], [setting])

Details

Prices a bond instrument, supporting output of multiple risk measures, including (NPV (Net Present Value), Delta (first-order sensitivity), Gamma (second-order sensitivity), and Key Rate Duration (sensitivity to interest rate shifts at specified key maturities).

Return value:

  • If setting is not specified, returns the NPV (a DOUBLE scalar).

  • If setting is specified, returns a Dictionary<STRING, ANY> with the following key-value pairs:

    • "npv": A DOUBLE scalar

    • "discountCurveDelta": A DOUBLE scalar

    • "discountCurveGamma": A DOUBLE scalar

    • "discountCurveKeyRateDuration": A DOUBLE vector

Arguments

instrument is an INSTRCMENT object representing the bond to be priced. The required key fields vary depending on the type of bond product; see Bond Product Field Specifications for details.

pricingDate is a DATE scalar specifying the pricing date.

discountCurve is a MKTDATA object of type IrYieldCurve representing the discount curve. See Curve Field Specifications for details.

spreadCurve (optional) is a MKTDATA object of type IrYieldCurve representing the credit spread curve. If not specified, defaults to a flat curve with 0% spread. See Curve Field Specifications for details.

setting (optional)is a Dictionary<STRING, ANY> with the following key-value pairs:

Key Value Type Description
"calcDiscountCurveDelta" BOOL Whether to compute the bond’s first-order sensitivity (delta) to the discount curve.
"calcDiscountCurveGamma" BOOL Whether to compute the bond’s second-order sensitivity (gamma) to the discount curve.
"calcDiscountCurveKeyRateDuration" BOOL Whether to compute the bond’s key rate durations.
"discountCurveShift" DOUBLE scalar The parallel shift applied to the discount curve. For example, a bp(0.0001).
"discountCurveKeyTerms" DOUBLE scalar/vector The specific maturity point(s) to calculate the key rate duration. For example, [1.0, 3.0, 5.0].
"discountCurveKeyShifts" DOUBLE scalar/vector The shift amounts corresponding to each maturity point. It has the same length with discountCurveKeyTerms. For example, [0.0001, 0.0002, 0.0015].

Examples

bond  = {
    "productType": "Cash",
    "assetType": "Bond",
    "bondType": "FixedRateBond",
    "version": 0, 
    "instrumentId": "240025.IB",
    "start": 2024.12.25,
    "maturity": 2031.12.25,
    "issuePrice": 100.0,
    "coupon": 0.0149,
    "frequency": "Annual",
    "dayCountConvention": "ActualActualISDA"
}

pricingDate = 2025.08.18

curve = {
    "mktDataType": "Curve",
    "curveType": "IrYieldCurve",
    "referenceDate": pricingDate,
    "currency": "CNY",
    "curveName": "CNY_TREASURY_BOND",
    "dayCountConvention": "ActualActualISDA",
    "compounding": "Compounded",
    "interpMethod": "Linear",
    "extrapMethod": "Flat",
    "frequency": "Annual",
    "dates":[2025.09.18, 2025.11.18, 2026.02.18, 2026.08.18, 2027.08.18, 2028.08.18, 2030.08.18,
             2032.08.18, 2035.08.18, 2040.08.18, 2045.08.18, 2055.08.18,2065.08.18, 2075.08.18],
    "values":[1.3000, 1.3700, 1.3898, 1.3865, 1.4299, 1.4471, 1.6401,
              1.7654, 1.7966, 1.9930, 2.1834, 2.1397, 2.1987, 2.2225] / 100.0
}

instrument = parseInstrument(bond)
discountCurve = parseMktData(curve)

setting = dict(STRING, ANY)
setting["calcDiscountCurveDelta"] = true
setting["calcDiscountCurveGamma"] = true
setting["calcDiscountCurveKeyRateDuration"] = true
setting["discountCurveShift"] = 0.0001
setting["discountCurveKeyTerms"] = [1.0, 3.0, 5.0]
setting["discountCurveKeyShifts"] = [0.0002, 0.0003, 0.0001]

results = bondPricer(instrument, pricingDate, discountCurve, setting=setting)
print(results)

/* output:
npv->99.600846811350891
discountCurveDelta->-592.25994127828585
discountCurveGamma->4223.064257757869199
discountCurvekeyRateDuration->[0.012669167121743,0.069982332985636,1.955786205709234]
*/

Related functions: parseInstrument, parseMktData

Bond Product Field Specifications

Discount Bond

Field Name Data Type Description Required
productType STRING Must be "Cash"
assetType STRING Must be "Bond"
bondType STRING Must be "DiscountBond"
version INT Version, default 0 ×
nominal DOUBLE Nominal amount, defalut 100 ×
instrumentId STRING Bond code, e.g., "259926.IB" ×
start DATE Value date
maturity DATE Maturity date
dayCountConvention STRING The day count convention. It can be: "ActualActualISDA", "ActualActualISMA"," Actual365", "Actual360"
issuePrice DOUBLE Issue price
currency STRING Currency, defaults to "CNY" ×
cashFlow TABLE Cash flow table ×
discountCurve STRING The discount curve, e.g., "CNY_TRASURY_BOND" ×
spreadCurve STRING The credit spread curve ×
subType STRING

Subtypes. China's bonds include:

  • "TREASURY_BOND": Treasury Bonds

  • "CENTRAL_BANK_BILL": Central Bank Bills

  • "CDB_BOND": Policy Bank Financial Bonds (China Development Bank)

  • "EIBC_BOND": Policy Bank Financial Bonds (Export-Import Bank of China)

  • "ADBC_BOND": Policy Bank Financial Bonds (Agricultural Development Bank of China)

  • "MTN": Medium-term Notes

  • "CORP_BOND": Corporate Bonds

  • "UNSECURED_CORP_BOND": Unsecured Corporate Bonds

  • "SHORT_FIN_BOND": Short-term Financing Bills

  • "NCD": Negotiable Certificates of Deposit

  • "LOC_GOV_BOND": Local Government Bonds

  • "COMM_BANK_FIN_BOND": Commercial Bank Financial Bonds

  • "BANK_SUB_CAP_BOND": Bank Subordinated Capital Bonds

  • "ABS": Asset-backed Securities

  • "PPN": Privately Offered Bonds

×
creditRating STRING Credit rating. It can be: "B", "BB", "BBB", "BBB+", "A-", "A", "A+", "AA-", "AA", "AA+", "AAA-", "AAA", "AAA+" ×

Zero Coupon Bond

Field Name Data Type Description Required
productType STRING Must be "Cash"
assetType STRING Must be "Bond"
bondType STRING Must be "ZeroCouponBond"
version INT Version, default 0 ×
nominal DOUBLE Nominal amount, defalut 100 ×
instrumentId STRING Bond code, e.g., "259926.IB" ×
start DATE Value date
maturity DATE Maturity date
coupon DOUBLE Coupon rate, e.g., 0.03 means 3%
frequency STRING Frequency of interest payment
dayCountConvention STRING The day count convention. It can be: "ActualActualISDA", "ActualActualISMA"," Actual365", "Actual360"
currency STRING Currency, defaults to "CNY" ×
cashFlow TABLE Cash flow table ×
discountCurve STRING The discount curve, e.g., "CNY_TRASURY_BOND" ×
spreadCurve STRING The credit spread curve ×
subType STRING

Subtypes. China's bonds include:

  • "TREASURY_BOND": Treasury Bonds

  • "CENTRAL_BANK_BILL": Central Bank Bills

  • "CDB_BOND": Policy Bank Financial Bonds (China Development Bank)

  • "EIBC_BOND": Policy Bank Financial Bonds (Export-Import Bank of China)

  • "ADBC_BOND": Policy Bank Financial Bonds (Agricultural Development Bank of China)

  • "MTN": Medium-term Notes

  • "CORP_BOND": Corporate Bonds

  • "UNSECURED_CORP_BOND": Unsecured Corporate Bonds

  • "SHORT_FIN_BOND": Short-term Financing Bills

  • "NCD": Negotiable Certificates of Deposit

  • "LOC_GOV_BOND": Local Government Bonds

  • "COMM_BANK_FIN_BOND": Commercial Bank Financial Bonds

  • "BANK_SUB_CAP_BOND": Bank Subordinated Capital Bonds

  • "ABS": Asset-backed Securities

  • "PPN": Privately Offered Bonds

×
creditRating STRING Credit rating. It can be: "B", "BB", "BBB", "BBB+", "A-", "A", "A+", "AA-", "AA", "AA+", "AAA-", "AAA", "AAA+" ×

Fixed Rate Bond

Field Name Data Type Description Required
productType STRING Must be "Cash"
assetType STRING Must be "Bond"
bondType STRING Must be "FixedRateBond"
version INT Version, default 0 ×
nominal DOUBLE Nominal amount, defalut 100 ×
instrumentId STRING Bond code, e.g., "259926.IB" ×
start DATE Value date
maturity DATE Maturity date
coupon DOUBLE Coupon rate, e.g., 0.03 means 3%
frequency STRING Frequency of interest payment
dayCountConvention STRING The day count convention. It can be: "ActualActualISDA", "ActualActualISMA"," Actual365", "Actual360"
currency STRING Currency, defaults to "CNY" ×
cashFlow TABLE Cash flow table ×
discountCurve STRING The discount curve, e.g., "CNY_TRASURY_BOND" ×
spreadCurve STRING The credit spread curve ×
subType STRING

Subtypes. China's bonds include:

  • "TREASURY_BOND": Treasury Bonds

  • "CENTRAL_BANK_BILL": Central Bank Bills

  • "CDB_BOND": Policy Bank Financial Bonds (China Development Bank)

  • "EIBC_BOND": Policy Bank Financial Bonds (Export-Import Bank of China)

  • "ADBC_BOND": Policy Bank Financial Bonds (Agricultural Development Bank of China)

  • "MTN": Medium-term Notes

  • "CORP_BOND": Corporate Bonds

  • "UNSECURED_CORP_BOND": Unsecured Corporate Bonds

  • "SHORT_FIN_BOND": Short-term Financing Bills

  • "NCD": Negotiable Certificates of Deposit

  • "LOC_GOV_BOND": Local Government Bonds

  • "COMM_BANK_FIN_BOND": Commercial Bank Financial Bonds

  • "BANK_SUB_CAP_BOND": Bank Subordinated Capital Bonds

  • "ABS": Asset-backed Securities

  • "PPN": Privately Offered Bonds

×
creditRating STRING Credit rating. It can be: "B", "BB", "BBB", "BBB+", "A-", "A", "A+", "AA-", "AA", "AA+", "AAA-", "AAA", "AAA+" ×

Curve Field Specifications

Field Name Data Type Description Required
mktDataType STRING Must be "Curve"
referenceDate DATE Reference Date
version INT Version, default 0 ×
curveType STRING Must be "IrYieldCurve"
dayCountConvention STRING

The day count convention to use. It can be:

  • "Actual360": actual/360

  • "Actual365": actual/365

  • "ActualActualISMA": actual/actual according to ISMA (International Securities Market Association) convention

  • "ActualActualISDA": actual/actual according to ISDA (International Swaps and Derivatives Association) convention.

interpMethod STRING

Interpolation method. It can be:

  • "Linear": linear interpolation

  • "CubicSpline": cubic spline interpolation

  • "CubicHermiteSpline": cubic Hermite interpolation

extrapMethod STRING

Extrapolation method. It can be

  • Flat: flat extrapolation

  • Linear: linear extrapolation

dates DATE vector Date of each data point
values DOUBLE vector Value of each data point, corresponding to the elements in dates.
curveName STRING Curve name ×
currency STRING Currency. It can be CNY", "USD", "EUR", "GBP", "JPY", "HKD"
compounding STRING

The compounding interest. It can be:

  • "Compounded": discrete compounding

  • "Simple": simple interest (no compounding).

  • "Continuous": continuous compounding.

settlement DATE Settlement date. If specified, all subsequent tenor intervals are computed starting from "settlement" rather than from "referenceDate". ×
frequency INTEGRAL/STRING

The interest payment frequency. Supported values:

  • -1 or "NoFrequency": No payment frequency

  • 0 or "Once": Single lump-sum payment of principal and interest at maturity.

  • 1 or "Annual": Annually

  • 2 or "Semiannual": Semiannually

  • 3 or "EveryFourthMonth": Every four months

  • 4 or "Quarterly": Quarterly

  • 6 or "BiMonthly": Every two months

  • 12 or "Monthly": Monthly

  • 13 or "EveryFourthWeek": Every four weeks

  • 26 or "BiWeekly": Every two weeks

  • 52 or "Weekly": Weekly

  • 365 or "Daily": Daily

  • 999 or "Other": Other frequencies

×
curveModel STRING

Curve construction model; It can be "Bootstrap" (default), "NS", "NSS".

When the value is "NSS" or "NS", the fields interpMethod, extrapMethod, dates, and values are not required.

×
curveParams DICT

Model parameters. It is required when curveModel is "NSS" or "NS":

  • If curveModel = "NS": must include keys 'beta0', 'beta1', 'beta2', 'lambda'.

  • If curveModel = "NSS": must include keys 'beta0', ‘beta1', 'beta2', 'beta3', 'lambda0', 'lambda1'.

×