Fixed Income Mcp

io.github.joselillotrax-cell由 GitHub 帳號 joselillotrax-cell 發布v0.1.3更新於 Oct 24, 2026

Bond pricing, duration, DV01 and convexity for AI agents, with numerical cross-checks built in.

發布方自己的服務:FixedLink

已驗證STDIO僅桌面金融資料與分析

概覽

AI 產生的概覽

讓助理為固定利率債券定價、計算存續期間、DV01 與凸性,並透過內建數值交叉檢查稽核殖利率。

可以做什麼
提供六個固定收益計算工具:由價格求解到期殖利率、由殖利率計算乾淨價與全價、債券分析(存續期間、DV01、凸性)、含折現因子的現金流量表、將精確重新定價與一階及二階估計相比的情境衝擊,以及稽核他人給出殖利率的一致性檢查。解析存續期間會與不依賴慣例的數值有效存續期間相互驗證,每次評價都會回傳 all_checks_passed 旗標及其依據的界限。參數名稱自帶單位,例如 coupon_rate_pct 與 clean_price_pct_of_face。
適用情境
適合助理必須真正計算債券數學而非估算的情況,例如查核同事或其他模型給出的殖利率、比較兩檔債券的利率風險,或執行利率衝擊情境。它是教學與查核工具,不是交易系統。
執行需求
以 stdio 方式作為本機程序執行,從 PyPI 安裝 bondmath 套件(pip install bondmath),該套件同時安裝 MCP SDK。在用戶端設定中註冊 fixed-income-mcp 指令;若找不到該指令,請使用其絕對路徑。未宣告任何帳號、API 金鑰或環境變數。
安裝前請注意
僅做唯讀計算:工具用於定價、衡量與稽核,不會下單或移轉資金。結果取決於輸入,README 說明該程式庫不涵蓋內嵌選擇權、浮動票息、償債基金、攤銷結構、除息慣例、信用風險與結算時滯。在 macOS 上,安裝於 Desktop、Documents 或 Downloads 內可能需要為啟動的子程序明確授予權限。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Fixed Income Mcp,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

fixed-income-mcp

Fixed-income analytics for AI agents, with the checks that catch the errors models actually make.

Prices fixed-coupon bonds and measures their interest-rate sensitivity. Two things separate it from a calculator: every analytic duration is validated against a convention-free numerical one, and every valuation is tested against the bounds a correct answer has to satisfy.

The pricing and analytics core (bondmath.bond, .pricing, .analytics, .checks, .daycount, .schedule) is pure standard library. The package as distributed also installs the MCP SDK, required by bondmath.server — see As an MCP server for why that dependency isn't optional.


Why

A language model asked for the modified duration of an ordinary bond returned 3.0942 years. The correct value is 3.1686. It had divided Macaulay duration by one plus the annual yield instead of one plus the periodic yield — the wrong divisor for a bond paying twice a year.

Then it did something more interesting. Its own duration-plus-convexity approximation stopped matching an exact repricing, and it explained the gap as "third-order terms of the Taylor series." For a bond of that maturity and a 100 bp move, the genuine third-order term is 0.09 bp. The residual it was explaining came from its own miscalculated duration, handed back as theory.

A separate session returned a 4.01% yield for a bond trading at 97.80% of par — below the 4.09% current yield, and therefore outside the range of possible answers.

The full write-up is at joselillotrax-cell/bond-desk.

This library is the answer to it: give the agent a tool that does the arithmetic correctly, and have the tool say so out loud.

Design

Bisection, not Newton-Raphson. Newton converges faster but can diverge, or settle on a value that satisfies the iteration without solving the pricing equation. That is exactly the 4.01% failure. Bisection cannot do it.

Effective duration ships alongside the analytic one. Central differences on the pricing function involve no annualisation, so the numerical figure cannot inherit a convention error. When the two disagree, the analytic one is wrong.

The wrong answer is computed on purpose. Analytics.naive_modified carries the figure the bad divisor produces. Unusual for a library, but it is what lets the tools flag the error rather than silently avoid it.

Use

python
from datetime import datefrom bondmath import Bond, DayCount, yield_from_price, analytics, check_consistency
bond = Bond(    face=1000,    coupon_rate=0.04,    frequency=2,    issue=date(2024, 3, 15),    maturity=date(2029, 3, 15),    basis=DayCount.ACT_ACT_ICMA,)settle = date(2025, 9, 11)
quote = yield_from_price(bond, settle, 978.00)   # 97.80% of parprint(f"{quote.dirty:.4f}")          # 997.5652print(f"{quote.ytm:.4%}")            # 4.6867%
metrics = analytics(bond, settle, quote.ytm)print(f"{metrics.modified:.4f}")     # 3.1686  <- correctprint(f"{metrics.naive_modified:.4f}")  # 3.0976  <- the common errorprint(f"{metrics.effective:.4f}")    # 3.1694  <- numerical arbiter
print(check_consistency(bond, settle, quote, metrics))# [PASS] below_par_ordering: trading below par at 97.8000%, so#        coupon < current yield < YTM must hold: 4.0000% < 4.0900% < 4.6867%# ...

Scenario analysis isolates the true higher-order residual:

python
from bondmath import scenario
s = scenario(bond, settle, quote.ytm, shock_bp=100)print(f"{s.exact:.2f}")          # 966.55print(f"{s.residual_bp:+.2f}")   # +0.09 bp, not the six the model claimed

Conventions

ACT/ACT ICMA, 30/360 (US bond basis), ACT/365 and ACT/360. Annual, semi-annual, quarterly and monthly coupons. Schedules are generated backward from maturity, so an off-cycle issue produces a correctly handled irregular first period.

As an MCP server

Six tools, so an agent can stop doing this arithmetic in its head.

ToolDoes
yield_from_price_toolSolves yield to maturity from a market price
price_from_yield_toolClean and dirty price at a given yield
bond_analytics_toolDuration, DV01, convexity — with both cross-checks
cashflow_schedule_toolRemaining flows, discount factors, present values
scenario_shock_toolExact repricing vs first- and second-order estimates
check_consistency_toolAudits a yield someone else produced

Two decisions make these usable by a model rather than merely callable.

Units live in the parameter names. A field called coupon_rate invites the question of whether 4% is 4 or 0.04, and a wrong guess is off by a factor of a hundred while looking reasonable. Everything here is coupon_rate_pct, clean_price_pct_of_face, ytm_pct. Nothing to guess.

Every valuation returns its own verdict. Results carry an all_checks_passed flag and the list of bounds behind it, so the model sees whether the number is admissible, not just what it is.

Install

bash
pip install bondmath

mcp is a required dependency rather than an optional extra — the MCP registry validates a package's identifier against PyPI by exact project name, and an extras-qualified name like bondmath[mcp] fails that check. A plain install has to be enough to run the server.

Then register it. In Claude Desktop, add to claude_desktop_config.json:

json
{  "mcpServers": {    "fixed-income": {      "command": "fixed-income-mcp"    }  }}

In Claude Code:

bash
claude mcp add fixed-income -- fixed-income-mcp

If the command isn't found: the pip-installed script may not be on the launching process's PATH. Use the absolute path instead — find it with which fixed-income-mcp (inside the environment you installed into) and put that full path in command.

If you're on macOS and the server shows "disconnected" with no clear error: check ~/Library/Logs/Claude/mcp-server-fixed-income.log before anything else — the panel's error message is not the real one. Two macOS specifics bit this project during development: Python 3.14 silently skips hidden .pth files, and iCloud Drive can mark files inside ~/Desktop as hidden without warning; separately, ~/Desktop, ~/Documents and ~/Downloads require an explicit permission grant for a launched subprocess to read from at all. Installing outside those folders (~/dev, ~/code, anywhere not cloud-synced) avoids both.

In practice

Three exchanges from testing this against Claude Desktop, exercised with natural-language questions rather than pre-filled parameters and cross-checked independently against each tool's own output:

"Un compañero me dice que un bono al 4% semestral... cotizando al 97,80%, rinde un 4,01%. ¿Tiene sentido?" — called check_consistency_tool directly rather than recomputing from scratch, correctly identified the 67.67 bp error, and explained why without needing to iterate: "el bono cotiza bajo par, así que obligatoriamente cupón < rendimiento corriente < TIR."

"Un bono al 3,5% que vence en 2032 cotiza a 96,4. ¿Qué rentabilidad me da?" — face value, issue date and payment frequency were all missing. The schema's required issue_date field rejected the first call attempt (MCP error -32602: invalid_type); the model disclosed the assumption it then made rather than silently inventing it, and computed both semi-annual and annual scenarios to show the frequency assumption barely moved the answer.

"¿Cuál tiene más riesgo de tipos: el A (4%, vence 2029, cotiza a 98) o el B (2%, vence 2035, cotiza a 85)?" — two chained tool calls, correct verdict (B, 7.43 years vs 2.14), and an explanation that separated the two forces at work: longer maturity and a low coupon that pushes more of the bond's value into the final principal payment. It also flagged, unprompted, that comparing DV01 in currency terms gives a different ratio than comparing modified duration in percentage terms, since the two bonds don't trade at the same price.

Auditing a suspect figure

check_consistency_tool exists for the case that started this project — checking a number someone already produced:

claimed_ytm_pct        4.01correct_ytm_pct        4.686736error_bp               -67.67all_checks_passed      false
[FAIL] below_par_ordering: trading below par at 97.8000%, so       coupon < current yield < YTM must hold:       4.0000% < 4.0900% < 4.0100%

Install for development

bash
pip install -e ".[dev]"python -m pytest -q

59 tests. Some pin the numbers in the write-up: if someone ever swaps the divisor back, test_naive_divisor_is_the_one_that_disagrees fails. Others guard the MCP schema itself — test_every_parameter_carries_a_description exists because an earlier version of this server shipped with none, which a model could only have discovered by guessing.

Not covered

Embedded optionality, floating coupons, sinking funds, amortising structures, ex-dividend conventions, credit risk and settlement lag. A teaching and checking instrument, not a trading system.

License

MIT.

來源:README.md,提交 bf5e5d6

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

2
  1. v0.1.3最新Sep 16, 2026
  2. v0.1.2Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分

其他 Fixed 整合