跳至主要内容

Examples

可直接複製貼上、針對 https://calc.dev.emrgex.com 執行的範例。所有利率均為小數(0.10 = 10%), 價格以每 100 面額計,日期採用 ISO 格式。

Price a stored bond by yield

curl -s https://calc.dev.emrgex.com/v1/quotes -H 'content-type: application/json' -d '{
"quotes": [
{ "instrument_id": "MH12034", "input_kind": "yield", "input_value": 0.10,
"settlement_date": "2026-06-09", "options": { "round": 6 } }
]
}'

Solve a yield from a clean price

curl -s https://calc.dev.emrgex.com/v1/quotes -H 'content-type: application/json' -d '{
"quotes": [
{ "instrument_id": "MH12034", "input_kind": "clean_price", "input_value": 107.85,
"settlement_date": "2026-06-09", "options": { "round": 6 } }
]
}'

Price an ad-hoc bond

curl -s https://calc.dev.emrgex.com/v1/quotes -H 'content-type: application/json' -d '{
"instruments": [
{ "id": "B1", "rate_type": "NOMINAL", "day_count": "ACT/ACT.ICMA", "coupon_type": "FIXED",
"frequency": 2, "start": "2020-01-15", "maturity": "2030-01-15",
"coupon_rate": 0.06, "face_value": 100 }
],
"quotes": [
{ "instrument_id": "B1", "input_kind": "clean_price", "input_value": 95.5,
"settlement_date": "2024-06-18", "options": { "round": 6 } }
]
}'

Settlement cash for a trade size

curl -s https://calc.dev.emrgex.com/v1/quotes -H 'content-type: application/json' -d '{
"quotes": [
{ "instrument_id": "MH12034", "input_kind": "yield", "input_value": 0.10,
"amount_kind": "nominal", "amount_value": 1000000,
"settlement_date": "2026-06-09", "options": { "round": 6 } }
]
}'

結果會新增一個 amounts 區塊(clean_amountaccrued_amountdirty_amount = 交割 現金、quantity)。

Batch — price many at once

curl -s https://calc.dev.emrgex.com/v1/quotes -H 'content-type: application/json' -d '{
"quotes": [
{ "instrument_id": "MH12034", "input_kind": "yield", "input_value": 0.10, "settlement_date": "2026-06-09" },
{ "instrument_id": "MH12034", "input_kind": "yield", "input_value": 0.11, "settlement_date": "2026-06-09" },
{ "instrument_id": "MH12034", "input_kind": "clean_price", "input_value": 105.0, "settlement_date": "2026-06-09" }
]
}'

每一筆報價會各自回傳自己的 status;任何一筆失敗都不會影響其餘報價。

Callable bond — yield-to-worst

以價格為可贖回債券(callable bond)報價,並要求取得最差收益率:

... "input_kind": "clean_price", "input_value": 101.5, "options": { "yield_worst": true } ...

結果中的 metrics.yield_to_worstmin(到期收益率與每一個贖回收益率中的最小值)。

Index-linked bond (Brazil NTN-B, Mexico UDIBONO)

透過 index_ratio 提供估值時點所公布的指數名目本金(VNA);每一項貨幣輸出都會 乘以 index_ratio/100

... "options": { "index_ratio": 4250.123456, "round": 6 } ...

形態類指標(yield、duration、convexity)為無單位指標,不受影響。

Regional conventions

MarketTypical convention
Brazil (LTN / NTN-F)day_count: BUS/252(營業日,ANBIMA 行事曆)
Mexico (Bonos M / CETES)NOMINAL / AT_MATURITY,搭配對應的 ACT 基準
Dominican Rep. (MoH bonds)day_count: ACT/ACT.DRMH + discount_day_count: ACT/ACT.ICMA

在已儲存的目錄中,這些慣例皆已預先設定;對於臨時(ad-hoc)債券,請於工具(instrument)上自行設定。詳見 Conventions

:::tip Going fast 對於大型批次,請省略 with_cashflows(回應更小、更快),並送出單一個大型 批次,而非多筆單一請求。 :::