Skip to main content
Glama

get_correlation_matrix

Analyze Bitcoin's 30-day correlation with S&P 500 and Gold to determine if it's trading as a risk asset, safe haven, or independently, helping assess macro spillover risk.

Instructions

BTC correlation with traditional finance: 30-day Pearson correlation with S&P 500 and Gold, plus current TradFi prices. Shows whether BTC is trading as a risk asset, safe haven, or independently. Critical for understanding macro spillover risk.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the get_correlation_matrix tool. It retrieves correlation data, generates summary/guidance, and handles caching and error cases.
    export async function getCorrelationMatrixTool(cache: CacheService): Promise<CorrelationMatrixOutput | ErrorOutput> {
      const cached = cache.get<CorrelationMatrixOutput>(CACHE_KEY);
      if (cached) return cached.data;
    
      try {
        const data = await getCorrelationData();
    
        const summary = generateSummary(data);
        const guidance = generateGuidance(data);
    
        const result: CorrelationMatrixOutput = {
          btc_sp500_correlation: data.btc_sp500.correlation_30d,
          btc_sp500_classification: data.btc_sp500.classification,
          btc_gold_correlation: data.btc_gold.correlation_30d,
          btc_gold_classification: data.btc_gold.classification,
          sp500_price: data.sp500_price,
          sp500_change_pct: data.sp500_change_pct,
          gold_price: data.gold_price,
          gold_change_pct: data.gold_change_pct,
          macro_risk_appetite: data.macro_risk_appetite,
          correlation_summary: summary,
          agent_guidance: guidance,
        };
    
        cache.set(CACHE_KEY, result, getCacheTtl(BASE_TTL));
        return result;
      } catch (err) {
        return {
          error: true,
          error_source: 'get_correlation_matrix',
          agent_guidance: 'TradFi correlation data unavailable. Cannot assess BTC relationship to equities or gold. Assume moderate positive correlation with S&P 500 as a safe default. Do not use absence of this data as a reason to increase risk.',
          last_known_data: cache.get<CorrelationMatrixOutput>(CACHE_KEY)?.data ?? null,
          data_warnings: ['TradFi correlation data temporarily unavailable (Yahoo Finance).'],
        };
      }
    }
  • The output interface schema for the tool.
    export interface CorrelationMatrixOutput {
      btc_sp500_correlation: number;
      btc_sp500_classification: string;
      btc_gold_correlation: number;
      btc_gold_classification: string;
      sp500_price: number;
      sp500_change_pct: number;
      gold_price: number;
      gold_change_pct: number;
      macro_risk_appetite: string;
      correlation_summary: string;
      agent_guidance: string;
    }
Behavior4/5

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

Since no annotations exist, description carries full burden and discloses: calculation method (Pearson correlation), timeframe (30-day), included assets (S&P 500, Gold), additional returned data (current TradFi prices), and interpretation semantics (risk asset classification). Only missing operational details like data freshness or rate limits.

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?

Three sentences with zero waste: technical specs first, interpretation guide second, use case third. Front-loaded with specific methodology and assets. Every sentence earns its place.

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 0-parameter tool without output schema, description adequately explains return values (correlation coefficients, TradFi prices) and their semantic meaning (spillover risk assessment). Sufficient for an agent to understand what data will be returned and how to interpret it.

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?

Input schema has 0 parameters, establishing baseline of 4. Description adds value by specifying the implicit timeframe (30-day) and fixed methodology (Pearson) that would otherwise be unknown parameters of the operation.

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 (correlation) + specific resources (BTC vs S&P 500/Gold) + methodology (30-day Pearson). Distinguishes from siblings like get_macro_context or get_asset_context by focusing specifically on cross-asset correlation analysis rather than general market data.

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?

Explains when to use it ('Critical for understanding macro spillover risk') and what insight it provides ('Shows whether BTC is trading as a risk asset, safe haven, or independently'). While it doesn't explicitly name sibling alternatives, the functional scope is distinct enough to imply appropriate usage context.

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/0xHashy/fathom-fyi'

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