get_returns
Calculate daily, log, or cumulative returns for investment portfolios to analyze performance and generate statistics.
Instructions
Get returns data for a portfolio.
Calculates different types of returns from the portfolio's
price data.
Args:
name: The portfolio name.
return_type: Type of returns to calculate:
- "daily": Daily percentage returns
- "log": Daily log returns
- "cumulative": Cumulative returns from start
as_percentage: If True, multiply by 100 for percentage display.
Returns:
Dictionary containing:
- return_type: The type of returns calculated
- dates: List of date strings
- returns: Dict of returns per symbol
- portfolio_returns: Weighted portfolio returns
- statistics: Summary statistics (mean, std, min, max)
Example:
```
# Get daily returns
result = get_returns(name="tech_stocks", return_type="daily")
# Get cumulative returns for growth chart
result = get_returns(name="tech_stocks", return_type="cumulative")
```
Caching Behavior:
Any input parameter can accept a ref_id from a previous tool call
Large results return ref_id + preview; use get_cached_result to paginate
All responses include ref_id for future reference
Preview Size: server default. Override per-call with get_cached_result(ref_id, max_size=...).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| return_type | No | daily | |
| as_percentage | No |