Skip to main content
Glama
dun999

FinSight

analyze_regime

Detect current market regimes (risk_on, stable_growth, recovery, high_volatility, risk_off, crisis) using macro indicators and portfolio signals. Assess portfolio alignment with detected regime and provide adjustment recommendations.

Instructions

Market regime detection from macro indicators + portfolio signals. Regimes: risk_on | stable_growth | recovery | high_volatility | risk_off | crisis. Returns regime, confidence (low/medium/high), individual signals, portfolio-fit score (0-100), and suggested adjustments. Provide marketIndicators for higher confidence. Costs $0.02 USDC.

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 `analyzeMarketRegime` that computes the market regime by aggregating weighted signals from both provided macro indicators and portfolio-derived metrics.
    export function analyzeMarketRegime(portfolio: Portfolio): MarketRegimeResult {
      const indicators = portfolio.marketIndicators ?? {}
      const scoredSignals: ScoredSignal[] = []
    
      // Macro signals (when provided)
      if (indicators.vix           !== undefined) scoredSignals.push(vixSignal(indicators.vix))
      if (indicators.yieldCurve    !== undefined) scoredSignals.push(yieldCurveSignal(indicators.yieldCurve))
      if (indicators.creditSpread  !== undefined) scoredSignals.push(creditSpreadSignal(indicators.creditSpread))
      if (indicators.inflationRate !== undefined) scoredSignals.push(inflationSignal(indicators.inflationRate))
      if (indicators.gdpGrowth     !== undefined) scoredSignals.push(gdpSignal(indicators.gdpGrowth))
    
      // Portfolio-derived signals (always computed)
      scoredSignals.push(portfolioVolSignal(portfolio))
      scoredSignals.push(cryptoConcentrationSignal(portfolio))
      scoredSignals.push(defensiveRatioSignal(portfolio))
    
      // Weighted average score
      const totalWeight = scoredSignals.reduce((acc, s) => acc + s.weight, 0)
      const weightedScore = scoredSignals.reduce((acc, s) => acc + s.score * s.weight, 0) / totalWeight
    
      // Confidence: low if we only have portfolio signals, high if macro + portfolio align
      const macroCount = scoredSignals.filter((s) =>
        ['VIX Fear Index', 'Yield Curve (10Y-2Y)', 'IG Credit Spread', 'Inflation Rate', 'GDP Growth'].includes(s.name),
      ).length
      const confidence: MarketRegimeResult['confidence'] =
        macroCount >= 3 ? 'high' : macroCount >= 1 ? 'medium' : 'low'
    
      const portVol = Math.sqrt(
        portfolio.holdings.reduce((acc, h) => acc + h.weight ** 2 * h.volatility ** 2, 0),
      )
      const regime = scoreToRegime(weightedScore, portVol)
      const fit    = portfolioFitScore(regime, portfolio)
    
      // Strip internal score/weight from output
      const signals: RegimeSignal[] = scoredSignals.map(({ name, value, signal }) => ({
        name, value, signal,
      }))
    
      return {
        regime,
        confidence,
        signals,
        portfolioFitScore: fit,
        recommendation: regimeDescription(regime),
        suggestedAdjustments: buildAdjustments(regime, portfolio),
      }
    }
  • src/index.ts:590-597 (registration)
    The tool `analyze/regime` is registered as a POST endpoint in the main application file, utilizing the `analyzeMarketRegime` handler.
    app.post('/analyze/regime', validate, charge('0.01'), async (c) => {
      try {
        return c.json(withMeta(c, analyzeMarketRegime(c.get('portfolio'))))
      } catch (err) {
        console.error(err)
        return internalError(c)
      }
    })
Behavior4/5

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

No annotations provided, yet description discloses cost, enumerates specific return values (regime, confidence levels, portfolio-fit score), and notes confidence thresholds. Missing explicit read-only/destructive classification or rate limits, but comprehensive output disclosure compensates for missing output schema.

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 high-density sentences: purpose definition, regime enumeration, return structure, and usage/cost guidance. No redundancy. Every sentence earns its place by adding distinct value (what it is, possible values, what it returns, cost/guidance).

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?

Appropriately complete for complexity: compensates for missing output schema by detailing return structure (regime, confidence, signals, score, adjustments). Mentions cost. With rich schema documenting 83% of inputs, description correctly focuses on behavioral/output aspects rather than repeating parameter definitions.

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?

Schema coverage is high (83%), establishing baseline 3. Description adds 'macro indicators' and 'portfolio signals' context that loosely maps to marketIndicators and holdings parameters, but largely restates schema information (e.g., 'higher confidence' mirrors schema's 'improves...confidence to HIGH'). No additional syntax or format details provided.

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?

Excellent specificity: verb 'detection' + resource 'market regime' + sources 'macro indicators + portfolio signals'. Lists distinct regime categories (risk_on, stable_growth, etc.) that clearly differentiate from sibling analyze_* tools (risk, correlation, etc.).

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?

Provides clear usage guidance: 'Provide marketIndicators for higher confidence' explicitly links optional input to outcome quality. Cost disclosure ($0.02 USDC) informs economic constraints. Lacks explicit 'when not to use' vs specific siblings, but regime focus provides sufficient context for selection.

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