Skip to main content
Glama
mothanaprime

Portfolio Rotation MCP Server

by mothanaprime

run_backtest

Backtest a portfolio rotation strategy on historical price data with momentum or score ranking, and obtain return, Sharpe, drawdown, and equity curve.

Instructions

Backtest a rotation strategy on historical price data.

Uses price momentum ranking by default. Simulates monthly rebalancing with trailing stops and transaction costs.

Args: prices_json: JSON of price data from fetch_prices (the "prices" array). strategy_json: Optional JSON strategy config, e.g. '{"rebalance": "monthly", "max_positions": 5, "sizing": "equal_weight", "entry": {"min_score": 60}, "exit": {"trailing_stop": 0.15}}'. If empty, uses sensible defaults. benchmark: Benchmark ticker (default "SPY"). cost_bps: Transaction cost in basis points (default 10). scores_json: Optional JSON of score results from score_tickers tool. When provided with ranking_mode="score", uses composite scores for initial allocation instead of price momentum. ranking_mode: "momentum" (default, rank by 3M price return) or "score" (rank by composite scores for initial allocation). When "score", the entry.min_score threshold from strategy is honored. Note: subsequent rebalances use momentum since scores can't be recomputed mid-backtest without financials at each date.

Returns: JSON with metrics (total_return, CAGR, Sharpe, Sortino, max_drawdown, win_rate), equity_curve, trade_log, and monthly_returns.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
prices_jsonYes
strategy_jsonNo
benchmarkNoSPY
cost_bpsNo
scores_jsonNo
ranking_modeNomomentum

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior4/5

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

Given no annotations, the description discloses key behavioral traits: default momentum ranking, monthly rebalancing, trailing stops, transaction costs, and the interaction between ranking_mode and scores_json. It also notes that subsequent rebalances use momentum since scores aren't recomputed mid-backtest. While it doesn't explicitly state that the tool is read-only (non-destructive), the nature of a backtest implies no data mutation. This is adequate transparency.

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 a clear overview, bullet-listed parameters, and a return value section. Every sentence adds necessary information without redundancy. It is concise yet comprehensive, avoiding unnecessary prose.

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

Completeness5/5

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

The description covers all aspects needed for an agent: inputs (required and optional), behavior (momentum vs. score ranking, rebalancing), constraints (scores not recomputed mid-backtest), and outputs (metrics, equity curve, etc.). Despite no output schema, the return description is detailed. The tool is complex with 6 parameters, and the description leaves no gaps in understanding.

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?

With 0% schema description coverage, the description fully compensates by explaining all six parameters in detail. It provides examples, defaults, and links to other tools (e.g., fetch_prices, score_tickers). This adds significant meaning beyond the schema, enabling correct parameter usage.

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: 'Backtest a rotation strategy on historical price data.' It distinguishes itself from sibling tools by focusing on rotation strategies, simulations with monthly rebalancing, trailing stops, and transaction costs. This specificity helps an agent select the correct tool for backtesting scenarios.

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 clear guidance on when to use the tool, including prerequisites (prices from fetch_prices) and optional inputs (strategy_json, scores_json, ranking_mode). It explains the default behavior and how different ranking modes affect the backtest. However, it does not explicitly mention when to use this tool over alternatives (e.g., stress_test vs. run_backtest), which would strengthen the guidelines.

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/mothanaprime/Rebalance-MCP'

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