Language

Choose a language

/build/rpc / pricing / forward

pricing.forward.quote

pricing.forward.quote "source_type" ( "registry_id" {"alice_deliver_asset":"hex","alice_deliver_is_native":bool,"alice_deliver_units":n,"alice_im_asset":"hex","alice_im_is_native":bool,"alice_im_units":n,"bob_deliver_asset":"hex","bob_deliver_is_native":bool,"bob_deliver_units":n,"bob_im_asset":"hex","bob_im_is_native":bool,"bob_im_units":n,"premium_asset":"hex","premium_is_native":bool,"premium_units":n,"deadline_short":n,"safety_k":n} "report_asset" report_is_native compute_greeks "price_source" ) Compute mark-to-market valuation for a forward (IM-capped DvP) contract Supports both registry-backed contracts and inline term specification. Arguments: 1. source_type (string, required) Contract source: 'registry' or 'inline' 2. registry_id (string, optional) Registry contract ID 3. inline_terms (json object, optional) Inline forward terms { "alice_deliver_asset": "hex", (string, optional) Alice delivery asset (omit if is_native) "alice_deliver_is_native": bool, (boolean, optional, default=false) Alice delivers native BTC "alice_deliver_units": n, (numeric, required) Alice delivery units "alice_im_asset": "hex", (string, optional) Alice IM asset (omit if is_native) "alice_im_is_native": bool, (boolean, optional, default=false) Alice IM is native BTC "alice_im_units": n, (numeric, required) Alice IM units "bob_deliver_asset": "hex", (string, optional) Bob delivery asset (omit if is_native) "bob_deliver_is_native": bool, (boolean, optional, default=false) Bob delivers native BTC "bob_deliver_units": n, (numeric, required) Bob delivery units "bob_im_asset": "hex", (string, optional) Bob IM asset (omit if is_native) "bob_im_is_native": bool, (boolean, optional, default=false) Bob IM is native BTC "bob_im_units": n, (numeric, required) Bob IM units "premium_asset": "hex", (string, optional, default="") Premium asset (omit if is_native) "premium_is_native": bool, (boolean, optional, default=false) Premium is native BTC "premium_units": n, (numeric, optional, default=0) Premium units "deadline_short": n, (numeric, required) Bob's deadline (block height) "safety_k": n, (numeric, optional, default=144) Safety window blocks } 4. report_asset (string, optional, default="") Reporting currency 5. report_is_native (boolean, optional, default=false) Reporting currency is native BTC 6. compute_greeks (boolean, optional, default=true) Compute spread option Greeks 7. price_source (string, optional, default="mark") Price source: 'mark' or 'market' Result: { (json object) "pv_receive" : n, (numeric) PV of Alice's receipt (Bob delivers to Alice) "pv_pay" : n, (numeric) PV of Alice's payment (Alice delivers to Bob) "net_spread_value" : n, (numeric) pv_receive - pv_pay "premium_pv" : n, (numeric) Premium PV (paid at t=0) "alice_short_call_value" : n, (numeric) Alice's short call on Bob's IM "alice_long_put_value" : n, (numeric) Alice's long put on her own IM "alice_mtm" : n, (numeric) Alice's total mark-to-market "bob_mtm" : n, (numeric) Bob's mark-to-market (-alice_mtm) "im_coverage_alice" : n, (numeric) IM coverage ratio for Alice "im_coverage_bob" : n, (numeric) IM coverage ratio for Bob "spot_A0" : n, (numeric) Spot of pay_leg asset (A) in report currency "spot_B0" : n, (numeric) Spot of receive_leg asset (B) in report currency "spot_C0" : n, (numeric) Spot of Alice IM asset (C) in report currency "spot_D0" : n, (numeric) Spot of Bob IM asset (D) in report currency "model_unreliable" : true|false, (boolean) True if walkaway options could not be priced reliably "spread_greeks_call" : { (json object, optional) Greeks for short call component "delta_A" : n, (numeric) Delta w.r.t. asset A "delta_B" : n, (numeric) Delta w.r.t. asset B "gamma_A" : n, (numeric) Gamma w.r.t. asset A "gamma_B" : n, (numeric) Gamma w.r.t. asset B "vega_A" : n, (numeric) Vega w.r.t. vol of A "vega_B" : n, (numeric) Vega w.r.t. vol of B "theta" : n, (numeric) Time decay "rho_rate" : n (numeric) Interest rate sensitivity }, "spread_greeks_put" : { (json object, optional) Greeks for long put component "delta_A" : n, (numeric) Delta w.r.t. asset A "delta_B" : n, (numeric) Delta w.r.t. asset B "gamma_A" : n, (numeric) Gamma w.r.t. asset A "gamma_B" : n, (numeric) Gamma w.r.t. asset B "vega_A" : n, (numeric) Vega w.r.t. vol of A "vega_B" : n, (numeric) Vega w.r.t. vol of B "theta" : n, (numeric) Time decay "rho_rate" : n (numeric) Interest rate sensitivity }, "asset_greeks" : { (json object, optional) Per-leg Greeks for portfolio aggregation "delta" : [ (json array) Spot delta for {receive, pay, im_alice, im_bob} n, (numeric) Delta element ... ], "vega" : [ (json array) Vega for {receive, pay, im_alice, im_bob} n, (numeric) Vega element ... ], "gamma" : [ (json array) Gamma for {receive, pay, im_alice, im_bob} n, (numeric) Gamma element ... ], "cross_gamma" : [ (json array) 4x4 cross-gamma matrix [ (json array) n, (numeric) Cross-gamma element ... ], ... ], "rate_delta" : [ (json array) Rate delta for {r_receive, r_pay, r_im_alice, r_im_bob, r_report} n, (numeric) Rate delta element ... ] }, "warnings" : [ (json array) Diagnostic warnings { (json object) "severity" : "str", (string) WARNING, CRITICAL, INFO "category" : "str", (string) coverage, deadline, market_data, model "message" : "str", (string) Human-readable message "threshold" : n (numeric, optional) Threshold value if applicable }, ... ] } Examples: > bitcoin-cli pricing.forward.quote "registry" "CONTRACT_ID" > curl --user myusername --data-binary '{"jsonrpc": "2.0", "id": "curltest", "method": "pricing.forward.quote", "params": ["inline", "", {"alice_deliver_asset":"...", ...}]}' -H 'content-type: application/json' http://127.0.0.1:8332/

Signature

pricing.forward.quote(source_type: string, registry_id?: string, inline_terms?: object, report_asset?: string, report_is_native?: boolean, compute_greeks?: boolean, price_source?: string) → any

Code samples

curl --user "$RPC_USER:$RPC_PASS" \
  --data-binary '{"jsonrpc":"1.0","id":"docs","method":"pricing.forward.quote","params":["\"<source_type>\"","\"<registry_id>\"",{},"",false,true,"mark"]}' \
  -H 'content-type: text/plain;' \
  http://127.0.0.1:8332/

Parameters

NameTypeReq.Description
source_typestringyesContract source: 'registry' or 'inline'
registry_idstringRegistry contract ID
inline_termsobjectInline forward terms { "alice_deliver_asset": "hex", (string, optional) Alice delivery asset (omit if is_native) "alice_deliver_is_native": bool, (boolean, optional, default=false) Alice delivers native BTC "alice_deliver_units": n, (numeric, required) Alice delivery units "alice_im_asset": "hex", (string, optional) Alice IM asset (omit if is_native) "alice_im_is_native": bool, (boolean, optional, default=false) Alice IM is native BTC "alice_im_units": n, (numeric, required) Alice IM units "bob_deliver_asset": "hex", (string, optional) Bob delivery asset (omit if is_native) "bob_deliver_is_native": bool, (boolean, optional, default=false) Bob delivers native BTC "bob_deliver_units": n, (numeric, required) Bob delivery units "bob_im_asset": "hex", (string, optional) Bob IM asset (omit if is_native) "bob_im_is_native": bool, (boolean, optional, default=false) Bob IM is native BTC "bob_im_units": n, (numeric, required) Bob IM units "premium_asset": "hex", (string, optional, default="") Premium asset (omit if is_native) "premium_is_native": bool, (boolean, optional, default=false) Premium is native BTC "premium_units": n, (numeric, optional, default=0) Premium units "deadline_short": n, (numeric, required) Bob's deadline (block height) "safety_k": n, (numeric, optional, default=144) Safety window blocks }
report_assetstringReporting currency
report_is_nativebooleanReporting currency is native BTC
compute_greeksbooleanCompute spread option Greeks
price_sourcestringPrice source: 'mark' or 'market'

Result

Type:  any

{ (json object) "pv_receive" : n, (numeric) PV of Alice's receipt (Bob delivers to Alice) "pv_pay" : n, (numeric) PV of Alice's payment (Alice delivers to Bob) "net_spread_value" : n, (numeric) pv_receive - pv_pay "premium_pv" : n, (numeric) Premium PV (paid at t=0) "alice_short_call_value" : n, (numeric) Alice's short call on Bob's IM "alice_long_put_value" : n, (numeric) Alice's long put on her own IM "alice_mtm" : n, (numeric) Alice's total mark-to-market "bob_mtm" : n, (numeric) Bob's mark-to-market (-alice_mtm) "im_coverage_alice" : n, (numeric) IM coverage ratio for Alice "im_coverage_bob" : n, (numeric) IM coverage ratio for Bob "spot_A0" : n, (numeric) Spot of pay_leg asset (A) in report currency "spot_B0" : n, (numeric) Spot of receive_leg asset (B) in report currency "spot_C0" : n, (numeric) Spot of Alice IM asset (C) in report currency "spot_D0" : n, (numeric) Spot of Bob IM asset (D) in report currency "model_unreliable" : true|false, (boolean) True if walkaway options could not be priced reliably "spread_greeks_call" : { (json object, optional) Greeks for short call component "delta_A" : n, (numeric) Delta w.r.t. asset A "delta_B" : n, (numeric) Delta w.r.t. asset B "gamma_A" : n, (numeric) Gamma w.r.t. asset A "gamma_B" : n, (numeric) Gamma w.r.t. asset B "vega_A" : n, (numeric) Vega w.r.t. vol of A "vega_B" : n, (numeric) Vega w.r.t. vol of B "theta" : n, (numeric) Time decay "rho_rate" : n (numeric) Interest rate sensitivity }, "spread_greeks_put" : { (json object, optional) Greeks for long put component "delta_A" : n, (numeric) Delta w.r.t. asset A "delta_B" : n, (numeric) Delta w.r.t. asset B "gamma_A" : n, (numeric) Gamma w.r.t. asset A "gamma_B" : n, (numeric) Gamma w.r.t. asset B "vega_A" : n, (numeric) Vega w.r.t. vol of A "vega_B" : n, (numeric) Vega w.r.t. vol of B "theta" : n, (numeric) Time decay "rho_rate" : n (numeric) Interest rate sensitivity }, "asset_greeks" : { (json object, optional) Per-leg Greeks for portfolio aggregation "delta" : [ (json array) Spot delta for {receive, pay, im_alice, im_bob} n, (numeric) Delta element ... ], "vega" : [ (json array) Vega for {receive, pay, im_alice, im_bob} n, (numeric) Vega element ... ], "gamma" : [ (json array) Gamma for {receive, pay, im_alice, im_bob} n, (numeric) Gamma element ... ], "cross_gamma" : [ (json array) 4x4 cross-gamma matrix [ (json array) n, (numeric) Cross-gamma element ... ], ... ], "rate_delta" : [ (json array) Rate delta for {r_receive, r_pay, r_im_alice, r_im_bob, r_report} n, (numeric) Rate delta element ... ] }, "warnings" : [ (json array) Diagnostic warnings { (json object) "severity" : "str", (string) WARNING, CRITICAL, INFO "category" : "str", (string) coverage, deadline, market_data, model "message" : "str", (string) Human-readable message "threshold" : n (numeric, optional) Threshold value if applicable }, ... ] }

Source: services/core-node/bcore/src/wallet/pricing/rpc/pricing_forward.cpp:65

C++ symbol: pricing_forward_quote