DStream::pricingEngine

First introduced in version: 3.00.6.1

Syntax

DStream::pricingEngine(instrument, [engineConfig])

Details

Creates a real-time pricing engine in Orca. The engine receives standardized market data objects from the upstream node, automatically matches the market data with the registered financial instrument, and outputs pricing results.

It is suitable for real-time valuation scenarios involving bonds, treasury futures, deposits, interest rate swaps, FX forwards, FX swaps, FX options, and other financial instruments.

Parameters

instrument is an INSTRUMENT scalar/vector, indicating the instrument(s) to be priced. During pricing, market data is matched according to the rules defined by instrumentPricer.

engineConfig (optional) is a dictionary specifying engine runtime configuration. Supported key-value pairs include:

Returns

A DStream object.

Examples

This example demonstrates how to implement real-time valuation in Orca, where pricing results are refreshed whenever market quotes change.

The system receives multiple market quotes in real time, including a 3M deposit quote and 1y, 3y, and 5y interest rate swap quotes, and writes them to the quote stream table quote_in. The mktDataEngine dynamically builds the CNY_FR_007 CNY yield curve from these quotes. The pricing engine then uses the curve as the discount curve to value a 3-month deposit contract with a notional amount of CNY 1,000,000. The resulting NPV is continuously written to the stream table price_out.

if (!existsCatalog("orca")) {
    createCatalog("orca")
}
go
use catalog orca

// Configure market data (yield curve) and the instrument to be priced (deposit)
curveConfig = {
    "name": "CNY_FR_007",
    "type": "IrSingleCurrencyCurve",
    "insts": [
        ("FR_007", "Deposit", duration("3M")),
        ("CNY_FR_007", "IrVanillaSwap", duration("1y")),
        ("CNY_FR_007", "IrVanillaSwap", duration("3y")),
        ("CNY_FR_007", "IrVanillaSwap", duration("5y"))
    ],
    "currency": "CNY",
    "dayCountConvention": "Actual365"
}
deposit = {
    "productType": "Cash",
    "assetType": "Deposit",
    "instrumentId": "dep_3m",
    "start": 2025.01.01,
    "maturity": 2025.04.01,
    "rate": 0.02,
    "dayCountConvention": "Actual360",
    "notionalCurrency": "CNY",
    "notionalAmount": 1000000,
    "payReceive": "Receive",
    "discountCurve": "CNY_FR_007"
}
deposit = parseInstrument(deposit)

// Define a stream graph: quote input -> curve construction -> real-time pricing -> result output
g = createStreamGraph("simple_pricing_demo")
g.source(`quote_in, `type`name`term`price, [STRING, STRING, STRING, DOUBLE])
 .mktDataEngine(2025.01.01, curveConfig)
 .pricingEngine(deposit)
 .sink("price_out")
g.submit()

// Ingest interest rate quotes to trigger pricing
appendOrcaStreamTable("quote_in", table(
    ["Deposit","IrVanillaSwap","IrVanillaSwap","IrVanillaSwap"] as type,
    ["FR_007","CNY_FR_007","CNY_FR_007","CNY_FR_007"] as name,
    ["3M","1y","3y","5y"] as term,
    [0.019, 0.021, 0.024, 0.027] as price))

// Query the real-time pricing result
select * from useOrcaStreamTable("price_out", t -> select * from t)
name date price
dep_3m 2025.01.01 980,522.20

Related functions: DStream::mktDataEngine, createPricingEngine