Skip to main content
Glama
dun999

FinSight

analyze_var

Calculate Value-at-Risk and Expected Shortfall for crypto and multi-asset portfolios using real-time volatility data from CoinGecko to assess potential losses at 95% and 99% confidence levels.

Instructions

Value-at-Risk (VaR) and CVaR (Expected Shortfall) at 95% and 99% confidence. Uses real volatility auto-fetched from CoinGecko for known crypto tickers. Returns daily and annualised VaR/CVaR, worst-case dollar loss on $1M AUM, and interpretation. 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 handler function for the `analyze_var` tool, which computes Value at Risk (VaR) and Conditional Value at Risk (CVaR) for a given portfolio.
    export function analyzeVaR(portfolio: Portfolio): VaRResult {
      const { annualMean, annualVol } = portfolioStats(portfolio)
    
      // z-scores for 95% and 99% confidence (one-tailed)
      const Z_95 = 1.6449
      const Z_99 = 2.3263
    
      const confidence95 = computeBand(annualMean, annualVol, Z_95, 0.95)
      const confidence99 = computeBand(annualMean, annualVol, Z_99, 0.99)
    
      // Dollar impact on a $1,000,000 AUM position
      const worstCaseDollarLoss1M = Math.max(0, Math.round(confidence99.annualCVaR * 1_000_000))
    
      return {
        confidence95,
        confidence99,
        worstCaseDollarLoss1M,
        interpretation: buildInterpretation(confidence95, confidence99, portfolio.profile),
      }
    }
  • src/index.ts:563-570 (registration)
    Registration of the /analyze/var tool endpoint.
    app.post('/analyze/var', validate, charge('0.01'), async (c) => {
      try {
        return c.json(withMeta(c, analyzeVaR(c.get('portfolio'))))
      } catch (err) {
        console.error(err)
        return internalError(c)
      }
    })

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