Finance Utilities

Return On Investment

Calculates Return on Investment (ROI) percentage from initial investment and final value. Access via MCP in Cursor or Windsurf for financial analysis, or through REST API at `/v1/finance/roi`. Returns precise ROI calculation: ((final_value - initial_investment) / initial_investment) × 100. Essential for investment performance evaluation and portfolio analysis.

API Endpoint

GET /v1/finance/roi

Code Examples

curl "https://tinyfn.io/v1/finance/roi" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/finance/roi', {
  headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
console.log(data);
import requests

response = requests.get('https://tinyfn.io/v1/finance/roi',
    headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)

Use via MCP

Add to your AI agent

Connect your AI agent (Claude, Cursor, Windsurf, etc.) to TinyFn's finance tools:

{
  "mcpServers": {
    "tinyfn-finance": {
      "url": "https://tinyfn.io/mcp/finance",
      "headers": {
        "X-API-Key": "YOUR_API_KEY"
      }
    }
  }
}

Learn more about MCP setup →

FAQ

How do I calculate ROI for a stock investment using MCP?

Pass your initial purchase amount and current value to get the ROI percentage. For example, $1000 initial, $1250 current returns 25% ROI.

What's the difference between ROI and other investment metrics?

ROI shows simple percentage return without considering time, while metrics like IRR account for investment duration and cash flow timing.

Can I calculate negative ROI for losses?

Yes, the tool handles losses. If you invested $1000 and it's now worth $800, ROI returns -20%.

What input format does the ROI endpoint expect?

Provide initial_investment and final_value as numeric parameters. Both can be integers or decimals in any currency unit.

How can AI agents use ROI calculations in financial workflows?

Agents can analyze portfolio performance, compare investment options, or generate financial reports by calculating ROI for multiple assets automatically.

Try Return On Investment Now

Get your free API key and start using Return On Investment in seconds.

Get Free API Key