dsh-finance:DeepSeek Harness 财务计算插件

前言

DeepSeek Harness (DSH) 通过插件机制扩展智能体的能力。代理在处理金钱相关计算时容易产生幻觉,例如复利、PMT 公式、IRR 计算等。dsh-finance 插件通过确定性工具调用解决了这一问题,提供纯算术的金融计算能力。

插件概览

插件名称:tyeclipse/dsh-finance
维护者:TYEclipse
核心定位:Money math toolbox for DeepSeek Harness (dsh)。提供贷款还款、复利增长、利率转换、现金流分析、退休规划和通胀调整等功能。该插件零运行时依赖,完全基于算术运算,不涉及网络或文件系统访问。

核心功能

插件提供了以下工具:

  1. loan_payment:固定利率贷款还款计算,支持可选的摊销计划(上限 360 行)和每月额外本金支付。
  2. compound_growth:本金与未来价值计算,支持每月定投,提供多种复利频率(日、月、季、半年、年、连续)。
  3. rate_convert:名义年利率 (APR) 与有效年利率 (EAR) 转换,支持连续复利计算。
  4. cashflow_analysis:现金流分析,计算 NPV、IRR(使用二分法)以及简单/折现回收期。处理无符号变化或多符号变化的情况。
  5. retirement_plan:退休规划,计算固定提取下的耗尽时间或可持续月供。
  6. savings_goal:储蓄目标规划,计算达成目标所需的月数或所需月供。
  7. inflation_adjust:通胀调整,计算购买力变化及 Fisher 真实回报率。

安装与启用

使用 DeepSeek Harness 的 Web Profile 安装插件:

dsh plugin --profile web add github:TYEclipse/dsh-finance

安装完成后,可以通过以下命令验证插件层是否挂载:

dsh --profile web --dump-config | grep '=='

典型用法

插件支持以下典型场景的计算:

  • 房贷计算:

    • 输入:loan_payment { principal: 300000, annual_rate_percent: 4, months: 360 }
    • 输出:monthly_payment 1432.25, total_interest 215610, total_paid 515610
  • 复利增长:

    • 输入:compound_growth { principal: 1000, annual_rate_percent: 5, years: 10, compounding: "monthly", contribution_per_month: 100 }
    • 输出:future_value 17175.24 (contributions 13000, interest 4175.24)
  • 利率转换:

    • 输入:rate_convert { rate_percent: 12, input_kind: "nominal", compounding: "monthly" }
    • 输出:output_rate_percent 12.682503 (effective EAR)
  • IRR 与 NPV:

    • 输入:cashflow_analysis { cash_flows: [-70000, 12000, 15000, 18000, 21000, 26000], discount_rate_percent: 8 }
    • 输出:npv 1390.96, irr_percent 8.663095, payback_periods 4.15
  • 退休规划:

    • 输入:retirement_plan { principal: 1000000, annual_rate_percent: 4, monthly_withdrawal: 4000, years: 30 }
    • 输出:months_to_exhaust 538.42, withdrawal_rate_percent 4.8, lasts_horizon true
  • 储蓄目标:

    • 输入:savings_goal { target_amount: 50000, current_savings: 10000, annual_rate_percent: 5, monthly_contribution: 500 }
    • 输出:months_to_goal 65, final_balance 50341.48
  • 所需月供:

    • 输入:savings_goal { target_amount: 100000, current_savings: 20000, annual_rate_percent: 6, months: 240 }
    • 输出:required_monthly_contribution 73.15, projected_balance 100002.38
  • 通胀调整:

    • 输入:inflation_adjust { amount: 1000, annual_inflation_percent: 2.5, years: 10, nominal_rate_percent: 6 }
    • 输出:future_cost 1280.08, real_value 781.20, real_rate_percent 3.414634

细节与注意事项

  • 零依赖:插件不依赖任何外部运行时,纯算术运算,安全且快速。
  • 精度处理:金额仅在输出边界处舍入到分,内部计算保持高精度。
  • 特殊场景:支持零利率计算,明确报告现金流符号变化情况,支持负通胀(通缩)计算。
  • IRR 计算:仅在现金流符号变化一次且存在根时返回结果,否则返回无符号变化或根不唯一提示。
  • 可持续提取:使用与银行对账一致的舍入方法计算可持续月供。

总结

dsh-finance 是一个为 DSH 插件体系设计的金融计算工具箱,解决了大模型在金钱数学上的常见幻觉问题。它通过提供确定的函数调用,帮助开发者构建更可靠的财务分析智能体。

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

小夜