parseMktData

First introduced in version: 3.00.4

Syntax

parseMktData(dict)

Details

Parses the given dictionary or JSON string into MKTDATA type.

Parameters

dict A dictionary or a STRING scalar representing a JSON-encoded dictionary that defines the market data to be parsed.

Returns

A MKTDATA object.

Supported Market Data and Fields

The MKTDATA type is newly introduced in DolphinDB version 3.00.4, which provides database support for the market data used for pricing.

Currently supported types:

  • Spot prices: FxSpotRate (foreign exchange spot rate)

  • Term structure curves: IrYieldCurve (interest rate yield curve), AssetPriceCurve (asset price curve)

  • Volatility surfaces: FxVolatilitySurface (foreign exchange volatility surface)

Price

Field Name Data Type Description Required
mktDataType STRING Must be "Price"
referenceDate DATE Reference Date
priceType STRING Price type. Must be "Price"
value DOUBLE Spot price
unit STRING The pricing unit of value (i.e., the unit or dimension represented by the numeric value).When priceType is "Price", unit specifies the currency code. Supported values are "CNY", "USD", "EUR", "GBP", "JPY", "HKD"

FxSpotRate

Field Name Data Type Description Required
mktDataType STRING Must be "Price"
referenceDate DATE Reference Date
spotDate DATE Spot settlement date. Use internal static data by default. ×
priceType STRING Spot price type. Must be "FxSpotRate"
value DOUBLE Spot price
unit STRING

The pricing unit of value (i.e., the unit or dimension represented by the numeric value).When priceType is "FxSpotRate", unit specifies a currency pair. Supported values are "EURUSD", "USDCNY", "EURCNY", "GBPCNY", "JPYCNY", "HKDCNY".

Currency pairs may also use . or / as separators. For example, "EURUSD" can also be written as "EUR.USD" or "EUR/USD".

Define a MKTDATA object of FxSpotRate type.

FxSpotRate = {
    "mktDataType": "Price",
    "referenceDate": 2025.08.18,
    "spotDate": 2025.08.20,
    "priceType": "FxSpotRate",
    "value": 7.2659,
    "unit": "USDCNY"
}

mktData = parseMktData(FxSpotRate)
print(mktData)

IrYieldCurve

Field Name Data Type Description Required
mktDataType STRING Must be "Curve"
referenceDate DATE Reference Date
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'.

×

Define a MKTDATA object of IrYieldCurve type.

aod = 2025.07.01
curve = {
    "mktDataType": "Curve",
    "curveType": "IrYieldCurve",
    "referenceDate": aod,
    "currency": "CNY",
    "dayCountConvention": "Actual365",
    "compounding": "Continuous",
    "interpMethod": "Linear",
    "extrapMethod": "Flat",
    "dates":[2025.07.07,2025.07.10,2025.07.17,2025.07.24,2025.08.04,2025.09.03,2025.10.09,2026.01.05,
        2026.04.03,2026.07.03,2027.01.04,2027.07.05,2028.07.03],
    "values":[0.015785,0.015931,0.016183,0.016381,0.016493,0.016503,0.016478,0.016234,0.016321,
        0.016378,0.015508,0.015185,0.014901],
    "settlement": aod+2
}

mktData = parseMktData(curve)
print(mktData)

IrSwaptionVolatilityCube

Field Name Type Description Required
cubeName STRING Volatility cube name No
mktDataType STRING Market data type. Set this field to "Cube". Yes
cubeType STRING Surface type. Set this field to "IrSwaptionVolatilityCube". Yes
referenceDate DATE Reference date Yes
currency STRING Currency, for example, "CNY". Yes
iborIndex STRING Reference rate for the underlying interest rate swap Yes
atmTerms DOUBLE[] Expiry of the at-the-money (ATM) option, expressed as a year fraction Yes
atmTenors DOUBLE[] Tenor of the underlying interest rate swap for the ATM option, expressed as a year fraction Yes
atmVols DOUBLE Matrix Volatility of the ATM option, with shape size(atmTerms) * size(atmTenors) Yes
otmTerms DOUBLE[] Expiry of the out-of-the-money (OTM) option, expressed as a year fraction Yes
otmTenors DOUBLE[] Tenor of the underlying interest rate swap for the OTM option, expressed as a year fraction Yes
paramCube Dict(String, Double Matrix) Volatility smile parameters for the OTM option. Contains four keys: 'alpha', 'beta', 'rho', and 'nu'. Each key corresponds to one parameter, and its value is a DOUBLE matrix with shape size(otmTerms) * size(otmTenors). The value in row i and column j of the matrix is the value of that parameter at otmTerms[i] and otmTenors[j]. Yes
volType STRING Volatility type. The default value is "Normal". No

IrYieldCurve(non-bond)

Field Name Data Type Description Required
mktDataType STRING Must be "Curve"
referenceDate DATE Reference Date
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; Currently, only "Bootstrap" is supported.

×
curveParams DICT Model parameters. ×

AssetPriceCurve

Field Name Data Type Description Required
mktDataType STRING Must be "Curve"
referenceDate DATE Reference Date
curveType STRING Must be "AssetPriceCurve"
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 ×

Define a MKTDATA object of AssetPriceCurve type.

curve = {
    "mktDataType": "Curve",
    "curveType": "AssetPriceCurve",
    "referenceDate": 2024.06.28,
    "curveName": "PRICE_SHIBOR_3M",
    "dates": [2024.06.21, 2024.06.24, 2024.06.25, 2024.06.26,2024.06.27],
    "values": [1.923, 1.922, 1.921, 1.919, 1.918]/100
}

mktData = parseMktData(curve)
print(mktData)

CreditCurve

Field Name Type Description Required
mktDataType STRING Must be "Curve"
referenceDate DATE Reference Date
curveType STRING Must be "CreditCurve"
curveName STRING Curve name ×
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 Hazard rates. Value of each data point, corresponding to the elements in dates

Define a MKTDATA object of CreditCurve type.

def createCnyFr007CurveForCds(asOfDate){
    pillarDates = asOfDate + [2, 8, 93, 185, 276, 367, 732, 1099, 1463, 1828, 2558, 3654]
    pillarValues = [
        0.0145993931630537,
        0.0229075517972275,
        0.0253020667393029,
        0.0257564866303201,
        0.0259751440992468,
        0.0260355181479988,
        0.0265336263144786,
        0.0272721454114050,
        0.0282024453631075,
        0.0290231222075799,
        0.0304665029488732,
        0.0319855013976250
    ]
    discountCurveDict = {
        "mktDataType": "Curve",
        "curveType": "IrYieldCurve",
        "referenceDate": asOfDate,
        "currency": "CNY",
        "curveName": "CNY_FR_007",
        "dayCountConvention": "Actual365",
        "compounding": "Continuous",
        "interpMethod": "Linear",
        "extrapMethod": "Flat",
        "frequency": "NoFrequency",
        "dates": pillarDates,
        "values": pillarValues
    }
    return parseMktData(discountCurveDict)
}
def createCreditCurveForCds(asOfDate){
    pillarDates = asOfDate + [2, 8, 93, 185, 276, 367, 732, 1099, 1463]
    hazardRates = [
        0.001577614619366,
        0.001577614619366,
        0.00237392030740149,
        0.00527736067786984,
        0.00887303437629905,
        0.0151416564486811,
        0.0219406380083359,
        0.0442999285840119,
        0.0182083758016553
    ]
    creditCurveDict = {
        "mktDataType": "Curve",
        "curveType": "CreditCurve",
        "referenceDate": asOfDate,
        "currency": "CNY",
        "curveName": "CFETS_SHCH_GTJA",
        "interpMethod": "Linear",
        "extrapMethod": "Flat",
        "dayCountConvention": "Actual365",
        "dates": pillarDates,
        "values": hazardRates
    }
    return parseMktData(creditCurveDict)
}

FxVolatilitySurface

Field Name Data Type Description Required
mktDataType STRING Must be "Surface"
referenceDate DATE Reference Date
surfaceType STRING Must be "FxVolatilitySurface"
smileMethod STRING

Volatility smile method. It can be:

  • "Linear": linear smile

  • "CubicSpline": cubic-spline smile

  • "SVI": SVI-model smile

  • "SABR": SABR-model smile

volSmiles DICT(STRING, ANY)vector

Volatility smiles vector. Each element is one smile . It has the following members:

  • strikes: A DOUBLE vector indicating the strike prices.

  • vols: A DOUBLE vector indicating the volatilities corresponding to strikes (of the same length).

  • curveParams: A DICT(STRING, DOUBLE) indicating the model parameters for the smile method; only effective when smileMethod is "SVI" or "SABR":

    • smileMethod = 'SVI': Must have the keys: 'a', 'b', 'rho', 'm', 'sigma'

    • smileMethod = 'SABR':

      Must have the keys: 'alpha', 'beta', 'rho', 'nu'

  • fwd (optional ): A DOUBLE scalar indicating the forward value. It is required when smileMethod is "SVI" or "SABR".

termDates DATE vector Term date corresponding to each smile in volSmiles.
surfaceName STRING Surface name ×
currencyPair STRING

Foreign exchange currency pair. Available options: "EURUSD", "USDCNY", "EURCNY", "GBPCNY", "JPYCNY", "HKDCNY".

Currency pairs may also use . or / as separators. For example, "EURUSD" can also be written as "EUR.USD" or "EUR/USD".

Define a MKTDATA object of FxVolatilitySurface type.

surf = {
	"surfaceName": "USDCNY",
	"mktDataType": "Surface",
	"surfaceType": "FxVolatilitySurface",
	"referenceDate": 2025.08.18,
	"smileMethod": "Linear",
	"termDates": [
		2025.08.21,
		2026.08.20
	],
	"volSmiles":[{"strikes": [6.5,7,7.5],"vols": [0.1,0.1,0.1]},{"strikes": [6.5,7,7.5],"vols": [0.1,0.1,0.1]}],
	"currencyPair": "USDCNY"
}

surfUsdCny = parseMktData(surf)

IrCapFloorVolatilitySurface

Field Data Type Description Required
mktDataType STRING Must be "Surface"
referenceDate DATE Reference Date
surfaceType STRING Must be "IrCapFloorVolatilitySurface"
smileMethod STRING

Volatility smile method. It can be:

  • "Linear": linear smile

  • "CubicSpline": cubic-spline smile

  • "SVI": SVI-model smile

  • "SABR": SABR-model smile

volSmiles A tuple of DICT(STRING, ANY)

Volatility smiles vector. Each element is one smile . It has the following members:

  • strikes: A DOUBLE vector indicating the strike prices.

  • vols: A DOUBLE vector indicating the volatilities corresponding to strikes (of the same length).

  • curveParams: A DICT(STRING, DOUBLE) indicating the model parameters for the smile method; only effective when smileMethod is "SVI" or "SABR":

    • smileMethod = 'SVI': Must have the keys: 'a', 'b', 'rho', 'm', 'sigma'

    • smileMethod = 'SABR':

      Must have the keys: 'alpha', 'beta', 'rho', 'nu'

  • fwd (optional ): A DOUBLE scalar indicating the forward value. It is required when smileMethod is "SVI" or "SABR".

termDates DATE vector Term date corresponding to each smile in volSmiles.
surfaceName STRING Surface name ×
currency STRING Currency. It can be CNY", "USD", "EUR", "GBP", "JPY", "HKD"
iborIndex STRING

Reference Rate. Available options:

  • "LPR_1Y": 1-Year Loan Prime Rate

  • "LPR_5Y": 5-Year Loan Prime Rate

volType STRING

Volatility Type. Available valuoptionses:

  • "Normal"(Default): Normal Volatility

  • "Lognormal": Lognormal Volatility

×

Define a MKTDATA object of IrCapFloorVolatilitySurface type.

Lpr1yCapFloorSurf = {
    // Volatility surface name
    "surfaceName": "CNY_LPR_1Y",
    // Market data type
    "mktDataType": "Surface",
    // Surface type
    "surfaceType": "IrCapFloorVolatilitySurface",
    // Surface reference date
    "referenceDate": 2021.03.18,
    // Smile interpolation method
    "smileMethod": "Linear",
    // Term node dates
    "termDates": [
        2021.06.18,
        2021.09.17,
        2021.12.17,
        2022.03.17
    ],
    // Each termDate corresponds to a volatility smile.
    // The length of volSmiles should match the length of termDates.
    // Each smile contains:
    // strikes: strike rate nodes;
    // vols: volatilities at the corresponding strike rate nodes.
    "volSmiles":[
        {
            "strikes": [0.0, 0.03, 0.06, 0.10],
            "vols":    [0.0067, 0.0064, 0.0066, 0.0071]
        },
        {
            "strikes": [0.0, 0.03, 0.06, 0.10],
            "vols":    [0.0067, 0.0064, 0.0066, 0.0071]
        },
        {
            "strikes": [0.0, 0.03, 0.06, 0.10],
            "vols":    [0.0067, 0.0064, 0.0066, 0.0071]
        },
        {
            "strikes": [0.0, 0.03, 0.06, 0.10],
            "vols":    [0.0067, 0.0064, 0.0066, 0.0071]
        }
    ],
    // Currency
    "currency": "CNY",
    // Corresponding floating rate index
    "iborIndex": "LPR_1Y"
}
// -----------------------------------------------------
// Parse the volatility surface dictionary into a market data object recognized by the DDB system
// -----------------------------------------------------
lpr1yVolSurf = parseMktData(Lpr1yCapFloorSurf)