Skip to main content
Glama
dun999

FinSight

analyze_factors

Analyze portfolio factor exposures including market beta, asset class contributions, regional and sector breakdowns, interest rate sensitivity, dividend yield, and currency exposure to assess diversification and risk.

Instructions

Factor exposure analysis: portfolio market beta, asset-class contributions, region/sector breakdown, interest-rate sensitivity (duration), dividend yield, currency exposure. Payment: $0.02 USDC on Tempo chain.

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 factor exposure analysis, calculating beta, asset class contributions, duration, and other risk factors.
    export function analyzeFactorExposure(
      portfolio: Portfolio,
      returnSeries?: Record<string, number[]>,
    ): FactorExposureResult {
      const holdings = portfolio.holdings
    
      // ── Market beta (real OLS regression when available, class default otherwise) ─
      const marketBeta = holdings.reduce(
        (acc, h) => acc + h.weight * resolveEffectiveBeta(h, returnSeries),
        0,
      )
    
      let betaInterpretation: string
      if (marketBeta < 0.2) {
        betaInterpretation = 'Defensive — portfolio moves far less than the broad market'
      } else if (marketBeta < 0.7) {
        betaInterpretation = 'Low-beta — underperforms in bull markets, outperforms in downturns'
      } else if (marketBeta < 1.2) {
        betaInterpretation = 'Market-neutral — tracks broad market closely'
      } else if (marketBeta < 1.8) {
        betaInterpretation = 'High-beta — amplified market moves in both directions'
      } else {
        betaInterpretation = 'Very high-beta — extreme market sensitivity'
      }
    
      // ── Asset class contributions ────────────────────────────────────────────
      const classMap = new Map<
        AssetClass,
        { weight: number; betaContrib: number; volContrib: number }
      >()
      for (const h of holdings) {
        const beta = resolveEffectiveBeta(h, returnSeries)
        const existing = classMap.get(h.assetClass) ?? { weight: 0, betaContrib: 0, volContrib: 0 }
        classMap.set(h.assetClass, {
          weight:      existing.weight      + h.weight,
          betaContrib: existing.betaContrib + h.weight * beta,
          volContrib:  existing.volContrib  + h.weight * h.volatility,
        })
      }
      const assetClassContributions: AssetClassContribution[] = Array.from(classMap.entries())
        .map(([assetClass, { weight, betaContrib, volContrib }]) => ({
          assetClass,
          weight:          Number(weight.toFixed(4)),
          betaContribution: Number(betaContrib.toFixed(4)),
          volContribution:  Number(volContrib.toFixed(4)),
        }))
        .sort((a, b) => b.weight - a.weight)
    
      // ── Region breakdown ─────────────────────────────────────────────────────
      const regionBreakdown = groupBy(
        holdings.map((h) => ({ key: h.region as Region, weight: h.weight })),
      ).map(({ key, weight }) => ({ region: key, weight }))
    
      // ── Sector breakdown ─────────────────────────────────────────────────────
      const sectorBreakdown = groupBy(
        holdings.map((h) => ({
          key: (h.sector ?? h.assetClass) as string,
          weight: h.weight,
        })),
      ).map(({ key, weight }) => ({ sector: key, weight }))
    
      // ── Fixed-income metrics ─────────────────────────────────────────────────
      const portfolioDuration = Number(
        holdings.reduce((acc, h) => acc + h.weight * h.duration, 0).toFixed(2),
      )
      const weightedDividendYield = Number(
        holdings.reduce((acc, h) => acc + h.weight * h.dividendYield, 0).toFixed(4),
      )
    
      const bondWeight = holdings
        .filter((h) => h.assetClass === 'bond')
        .reduce((acc, h) => acc + h.weight, 0)
      const reWeight = holdings
        .filter((h) => h.assetClass === 'real_estate')
        .reduce((acc, h) => acc + h.weight, 0)
    
      // ── Currency exposure ────────────────────────────────────────────────────
      const currencyExposure = groupBy(
        holdings.map((h) => ({ key: h.currency, weight: h.weight })),
      ).map(({ key, weight }) => ({ currency: key, weight }))
    
      return {
        marketBeta: Number(marketBeta.toFixed(4)),
        betaInterpretation,
        assetClassContributions,
        regionBreakdown,
        sectorBreakdown,
        portfolioDuration,
        weightedDividendYield,
        interestRateSensitivity: interestRateSensitivity(portfolioDuration, bondWeight, reWeight),
        currencyExposure,
      }
    }
  • src/index.ts:572-579 (registration)
    The MCP/API tool registration for 'analyze_factors' (via the /analyze/factors route).
    app.post('/analyze/factors', validate, charge('0.01'), async (c) => {
      try {
        return c.json(withMeta(c, analyzeFactorExposure(c.get('portfolio'), c.get('returnSeries'))))
      } catch (err) {
        console.error(err)
        return internalError(c)
      }
    })
Behavior3/5

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

Discloses payment cost ($0.02 USDC on Tempo chain) which is critical for agent decision-making. However, with no annotations provided, the description fails to clarify whether this is a read-only analytical operation or if it writes to the Tempo chain, lacks rate limit warnings, and omits data freshness expectations for the CoinGecko integration mentioned in parameters.

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?

Two sentences, front-loaded with analytical scope. The payment information, while relevant, is disconnected from the operational description and could be considered structural noise, though it does serve a functional purpose for cost-aware routing.

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

Completeness3/5

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

Given the rich input schema (nested holdings objects, 6 top-level parameters) and lack of output schema, the description adequately enumerates the analysis dimensions but underserves operational context. No mention of return format, caching behavior, or the significance of the 83% auto-population capability for known tickers.

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?

With 83% schema coverage, the baseline is 3. The description adds value by mapping abstract schema fields (beta, duration, dividendYield, assetClass, region) to their analytical purposes (market beta, interest-rate sensitivity, yield, class contributions, breakdown), helping the agent understand why specific parameters are relevant.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

Lists specific analytical outputs (market beta, asset-class contributions, region/sector breakdown, duration sensitivity, dividend yield, currency exposure) clearly identifying what the tool calculates. However, it lacks explicit differentiation from siblings like analyze_risk or analyze_diversification which may overlap in functionality.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides no guidance on when to select this tool versus the nine sibling analysis tools (e.g., analyze_var, analyze_correlation). Does not mention prerequisites like requiring holdings data or when factor exposure specifically is needed over general risk metrics.

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