Skip to main content
Glama

PortfolioFit

Calculate portfolio statistics

calculate_portfolio_statistics
Idempotent

Calculate historical return, volatility, drawdown, risk-adjusted and benchmark-relative statistics from a confirmed portfolio series profile. The metrics parameter describes all available calculations and their required inputs. Use daily, weekly or monthly complete periods; results include coverage, warnings and exact dataset/profile pins. Reuse an idempotency_key only for an identical calculation.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "series_profile_id": "<series_profile_id>",
      "metrics": "<metrics>",
      "target_frequency": "<target_frequency>",
      "idempotency_key": "<idempotency_key>"
    },
    "name": "calculate_portfolio_statistics"
  }
}

Input Schema

NameRequiredDescriptionDefault
metricsYesSelect one or more unique metric names. periodic_returns: Return for each complete period at target_frequency. cumulative_return: Compounded return across the selected complete periods. observation_count: Number of source observations in the selected date range. period_count: Number of complete return periods available for calculation. min_return: Lowest periodic return and its period end date. max_return: Highest periodic return and its period end date. volatility: Sample standard deviation of periodic returns, with annualized volatility. drawdown: Decline from the running peak of compounded wealth for each period. max_drawdown: Largest peak-to-trough decline, with peak, trough and recovery dates when available. downside_deviation: Root mean square shortfall below minimum_acceptable_return, with annualized deviation. Requires minimum_acceptable_return. sharpe: Mean return above risk_free_rate divided by the sample standard deviation of excess returns, with annualized ratio. Requires risk_free_rate. sortino: Mean return above minimum_acceptable_return divided by downside deviation, with annualized ratio. Requires minimum_acceptable_return. beta: Sensitivity of portfolio returns to benchmark returns. Requires benchmark_profile_id. alpha: Return above the benchmark return implied by beta and risk_free_rate, with annualized alpha. Requires benchmark_profile_id and risk_free_rate. correlation: Pearson correlation between portfolio and benchmark returns. Requires benchmark_profile_id. tracking_error: Sample standard deviation of portfolio-minus-benchmark returns, with annualized tracking error. Requires benchmark_profile_id. information_ratio: Mean portfolio-minus-benchmark return divided by tracking error, with annualized ratio. Requires benchmark_profile_id.
end_dateNo
start_dateNo
analysis_nameNoOptional private grouping name. The same case-sensitive name, after trimming outer whitespace, reuses one group for this user. Omit it for an independent operation. Keep the name on retries; each calculation still needs its own idempotency_key.
risk_free_rateNoRequired for sharpe and alpha. Use a confirmed risk-free rate profile or a source-backed dated annualized scalar with currency, tenor, compounding and provenance. Do not substitute an assumed rate.
idempotency_keyYes
target_frequencyYesCalculate complete daily, weekly or monthly return periods. Annualization uses 252, 52 or 12 periods per year respectively; finer-frequency data must be available.
series_profile_idYesConfirmed portfolio series profile returned by upload or list_portfolio_series; pins one immutable dataset version.
benchmark_profile_idNoConfirmed benchmark series profile in the same currency and return basis as the portfolio. Required for beta, alpha, correlation, tracking_error and information_ratio. Returns are matched by exact period dates.
minimum_acceptable_returnNoRequired for downside_deviation and sortino. Use a confirmed minimum acceptable return profile or a source-backed dated annualized scalar with currency, tenor, compounding and provenance.

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Added

TDQS

A4.3/5.0
Behavior4/5

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

Annotations already declare idempotentHint=true, destructiveHint=false and openWorldHint=false, so the safety profile is covered. The description adds genuinely new behavior: results carry coverage and warnings, exact dataset/profile pins are returned, only complete periods are used, and an idempotency_key may only be reused for an identical calculation. It stops short of describing the persistence/auth implications of readOnlyHint=false.

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

Conciseness4/5

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

Four sentences, front-loaded with the purpose and followed by prerequisite, frequency, output-character and idempotency notes; nothing is padding. The sentence 'The metrics parameter describes all available calculations and their required inputs' is a pointer to the schema rather than new information, which is the only mildly wasteful line.

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?

An output schema exists, so return values need not be enumerated, and the description still notes that results include coverage, warnings and dataset/profile pins. Prerequisites for the required parameters (confirmed profile, benchmark/MAR/risk-free requirements per metric) are documented in the schema, leaving little uncovered for an agent to call this correctly.

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

Parameters4/5

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

Schema description coverage is 70% and the lengthy metric glossary lives in the schema, so the baseline is roughly 3. The description earns above baseline by supplying semantics the schema lacks: the idempotency_key reuse rule and the requirement that periods be complete at the chosen frequency.

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 names a specific verb (Calculate) and a precisely scoped resource set (historical return, volatility, drawdown, risk-adjusted and benchmark-relative statistics) read from a confirmed portfolio series profile. This distinguishes it cleanly from siblings like calculate_portfolio_constraints and evaluate_portfolio_alignment, which operate on different concerns.

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?

It states the prerequisite (a confirmed portfolio series profile), the frequency options ('daily, weekly or monthly complete periods'), and an idempotency-key reuse rule. However, it never names an alternative tool or states when *not* to use this one, so routing among the sibling analysis tools is left to inference.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources