eqEuropeanOptionPricer

First introduced in version: 3.00.6

Syntax

eqEuropeanOptionPricer(instrument, pricingDate, spot, discountCurve, dividendCurve, volSurf, [setting])

Details

Prices an European equity option.

Parameters

instrument: An INSTRUMENT scalar or vector specifying the European equity options to be priced. For field requirements, see the Instrument Field Description.

pricingDate: A DATE scalar or vector specifying the pricing date.

spot: A numeric scalar or vector specifying the spot price.

discountCurve: A MKTDATA scalar or vector specifying the discount curve (IrYieldCurve).

dividendCurve: A MKTDATA scalar or vector specifying the dividend curve (DividendCurve). This curve is built using eqDividendCurveBuilder.

volSurf: A VolatilitySurface object specifying the equity option volatility surface. This surface is built using eqVolatilitySurfaceBuilder.

setting (optional): A dictionary (<STRING, BOOL>) specifying whether to calculate option price sensitivities (Greeks). Supported keys:
Key Value Description
calcDelta Boolean; defaults to false Whether to calculate Delta, the sensitivity of the option price to the underlying asset price.
calcGamma Boolean; defaults to false Whether to calculate Gamma, the sensitivity of Delta to the underlying asset price.
calcVega Boolean; defaults to false Whether to calculate Vega, the sensitivity of the option price to volatility.
calcTheta Boolean; defaults to false Whether to calculate Theta, the sensitivity of the option price to the passage of time.
calcRhoIr Boolean; defaults to false Whether to calculate RhoIr, the sensitivity of the option price to the risk-free interest rate.
calcRhoDividend Boolean; defaults to false Whether to calculate RhoDividend, the sensitivity of the option price to changes in the dividend yield.

Returns

  • If the setting parameter is not specified, returns a DOUBLE scalar indicating the option’s net present value (NPV), i.e., the theoretical option price.
  • If the setting parameter is specified, returns a dictionary (<STRING, DOUBLE>) containing the option’s NPV and the option price sensitivities represented by the Greeks. For details on Greeks, see the description of the setting parameter.

Examples

// ================================================================
// Data Sources:
//   Spot Price  : akshare fund_etf_hist_sina('sh510050')     → 3.1140
//   Option Chain: akshare option_risk_indicator_sse('20260213')
//                 → Option settlement prices reconstructed via Black-Scholes
//   Rate Curve  : China Money Network  FX-Implied Interest Rate Curve (CNY)
//                 https://www.chinamoney.com.cn/chinese/bkcurvuiruuh/
//                 API: POST /ags/ms/cm-u-bk-fx/IuirCurvHis  2026-02-13
//
// Target      : Call  strike=3.2000  expiry=2026-03-25
// ================================================================

pricingDate   = 2026.02.13
referenceDate = pricingDate

// ------------------------------------------------------------------
// 1. Spot Price
// ------------------------------------------------------------------
spot = 3.1140

// ------------------------------------------------------------------
// 2. Define the Option Instrument  (near-month ATM / slightly OTM call)
// ------------------------------------------------------------------
optionDict = {
    "productType"       : "Option",
    "optionType"        : "EuropeanOption",
    "assetType"         : "EqEuropeanOption",
    "notionalCurrency"  : "CNY",
    "notionalAmount"    : 10000,
    "strike"            : 3.2000,
    "maturity"          : 2026.03.25,
    "payoffType"        : "Call",
    "dayCountConvention": "Actual365",
    "underlying"        : "510050"
}
option = parseInstrument(optionDict)

// ------------------------------------------------------------------
// 3. Raw Option Chain Data  (used to build dividend curve and vol surface)
//    Expiry sequence: 2026.02.25 | 2026.03.25 | 2026.06.24 | 2026.09.23
//    Strike range   : [2.85, 3.60]
// ------------------------------------------------------------------
termDates = [2026.02.25, 2026.03.25, 2026.06.24, 2026.09.23]

callPrices = matrix(
    [0.2655, 0.2155, 0.1656, 0.1156, 0.0318, 0.0039, 0.0015, 0.0008, 0.0003, 0.0001],
    [0.2690, 0.2248, 0.1770, 0.1385, 0.0697, 0.0303, 0.0128, 0.0069, 0.0046, 0.0036],
    [0.3030, 0.2655, 0.2278, 0.1970, 0.1431, 0.0991, 0.0677, 0.0479, 0.0346, 0.0254],
    [0.3330, 0.2987, 0.2681, 0.2388, 0.1883, 0.1448, 0.1139, 0.0899, 0.0715, 0.0574]
)

putPrices = matrix(
    [0.0004, 0.0009, 0.0021, 0.0045, 0.0218, 0.0939, 0.1901, 0.2896, 0.3908, 0.4916],
    [0.0125, 0.0165, 0.0229, 0.0316, 0.0616, 0.1250, 0.2029, 0.2967, 0.3962, 0.4948],
    [0.0396, 0.0507, 0.0634, 0.0798, 0.1253, 0.1814, 0.2499, 0.3321, 0.4175, 0.5077],
    [0.0651, 0.0798, 0.0973, 0.1180, 0.1662, 0.2250, 0.2952, 0.3651, 0.4508, 0.5342]
)

strikes = matrix(
    [2.8500, 2.9000, 2.9500, 3.0000, 3.1000, 3.2000, 3.3000, 3.4000, 3.5000, 3.6000],
    [2.8500, 2.9000, 2.9500, 3.0000, 3.1000, 3.2000, 3.3000, 3.4000, 3.5000, 3.6000],
    [2.8500, 2.9000, 2.9500, 3.0000, 3.1000, 3.2000, 3.3000, 3.4000, 3.5000, 3.6000],
    [2.8500, 2.9000, 2.9500, 3.0000, 3.1000, 3.2000, 3.3000, 3.4000, 3.5000, 3.6000]
)

// ------------------------------------------------------------------
// 4. Discount Curve  ── China Money Network FX-Implied CNY Rate Curve (2026-02-13)
//    Source: https://www.chinamoney.com.cn/chinese/bkcurvuiruuh/
//    Filter: USD.CNY / Shibor / Mean Quote Rate of OTC FX Spot Market / Swap Pips
//    Field : rmbRateStr (CNY interest rate, %)
// ------------------------------------------------------------------
discountCurveDict = {
    "mktDataType"       : "Curve",
    "curveType"         : "IrYieldCurve",
    "curveName"         : "CNY_FR_007",
    "referenceDate"     : referenceDate,
    "currency"          : "CNY",
    "dayCountConvention": "Actual365",
    "compounding"       : "Continuous",
    "interpMethod"      : "Linear",
    "extrapMethod"      : "Flat",
    "dates"             : [referenceDate + 1, referenceDate + 7, referenceDate + 14, referenceDate + 21, referenceDate + 30, referenceDate + 61, referenceDate + 91, referenceDate + 182, referenceDate + 273, referenceDate + 365, referenceDate + 547, referenceDate + 730, referenceDate + 1095],
    "values"            : [0.016134, 0.016107, 0.016102, 0.016102, 0.016102, 0.016103, 0.016029, 0.015832, 0.015889, 0.015898, 0.015561, 0.015583, 0.015892]
}
discountCurve = parseMktData(discountCurveDict)

// ------------------------------------------------------------------
// 5. Dividend Curve  ── Implied via Call-Put Parity
// ------------------------------------------------------------------
dividendCurve = eqDividendCurveBuilder(
    referenceDate, termDates, "CallPutParity", ,
    callPrices, putPrices, strikes, spot, discountCurve,
    "Actual365", "510050"
)

// ------------------------------------------------------------------
// 6. Volatility Surface  ── SABR model, built from OTM options
//    Strike < Spot → OTM Put;  Strike >= Spot → OTM Call
// ------------------------------------------------------------------
optionExpiries = termDates

optionPrices = matrix(
    [0.0004, 0.0009, 0.0021, 0.0045, 0.0218, 0.0039, 0.0015, 0.0008, 0.0003, 0.0001],
    [0.0125, 0.0165, 0.0229, 0.0316, 0.0616, 0.0303, 0.0128, 0.0069, 0.0046, 0.0036],
    [0.0396, 0.0507, 0.0634, 0.0798, 0.1253, 0.0991, 0.0677, 0.0479, 0.0346, 0.0254],
    [0.0651, 0.0798, 0.0973, 0.1180, 0.1662, 0.1448, 0.1139, 0.0899, 0.0715, 0.0574]
)

payoffTypes = matrix(
    ["Put", "Put", "Put", "Put", "Put", "Call", "Call", "Call", "Call", "Call"],
    ["Put", "Put", "Put", "Put", "Put", "Call", "Call", "Call", "Call", "Call"],
    ["Put", "Put", "Put", "Put", "Put", "Call", "Call", "Call", "Call", "Call"],
    ["Put", "Put", "Put", "Put", "Put", "Call", "Call", "Call", "Call", "Call"]
)

volSurface = eqVolatilitySurfaceBuilder(
    referenceDate,
    optionExpiries,
    strikes,
    optionPrices,
    payoffTypes,
    spot,
    discountCurve,
    dividendCurve,
    "SABR",
    "50ETF_SABR_20260213"
)

// ------------------------------------------------------------------
// 7. Pricing  ── Single contract NPV
// ------------------------------------------------------------------
npv = eqEuropeanOptionPricer(option, pricingDate, spot, discountCurve, dividendCurve, volSurface)
print("NPV = " + string(npv))

// ------------------------------------------------------------------
// 8. Pricing  ── With Greeks
// ------------------------------------------------------------------
setting = {
    "calcDelta"      : true,
    "calcGamma"      : true,
    "calcVega"       : true,
    "calcTheta"      : true,
    "calcRhoIr"      : true,
    "calcRhoDividend": true
}
result = eqEuropeanOptionPricer(option, pricingDate, spot, discountCurve, dividendCurve, volSurface, setting)
print(result)

// ------------------------------------------------------------------
// 9. Batch Pricing  ── All common strikes expiring 2026-03-25 (Call)
// ------------------------------------------------------------------
allStrikes = [2.8500, 2.9000, 2.9500, 3.0000, 3.1000, 3.2000, 3.3000, 3.4000, 3.5000, 3.6000]
results = array(DOUBLE, 0)
for (k in allStrikes) {
    iDict = {
        "productType"       : "Option",
        "optionType"        : "EuropeanOption",
        "assetType"         : "EqEuropeanOption",
        "notionalCurrency"  : "CNY",
        "notionalAmount"    : 10000,
        "strike"            : k,
        "maturity"          : 2026.03.25,
        "payoffType"        : "Call",
        "dayCountConvention": "Actual365",
        "underlying"        : "510050"
    }
    iOpt = parseInstrument(iDict)
    results.append!(eqEuropeanOptionPricer(iOpt, pricingDate, spot, discountCurve, dividendCurve, volSurface))
}
t = table(allStrikes as strike, results as npv)
print(t)

Instrument Field Description

Field Type Description Required
productType STRING Must be "Option". Yes
optionType STRING Must be "EuropeanOption". Yes
assetType STRING Must be "EqEuropeanOption". Yes
notionalAmount DOUBLE Notional amount Yes
notionalCurrency STRING Notional currency. Default value: "CNY". No
instrumentId STRING

Contract identifier, e.g. CSI 500 ETF option

510500C2512M04800

No
direction STRING Trade direction: "Buy" (default) or "Sell". No
maturity DATE Maturity date Yes
strike DOUBLE Strike price Yes
payoffType STRING Payoff type: "Call" or "Put". Yes
underlying STRING Underlying contract code, e.g. 510050. Yes
dayCountConvention STRING Day count convention. Valid values: "ActualActualISDA", "ActualActualISMA", "Actual365", "Actual360" Yes
discountCurve STRING Discount curve name for pricing reference. The default value for RMB deposits is "CNY_FR_007". No
dividendCurve STRING Name of the dividend curve used for pricing. No

Related Functions: parseInstrument, parseMktData, eqDividendCurveBuilder, eqVolatilitySurfaceBuilder