Skip to main content
Glama
dun999

FinSight

analyze_rebalance

Optimize portfolio allocations using four rebalancing methods with live market data. Get target weights, current weights, and specific actions (increase/reduce/hold) for each asset.

Instructions

Portfolio rebalancing recommendations with live market data. Four methods: profile (conservative/balanced/aggressive), risk_parity (inverse-vol weighting), min_variance (inverse-variance), equal_weight (1/N). Returns target weight, current weight, action (increase/reduce/hold), and delta per asset. Known crypto tickers auto-enriched with real volatility data. Payment: $0.02 USDC on Tempo.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
holdingsYes
profileNoRisk profile — affects rebalance targets and scoring. Default: balanced.
benchmarkReturnNoAnnual benchmark return for Sharpe calculation, e.g. 0.08 = 8%. Default: 0.08.
riskFreeRateNoAnnual risk-free rate for Sortino and VaR excess return, e.g. 0.05 = 5%. Default: 0.05.
rebalanceMethodNoPortfolio construction method for rebalance recommendations. Default: profile.
marketIndicatorsNoOptional macro indicators — improves market regime detection confidence to HIGH when 3+ provided.

Implementation Reference

  • The main handler function for rebalancing logic, which calculates target weights and generates rebalance suggestions based on the portfolio's method and profile.
    export function analyzeRebalance(portfolio: Portfolio): RebalanceResult {
      const targets = computeTargets(portfolio.holdings, portfolio.profile, portfolio.rebalanceMethod)
    
      const roundedTargets = targets.map((t) => Number(t.toFixed(4)))
      // Absorb rounding error into the largest-weight suggestion so client sums always equal 1.0
      const roundedSum = roundedTargets.reduce((a, b) => a + b, 0)
      const roundingError = Number((1 - roundedSum).toFixed(4))
      if (roundingError !== 0 && roundedTargets.length > 0) {
        const maxIdx = roundedTargets.reduce((best, v, i) => (v > roundedTargets[best] ? i : best), 0)
        roundedTargets[maxIdx] = Number((roundedTargets[maxIdx] + roundingError).toFixed(4))
      }
    
      const suggestions: RebalanceSuggestion[] = portfolio.holdings.map((h, i) => {
        const delta = Number((roundedTargets[i] - h.weight).toFixed(4))
        const action: RebalanceSuggestion['action'] =
          Math.abs(delta) < 0.02 ? 'hold' : delta > 0 ? 'increase' : 'reduce'
        return {
          asset: h.asset,
          currentWeight: h.weight,
          targetWeight: roundedTargets[i],
          action,
          delta,
        }
      })
    
      const targetWeightsSum = Number(
        targets.reduce((a, b) => a + b, 0).toFixed(6),
      )
    
      return {
        method: portfolio.rebalanceMethod,
        profile: portfolio.profile,
        suggestions,
        targetWeightsSum,
      }
    }
Behavior4/5

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

With no annotations provided, the description carries full burden. It discloses critical behavioral traits: payment requirement ($0.02 USDC), auto-enrichment of crypto tickers with live volatility data, and specific return schema (target weight, current weight, action, delta). Omits explicit read-only hint.

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?

Four dense sentences front-loaded with purpose, followed by method enumeration, return structure disclosure, auto-enrichment note, and payment terms. Zero redundancy; every clause adds unique information not found in structured fields.

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?

Excellent coverage given no output schema exists: explicitly documents return fields (target weight, action, delta). Covers payment and data enrichment behaviors. With complex nested holdings schema and high coverage, only minor gap is explicit safety/permissions statement.

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 coverage is 83% (high baseline), yet description adds crucial semantics: maps rebalanceMethod enum values to financial concepts ('risk_parity' = 'inverse-vol weighting'), and explains the auto-population logic for optional ticker fields (avgReturn, volatility, maxDrawdown) that the schema only mentions as 'optional'.

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?

Specific verb 'rebalancing recommendations' plus resource 'Portfolio' and explicit distinction from siblings via the four method descriptions (profile, risk_parity, min_variance, equal_weight) and unique return structure (action: increase/reduce/hold).

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?

Lists the four available methods with brief descriptions (e.g., 'inverse-vol weighting') to guide selection among them. Clear context that this generates actionable rebalancing signals versus pure analysis, though it doesn't explicitly contrast with sibling analyze_* tools like analyze_risk.

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/dun999/finsight-mpp'

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