Skip to main content
Glama
dun999

FinSight

analyze_stress

Stress test investment portfolios across 10 macro scenarios including market crashes, rate hikes, and geopolitical shocks to identify P&L impacts and worst/best performing assets.

Instructions

Stress test across 10 macro scenarios using real portfolio volatility data: market_crash (-40%), crypto_winter (-70%), stablecoin_depeg, high_volatility, recovery_bull (+50%), rate_hike_shock, recession, stagflation, geopolitical_shock, dollar_rally. All shocks are asset-class and sector-aware. Returns P&L per scenario with worst/best asset. Payment: $0.03 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 `analyzeStressTest` function calculates the impact of various market scenarios on a given portfolio, considering holdings, betas, and asset classes.
    export function analyzeStressTest(
      portfolio: Portfolio,
      returnSeries?: Record<string, number[]>,
    ): StressTestResult {
      // Pre-compute effective beta for each holding (real OLS or class default)
      const holdingBetas = portfolio.holdings.map((h) => resolveHoldingBeta(h, returnSeries))
    
      const scenarios: ScenarioResult[] = SCENARIOS.map((spec) => {
        const assetChanges = portfolio.holdings.map((h, idx) => ({
          asset: h.asset,
          change: spec.calcAssetChange(h, holdingBetas[idx]),
        }))
    
        const portfolioChange = portfolio.holdings.reduce(
          (acc, h, i) => acc + h.weight * assetChanges[i].change,
          0,
        )
    
        const portfolioValue = Math.round(BASE_VALUE * (1 + portfolioChange))
        const worstAsset = assetChanges.reduce((min, a) => (a.change < min.change ? a : min))
        const bestAsset  = assetChanges.reduce((max, a) => (a.change > max.change ? a : max))
    
        return {
          name: spec.name,
          description: spec.description,
          portfolioValue,
          change: Number(portfolioChange.toFixed(4)),
          worstAsset: { asset: worstAsset.asset, change: Number(worstAsset.change.toFixed(4)) },
          bestAsset:  { asset: bestAsset.asset,  change: Number(bestAsset.change.toFixed(4)) },
        }
      })
    
      return { baseValue: BASE_VALUE, scenarios }
    }
Behavior4/5

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

With no annotations provided, the description carries the full disclosure burden and succeeds well: it reveals the $0.03 USDC cost (critical runtime trait), specifies the return format (P&L per scenario with worst/best asset), and notes the asset-class/sector-aware processing behavior.

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?

Every sentence is high-density and earns its place: scenario enumeration with percentages, processing characteristics, output format, and payment terms. No filler text, logically ordered from action to cost.

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 complex 6-parameter tool with nested objects and no output schema, the description appropriately explains the return values (P&L per scenario) and enumerates the complete scenario set. It omits mention of the auto-fetch ticker capability, but that is well-covered in the high-quality schema.

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 a baseline of 3. The description adds semantic value by noting the analysis is 'asset-class and sector-aware' (reinforcing the assetClass/sector parameters) and uses 'real portfolio volatility data' (contextualizing the volatility parameter), though it doesn't detail the holdings structure.

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: 'Stress test' is a precise verb, and the description enumerates all 10 macro scenarios (market_crash, crypto_winter, etc.) with specific shock magnitudes. This clearly distinguishes it from sibling risk tools like analyze_var or analyze_correlation by defining the exact simulation scope.

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

Usage Guidelines3/5

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

The 10 scenario names provide implied usage context (use this for macro stress testing), but there is no explicit guidance on when to choose this over analyze_var or analyze_risk for tail-risk analysis, nor any prerequisites mentioned.

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