Fixed income and term structure analytics
calculate_fixed_incomeFixed-income engine. Price plain coupon bonds, solve for yield to maturity, measure interest-rate sensitivity via Macaulay and modified duration and convexity, and build a HIBOR/HKD-style term structure: bootstrap a zero curve from par rates, infer forward rates, and discount cash flows on the curve. Use this for vanilla bonds, rate risk and discount curves; for convertibles use calculate_convertible_bond and for structured payoffs use calculate_structured_product. Methods: bond_price/duration/convexity: face, coupon_rate, years, ytm, frequency; bond_yield: face, coupon_rate, years, price, frequency; matrix_pricing: target_tenor, benchmark_tenors, benchmark_yields; discount_factor: rate, years, frequency; zero_curve: par_rates, tenors, frequency; forward_rate: zero_rates, tenors, t1, t2; pv_curve: cash_flows, times, zero_rates, tenors. Supply exactly one method with its declared inputs (no defaults). An unknown method, a missing input, or an extra field returns an error envelope (code INVALID_ARGUMENT) instead of raising.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| t1 | No | Forward period start in years (>=0). | |
| t2 | No | Forward period end in years (> t1). | |
| ytm | No | Yield to maturity (decimal, annualised). | |
| face | No | Bond face value. | |
| rate | No | A single interest/zero rate (decimal). | |
| price | No | Dirty price of the instrument in reporting currency. | |
| times | No | Cash-flow times in years, aligned with cash_flows. | |
| years | No | Number of projection years n; equal len(cash_flows) when both are supplied. | |
| method | Yes | Formula to apply; the tool description lists the exact inputs each value requires. | |
| tenors | No | Tenors in years, aligned with par_rates or zero_rates. | |
| frequency | No | Coupon payments per year (1=annual, 2=semi-annual). | |
| par_rates | No | Par (coupon) rates per tenor, aligned with tenors (decimal). | |
| cash_flows | No | Projected cash flows in reporting currency, indexed t=1..n. | |
| zero_rates | No | Zero (spot) rates per tenor, decimal, annual compounding. | |
| coupon_rate | No | Annual coupon rate (decimal). | |
| target_tenor | No | Target tenor in years for matrix pricing (interpolated). | |
| benchmark_tenors | No | Benchmark tenors in years, sorted, aligned with benchmark_yields. | |
| benchmark_yields | No | Benchmark yields (decimal) at each benchmark tenor. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| error | No | Error detail, present only when status='error'. | |
| steps | No | Ordered computation steps, when the method reports them. | |
| value | No | Primary result: a number for scalar methods, an object for valuation methods. | |
| method | No | Method or tool name that produced the result. | |
| status | Yes | 'ok' on success, 'error' on failure. | |
| ticker | No | Ticker the result pertains to, when applicable. | |
| assumptions | No | Inputs and assumptions used, echoed for traceability. | |
| formula_ref | No | Formula or standards reference for the method. | |
| data_timestamp | No | ISO-8601 UTC timestamp of the underlying data, when fetched. |