calculate_mirr
Calculate Modified Internal Rate of Return using finance and reinvestment rates for accurate investment analysis and cash flow evaluation.
Instructions
Calculate Modified Internal Rate of Return
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cashFlows | Yes | ||
| financeRate | Yes | Finance rate for negative cash flows | |
| reinvestRate | Yes | Reinvestment rate for positive cash flows |
Implementation Reference
- src/tools/financial-tools.ts:75-89 (handler)TypeScript handler for calculate_mirr tool that proxies arguments to Python's FinancialCalculator.mirr via PythonBridge.handler: async (args: any): Promise<ToolResult> => { try { const result = await pythonBridge.callPythonFunction({ module: 'financial_calculations', function: 'FinancialCalculator.mirr', args: [args.cashFlows, args.financeRate, args.reinvestRate] }); return result; } catch (error) { return { success: false, error: error instanceof Error ? error.message : String(error) }; } }
- Core Python implementation of the MIRR calculation using numpy_financial.mirr.@staticmethod def mirr(cash_flows: List[float], finance_rate: float, reinvest_rate: float) -> float: """Calculate Modified Internal Rate of Return""" return float(npf.mirr(cash_flows, finance_rate, reinvest_rate))
- src/tools/financial-tools.ts:66-74 (schema)Input schema defining the parameters for the calculate_mirr tool.inputSchema: { type: "object", properties: { cashFlows: { type: "array", items: { type: "number" } }, financeRate: { type: "number", description: "Finance rate for negative cash flows" }, reinvestRate: { type: "number", description: "Reinvestment rate for positive cash flows" } }, required: ["cashFlows", "financeRate", "reinvestRate"] },
- src/tools/financial-tools.ts:63-89 (registration)Full tool registration object for calculate_mirr within the financialTools array.{ name: "calculate_mirr", description: "Calculate Modified Internal Rate of Return", inputSchema: { type: "object", properties: { cashFlows: { type: "array", items: { type: "number" } }, financeRate: { type: "number", description: "Finance rate for negative cash flows" }, reinvestRate: { type: "number", description: "Reinvestment rate for positive cash flows" } }, required: ["cashFlows", "financeRate", "reinvestRate"] }, handler: async (args: any): Promise<ToolResult> => { try { const result = await pythonBridge.callPythonFunction({ module: 'financial_calculations', function: 'FinancialCalculator.mirr', args: [args.cashFlows, args.financeRate, args.reinvestRate] }); return result; } catch (error) { return { success: false, error: error instanceof Error ? error.message : String(error) }; } }
- src/index.ts:32-44 (registration)Inclusion of financialTools (containing calculate_mirr) into the allTools array used for MCP tool listing and execution.const allTools = [ ...excelTools, ...financialTools, ...rentalTools, ...expenseTools, ...reportingTools, ...cashFlowTools, ...taxTools, ...analyticsTools, ...chartTools, ...complianceTools, ...propertyTools, ];