Skip to main content
Glama

portfolio-rebalance

Compute exact buy and sell amounts to rebalance your portfolio to target allocations, with drift threshold support for partial rebalancing.

Instructions

Pure-math portfolio rebalancing calculator. Given current holdings (asset names and their current USD values) and target allocations (percentages summing to 100), returns the exact buy/sell dollar amounts needed to reach target weights. Handles partial rebalancing with a drift threshold. No external API — deterministic and instant. Useful for DeFi agents, robo-advisory flows, and automated rebalancing triggers.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
holdingsNoCurrent portfolio positions.
targetsNoTarget allocation percentages. Must sum to 100.
drift_threshold_pctNoMinimum drift percentage before an asset is flagged as needing rebalance (default 1.0). Positions within threshold are marked 'in_range'.
cash_injectionNoOptional additional cash (USD) to deploy during rebalancing (positive = buying, negative = withdrawing).
Behavior3/5

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

No annotations are provided, so the description must disclose all behavioral traits. It states 'No external API — deterministic and instant,' which is helpful. However, it does not mention error handling, input validation (e.g., target sum not 100), or behavior with empty arrays. It is adequate but not comprehensive.

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 four sentences, each serving a clear purpose: stating the tool's nature, detailing inputs/outputs, mentioning the drift threshold, and listing use cases. No extraneous information. It is front-loaded with the core function.

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?

For a calculator tool with no output schema, the description adequately explains the return values (buy/sell amounts) and key features (drift threshold, cash injection). It lacks some detail on input format and error scenarios, but overall it is sufficiently complete for an agent to use correctly.

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

Parameters3/5

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

The input schema has 100% coverage with descriptions, but those descriptions are minimal. The tool description clarifies that 'holdings' should include asset names and USD values, and 'targets' are percentages, but the schema only says 'Current portfolio positions' and 'Target allocation percentages.' The format (e.g., array of strings) requires additional context, and the description does not specify whether the arrays must correspond element-wise. This adds some value but leaves ambiguity.

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 identifies the tool as a 'pure-math portfolio rebalancing calculator' with specific verb and resource. It explains the inputs (holdings with USD values and target percentages) and outputs (buy/sell amounts). This distinguishes it from sibling tools, which are mostly data retrieval or analysis tools.

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 explicit use cases: 'DeFi agents, robo-advisory flows, and automated rebalancing triggers.' It implies the tool is for calculating rebalancing trades, not for other portfolio tasks. However, it does not explicitly state when not to use it or mention alternatives, leaving some room for improvement.

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/thebrierfox/the-stall'

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