Skip to main content
Glama
l4b4r4b4b4
by l4b4r4b4b4

get_returns

Calculate daily, logarithmic, or cumulative returns for a portfolio from price data. Optionally display as percentages and get summary 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
NameRequiredDescriptionDefault
nameYes
return_typeNodaily
as_percentageNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full responsibility for behavioral transparency. It discloses caching behavior (ref_id, pagination via get_cached_result) and return structure, but does not mention any side effects or read-only nature. The caching info adds valuable context beyond what annotations would provide.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with sections for Args, Returns, Example, and Caching Behavior. Every sentence adds value, and the example is concise yet illustrative. No redundant content.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the presence of an output schema (though not shown in the input, context indicates it exists), the description still provides a detailed Returns section. It covers caching and pagination. A minor gap is the lack of error handling or prerequisite mention (e.g., portfolio existence), but overall it is sufficiently complete for a straightforward data retrieval tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0% description coverage, but the description compensates fully by explaining each parameter: name, return_type (with explicit enum-like values), and as_percentage (with meaning). This adds significant semantic value beyond the bare schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose as 'Get returns data for a portfolio' and specifies different return types (daily, log, cumulative). It distinguishes itself from sibling tools like get_portfolio_metrics by focusing specifically on return calculations, and the examples further clarify use cases.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides examples and explains each parameter clearly, including different return_type options and the as_percentage flag. However, it does not explicitly contrast with alternative tools (e.g., get_portfolio_metrics) or state when not to use this tool, which would enhance guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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/l4b4r4b4b4/portfolio-mcp'

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