Skip to main content
Glama

calculate_bond_price

Calculate bond price using face value, coupon rate, yield rate, and maturity period to determine current market value for investment analysis.

Instructions

Calculate bond price given yield and terms

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
couponRateYesAnnual coupon rate as decimal
faceValueYes
frequencyNoCoupon payments per year
yearsYes
yieldRateYesRequired yield as decimal

Implementation Reference

  • The tool handler function that invokes the Python implementation via PythonBridge.
    handler: async (args: any): Promise<ToolResult> => { try { const result = await pythonBridge.callPythonFunction({ module: 'financial_calculations', function: 'FinancialCalculator.bond_price', args: [args.faceValue, args.couponRate, args.yieldRate, args.years, args.frequency || 2] }); return result; } catch (error) { return { success: false, error: error instanceof Error ? error.message : String(error) }; } }
  • Input schema defining parameters for the calculate_bond_price tool.
    inputSchema: { type: "object", properties: { faceValue: { type: "number" }, couponRate: { type: "number", description: "Annual coupon rate as decimal" }, yieldRate: { type: "number", description: "Required yield as decimal" }, years: { type: "number" }, frequency: { type: "number", default: 2, description: "Coupon payments per year" } }, required: ["faceValue", "couponRate", "yieldRate", "years"] },
  • Registration of the calculate_bond_price tool in the financialTools array, which is imported and used in the MCP server.
    { name: "calculate_bond_price", description: "Calculate bond price given yield and terms", inputSchema: { type: "object", properties: { faceValue: { type: "number" }, couponRate: { type: "number", description: "Annual coupon rate as decimal" }, yieldRate: { type: "number", description: "Required yield as decimal" }, years: { type: "number" }, frequency: { type: "number", default: 2, description: "Coupon payments per year" } }, required: ["faceValue", "couponRate", "yieldRate", "years"] }, handler: async (args: any): Promise<ToolResult> => { try { const result = await pythonBridge.callPythonFunction({ module: 'financial_calculations', function: 'FinancialCalculator.bond_price', args: [args.faceValue, args.couponRate, args.yieldRate, args.years, args.frequency || 2] }); return result; } catch (error) { return { success: false, error: error instanceof Error ? error.message : String(error) }; } } },
  • Core implementation of bond price calculation: present value of coupon payments plus face value.
    @staticmethod def bond_price(face_value: float, coupon_rate: float, yield_rate: float, years: int, frequency: int = 2) -> float: """Calculate bond price""" periods = years * frequency coupon_payment = (face_value * coupon_rate) / frequency period_yield = yield_rate / frequency pv_coupons = sum(coupon_payment / ((1 + period_yield) ** i) for i in range(1, periods + 1)) pv_face = face_value / ((1 + period_yield) ** periods) return pv_coupons + pv_face

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jeremycharlesgillespie/excel-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server