effective_annual_rate
Calculate the effective annual interest rate from a nominal rate and compounding frequency to accurately compare investment returns or loan costs.
Instructions
Calculate effective annual rate from nominal rate
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| compoundingPeriods | Yes | Number of compounding periods per year | |
| nominalRate | Yes | Nominal annual rate as decimal |
Implementation Reference
- src/tools/financial-tools.ts:290-304 (handler)Handler function that executes the tool by calling the Python FinancialCalculator.effective_annual_rate via the Python bridge.handler: async (args: any): Promise<ToolResult> => { try { const result = await pythonBridge.callPythonFunction({ module: 'financial_calculations', function: 'FinancialCalculator.effective_annual_rate', args: [args.nominalRate, args.compoundingPeriods] }); return result; } catch (error) { return { success: false, error: error instanceof Error ? error.message : String(error) }; } }
- src/tools/financial-tools.ts:282-289 (schema)Input schema defining the parameters nominalRate (float) and compoundingPeriods (int) for the tool.inputSchema: { type: "object", properties: { nominalRate: { type: "number", description: "Nominal annual rate as decimal" }, compoundingPeriods: { type: "number", description: "Number of compounding periods per year" } }, required: ["nominalRate", "compoundingPeriods"] },
- src/tools/financial-tools.ts:279-305 (registration)Full tool registration object added to the financialTools array, which is imported and spread into the main MCP tools list.{ name: "effective_annual_rate", description: "Calculate effective annual rate from nominal rate", inputSchema: { type: "object", properties: { nominalRate: { type: "number", description: "Nominal annual rate as decimal" }, compoundingPeriods: { type: "number", description: "Number of compounding periods per year" } }, required: ["nominalRate", "compoundingPeriods"] }, handler: async (args: any): Promise<ToolResult> => { try { const result = await pythonBridge.callPythonFunction({ module: 'financial_calculations', function: 'FinancialCalculator.effective_annual_rate', args: [args.nominalRate, args.compoundingPeriods] }); return result; } catch (error) { return { success: false, error: error instanceof Error ? error.message : String(error) }; } } },
- Core helper function implementing the effective annual rate formula: (1 + r/n)^n - 1.@staticmethod def effective_annual_rate(nominal_rate: float, compounding_periods: int) -> float: """Calculate effective annual rate (EAR)""" return ((1 + nominal_rate / compounding_periods) ** compounding_periods) - 1