DStream::pricingEngine
Syntax
DStream::pricingEngine(timeColumn, typeColumn, securityType, method,
[securityReference], [keyColumn], [extraMetrics])
Details
Creates a pricing engine. For details, see createPricingEngine.
Return value: A DStream object.
Arguments
timeColumn is a STRING vector indicating the time column in the input.
typeColumn is a STRING vector indicating the security type column in the input. Based on security type, the engine applies the corresponding pricing method.
securityType is a vector of integers indicating the types of securities.
-
User-defined functions or expressions are supported.
-
The parameters of method can be columns from dummyTable, securityReference, or constants. In case of name conflicts, columns from dummyTable are prioritized by default. To search columns from securityReference first, use column references such as
securityReference.X
. -
The kwargs parameter of the vanillaOption method can be specified as follows:
- Define kwargs before specifying the
method:
kwargs = dict(STRING, ANY) kwargs['theta'] = <theta> kwargs['kappa'] = <kappa> kwargs['rho'] = <rho> kwargs['sigma'] = <sigma> method=[<vanillaOption(settlement, maturity, valDay, spot, strike, riskFree, dividend, volatility, isCall, style, basis, calendar,"heston",kwargs)>]
- Define kwargs within the
method:
method=[<vanillaOption(settlement, maturity, valDay, spot, strike, riskFree, dividend, volatility, isCall, style, basis, calendar,"heston",dict(`theta`kappa`rho`sigma, [theta, kappa, rho, sigma]))>]
- Define kwargs before specifying the
method:
Field | Type | Description |
---|---|---|
type | INT | Security type (scalar/vector) |
assetType | INT | Asset type |
symbol | SYMBOL | Security symbol |
maturity | DOUBLE | Maturity date |
coupon | DOUBLE | Coupon rate |
frequency | INT | Coupon frequency |
underlying | SYMBOL | Reference interest rate including "FR007", "Shibor3M", "FDR001", "FDR007", "ShiborO/N", "LPR1Y", "LPR5Y". |
startDate | DATE | Start date of interest rate swap |
endDate | DATE | End date of interest rate swap. Must be later than startDay. |
fixRate | DOUBLE | Fixed interest rate (percentage) paid by the fixed rate payer in a swap contract. |
interval | INT | Interval of of interest rate swap |
basis | INT | Day count basis |
Price | DOUBLE | Current price of the security |
strike | DOUBLE | Strike price of the security |
dividendYield | DOUBLE | Dividend yield rate |
keyColumn (optional) is a STRING scalar or tuple of length 2, indicating the security symbol column in dummyTable and securityReference. Note that securityReference and keyColumn must be both set or unset.
extraMetrics (optional) is a tuple of metacode indicating the additional output beyond pricing results, including columns from the input and securityReference. Constants are not allowed.
Examples
if (!existsCatalog("orca")) {
createCatalog("orca")
}
go
use catalog orca
// If a stream graph with the same name already exists, destroy it first.
// dropStreamGraph('engine')
g = createStreamGraph('engine')
typeList=[0,1,2]
start=2022.07.15
maturity=2072.07.15
issuePrice=100
coupon=0.034
frequency="Semiannual"
dayCountConvention="ActualActual"
bondType="FixedRate"
settlement=2025.04.10
price=0.02
priceType="YTM"
methodList=[<bondDirtyPrice(start, maturity, issuePrice, coupon, frequency, dayCountConvention, bondType, settlement, price, priceType)>,
<bondAccrInt(start, maturity, issuePrice, coupon, frequency, dayCountConvention, bondType, settlement)>,
<bondDuration(start, maturity, issuePrice, coupon, frequency, dayCountConvention, bondType, settlement, price, priceType)>]
securityReference= table(take(0 1 2, 100) as type, take(1 2 3 4, 100) as assetType,"s"+string(1..100) as symbol, 2025.07.25+1..100 as maturity, rand(10.0, 100) as coupon, rand(10,100) as frequency,take([1],100) as basis )
g.source("trades", 1000:0, `tradeTime`Symbol`realTimeX`predictY`price,[TIMESTAMP,SYMBOL, DOUBLE, DOUBLE, DOUBLE])
.pricingEngine(timeColumn=`tradeTime, typeColumn=`type, securityType=typeList, method=methodList, securityReference=securityReference, keyColumn=`Symbol, extraMetrics=[<price * predictY>, <coupon+price>])
.sink("output")
g.submit()
go
data = table(take(now(), 100)as tradeTime,"s"+string(1..100) as symbol, rand(10.0, 100) as realTimeX, rand(10.0, 100) as predictY, rand(10.0, 100) as price)
appendOrcaStreamTable("trades", data)