示例
针对 https://calc.dev.emrgex.com 的可复制粘贴示例。所有利率均为小数(0.10 = 10%),价格按每 100 面值计,日期采用 ISO 格式。
按收益率为已存储债券定价
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 } }
]
}'
从净价反解收益率
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 } }
]
}'
为临时(ad-hoc)债券定价
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 } }
]
}'
按交易规模计算结算资金
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_amount、accrued_amount、dirty_amount = 结算资金、quantity)。
批量计算——一次性为多个报价定价
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;某一条失败绝不会影响其余报价。
可赎回债券——最差收益率(yield-to-worst)
按价格对可赎回债券报价,并请求计算最差收益率:
... "input_kind": "clean_price", "input_value": 101.5, "options": { "yield_worst": true } ...
结果中的 metrics.yield_to_worst 为 min(到期收益率,每个赎回日收益率)。
指数挂钩债券(巴西 NTN-B、墨西哥 UDIBONO)
通过 index_ratio 提供估值时点已公布的指数名义本金(VNA);所有金额类输出都会乘以 index_ratio/100:
... "options": { "index_ratio": 4250.123456, "round": 6 } ...
形态类指标(yield、久期、凸度)为无量纲指标,不受影响。
区域惯例
| 市场 | 典型惯例 |
|---|---|
| 巴西(LTN / NTN-F) | day_count: BUS/252(营业日,ANBIMA 日历) |
| 墨西哥(Bonos M / CETES) | NOMINAL / AT_MATURITY,配合相应的 ACT 计息基准 |
| 多米尼加共和国(财政部债券) | day_count: ACT/ACT.DRMH + discount_day_count: ACT/ACT.ICMA |
这些惯例在已存储的目录中已预先设置好;对于临时债券,请在工具(instrument)上自行设置。参见惯例。
:::tip Going fast
对于大批量请求,请省略 with_cashflows(响应体积更小、速度更快),并发送一个大批次,而非多个单条请求。
:::