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:

  • Prices: spot price (Price), foreign exchange spot rate (FxSpotRate)

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

  • Volatility surfaces: foreign exchange volatility surface (FxVolatilitySurface), interest rate cap/floor option volatility surface (IrCapFloorVolatilitySurface)

  • Volatility cubes: interest rate swaption volatility cube (IrSwaptionVolatilityCube)

Spot Price

Field Name Data Type Description Required
mktDataType STRING Must be "Price" Yes
referenceDate DATE Reference Date Yes
priceType STRING Price type. Must be "Price" Yes
value DOUBLE Spot price Yes
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" Yes

Foreign Exchange Spot Rate

Field Name Data Type Description Required
mktDataType STRING Must be "Price" Yes
referenceDate DATE Reference Date Yes
spotDate DATE Spot settlement date. Use internal static data by default. No
priceType STRING Spot price type. Must be "FxSpotRate" Yes
value DOUBLE Spot price Yes
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".

Yes

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)

Interest Rate Yield Curve

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

Yes
interpMethod STRING

Interpolation method. It can be:

  • "Linear": linear interpolation

  • "CubicSpline": cubic spline interpolation

  • "CubicHermiteSpline": cubic Hermite interpolation

Yes
extrapMethod STRING

Extrapolation method. It can be

  • Flat: flat extrapolation

  • Linear: linear extrapolation

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

The compounding interest. It can be:

  • "Compounded": discrete compounding

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

  • "Continuous": continuous compounding.

Yes
settlement DATE Settlement date. If specified, all subsequent tenor intervals are computed starting from "settlement" rather than from "referenceDate". No
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

No
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.

No
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'.

No

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)

Asset Price Curve

Field Name Data Type Description Required
mktDataType STRING Must be "Curve" Yes
referenceDate DATE Reference Date Yes
curveType STRING Must be "AssetPriceCurve" Yes
dates DATE vector Date of each data point Yes
values DOUBLE vector Value of each data point, corresponding to the elements in dates. Yes
curveName STRING Curve name No

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)

Dividend Curve

Define a MKTDATA object of DividendCurve type.

curve = {
    "mktDataType": "Curve",
    "curveType": "DividendCurve",
    "referenceDate": 2024.06.28,
    "dayCountConvention": "Actual365",
    "compounding": "Continuous",
    "interpMethod": "Linear",
    "extrapMethod": "Flat",
    "dates": [2024.07.19, 2024.08.16, 2024.09.20, 2024.12.20],
    "values": [0.15347650417594424, 0.10083112893776815, 0.0693439711515692, 0.04357496515816385],
    "shortEndDate": 2024.06.28
}

dividendCurve = parseMktData(curve)

Credit Curve

Field Name Type Description Required
mktDataType STRING Must be "Curve" Yes
referenceDate DATE Reference Date Yes
curveType STRING Must be "CreditCurve" Yes
curveName STRING Curve name No
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.

Yes
interpMethod STRING

Interpolation method. It can be:

  • "Linear": linear interpolation

  • "CubicSpline": cubic spline interpolation

  • "CubicHermiteSpline": cubic Hermite interpolation

Yes
extrapMethod STRING

Extrapolation method. It can be

  • Flat: flat extrapolation

  • Linear: linear extrapolation

Yes
dates DATE vector Date of each data point Yes
values DOUBLE vector Hazard rates. Value of each data point, corresponding to the elements in dates Yes

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)
}

Foreign Exchange Volatility Surface

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

Volatility smile method. It can be:

  • "Linear": linear smile

  • "CubicSpline": cubic-spline smile

  • "SVI": SVI-model smile

  • "SABR": SABR-model smile

Yes
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".

Yes
termDates DATE vector Term date corresponding to each smile in volSmiles. Yes
surfaceName STRING Surface name No
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".

Yes

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)

Interest Rate Cap/Floor Option Volatility Surface

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

Volatility smile method. It can be:

  • "Linear": linear smile

  • "CubicSpline": cubic-spline smile

  • "SVI": SVI-model smile

  • "SABR": SABR-model smile

Yes
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".

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

Reference Rate. Available options:

  • "LPR_1Y": 1-Year Loan Prime Rate

  • "LPR_5Y": 5-Year Loan Prime Rate

Yes
volType STRING

Volatility Type. Available valuoptionses:

  • "Normal"(Default): Normal Volatility

  • "Lognormal": Lognormal Volatility

No

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)

Interest Rate Swaption Volatility Cube

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