Alpha Vantage for Financial & Economic Fact Evidence

Motivation

Business, finance, technology, and economics facts frequently claim specific market caps, IPO dates, revenue figures, GDP growth, inflation rates, and commodity prices. The evidence pipeline currently has zero financial data APIs — these claims are verified only against Wikipedia text and Wikidata triples, which are often stale or lack the specificity to confirm exact figures.

Alpha Vantage provides authoritative financial data: company fundamentals, economic indicators, commodity prices, and 20+ years of market history across 100K+ global symbols.

Service Overview

CategoryFunctionKey Data
Company FundamentalsOVERVIEWMarket cap, IPO date, sector, employees, description
Income StatementINCOME_STATEMENTRevenue, net income, EBITDA (annual + quarterly)
EarningsEARNINGSEPS actual vs estimated, surprise %, quarterly history
Stock PricesTIME_SERIES_DAILYOHLCV, 20+ years daily history
Economic IndicatorsREAL_GDP, CPI, INFLATION, UNEMPLOYMENTUS macro data, quarterly/annual
CommoditiesWTI, BRENT, NATURAL_GAS, GOLD, SILVERDaily/monthly price history
ForexCURRENCY_EXCHANGE_RATEReal-time and historical FX rates
CryptoDIGITAL_CURRENCY_DAILYBTC, ETH, etc. daily OHLCV
IPO CalendarIPO_CALENDARUpcoming and historical IPOs

Base URL: https://www.alphavantage.co/query?function={FUNCTION}&apikey={KEY} Auth: apikey query parameter (ALPHA_VANTAGE_API_KEY env var, already in .env.local) Free tier: 25 requests/day, 5 requests/minute Format: JSON (default), CSV

What It Verifies

Fact Claim TypeExampleAPI FunctionEvidence
Market cap"Apple is worth $3 trillion"OVERVIEWMarketCapitalization (current)
IPO date"Tesla went public in 2010"OVERVIEWIPODate field
Revenue"Amazon revenue exceeded $500B"INCOME_STATEMENTtotalRevenue per year
Stock milestone"Bitcoin hit $69K in Nov 2021"DIGITAL_CURRENCY_DAILYActual daily high
GDP growth"US GDP grew 5.7% in 2021"REAL_GDPActual GDP values
Inflation"Inflation hit 9.1% in June 2022"CPIActual CPI reading
Commodity price"Gold surpassed $2,000/oz"GOLDDaily price history
Forex"Euro reached parity with USD in 2022"CURRENCY_EXCHANGE_RATEActual exchange rate
Earnings"Tesla beat earnings estimates"EARNINGSsurprise and surprisePercentage

Implementation

Challenge 1: Alpha Vantage Client

File: packages/ai/src/alphavantage-client.ts (new)

  • Base URL: https://www.alphavantage.co/query
  • Auth: apikey query param from ALPHA_VANTAGE_API_KEY env var
  • In-memory cache: 1h TTL for fundamentals, 15min for prices, 5K max entries
  • Rate tracking: log daily usage, warn at 20/25 requests (free tier is tight)
  • 10s timeout, abort controller
  • Metrics: alphavantage.api_calls, alphavantage.cache_hit, alphavantage.rate_limited

Key methods:

// Company fundamentals
getCompanyOverview(symbol: string): Promise<CompanyOverview | null>
getIncomeStatement(symbol: string): Promise<IncomeStatement | null>
getEarnings(symbol: string): Promise<EarningsHistory | null>

// Symbol resolution (name → ticker)
searchSymbol(name: string): Promise<SymbolMatch | null>
// Uses SYMBOL_SEARCH function: "Apple" → "AAPL"

// Economic indicators
getRealGDP(interval?: 'annual' | 'quarterly'): Promise<EconomicDataPoint[]>
getCPI(interval?: 'monthly' | 'semiannual'): Promise<EconomicDataPoint[]>
getInflation(): Promise<EconomicDataPoint[]>
getUnemployment(): Promise<EconomicDataPoint[]>
getFederalFundsRate(): Promise<EconomicDataPoint[]>

// Commodities & forex
getCommodityPrice(commodity: 'WTI' | 'BRENT' | 'GOLD' | 'SILVER' | 'NATURAL_GAS'): Promise<PriceHistory | null>
getForexRate(from: string, to: string): Promise<ForexRate | null>
getCryptoDaily(symbol: string): Promise<PriceHistory | null>

// Formatting
formatCompanyContext(overview: CompanyOverview): string
formatEconomicContext(indicator: string, data: EconomicDataPoint[]): string

Symbol resolution is critical — fact context says "Apple" or "Tesla", not "AAPL" or "TSLA". The SYMBOL_SEARCH function handles this: ?function=SYMBOL_SEARCH&keywords=Tesla{bestMatches: [{symbol: "TSLA", ...}]}.

Acceptance: Can look up "Apple" → AAPL → company overview with market cap, IPO date, sector. Can query US GDP for 2021 → actual growth figure.

Challenge 2: Evidence Pipeline Integration

File: packages/ai/src/validation/evidence.ts

Wire into Phase 4b with topic gating for business/finance/economics:

const financialTopics = ['business', 'finance', 'economics', 'technology', 'crypto']
if (financialTopics.some(t => topicPath.includes(t)) && alphaVantageKey) {

  // Company-specific claims
  if (hasCompanyClaim(factTitle, factContext)) {
    const symbol = await searchSymbol(extractCompanyName(factContext))
    if (symbol) {
      const overview = await getCompanyOverview(symbol.symbol)
      if (overview) {
        findings.push(`Alpha Vantage: ${overview.Name}, IPO ${overview.IPODate}, Market Cap $${overview.MarketCapitalization}`)
      }
      // Revenue/earnings claims
      if (hasRevenueClaim(factContext)) {
        const income = await getIncomeStatement(symbol.symbol)
        if (income) {
          findings.push(`Alpha Vantage: FY revenue ${income.annualReports[0]?.totalRevenue}`)
        }
      }
    }
  }

  // Economic indicator claims
  if (hasEconomicClaim(factContext)) {
    // GDP, inflation, unemployment — match claim to indicator
    const indicator = detectEconomicIndicator(factContext)
    if (indicator) {
      const data = await getEconomicData(indicator)
      findings.push(`Alpha Vantage: ${indicator} = ${data[0]?.value} (${data[0]?.date})`)
    }
  }

  // Commodity/crypto price claims
  if (hasPriceClaim(factContext)) {
    const asset = detectAsset(factContext) // "gold", "bitcoin", "oil"
    if (asset) {
      const prices = await getAssetPrice(asset)
      findings.push(`Alpha Vantage: ${asset} price history available`)
    }
  }
}

Rate budget strategy: 25 req/day is tight. Prioritize:

  1. SYMBOL_SEARCH + OVERVIEW (2 calls — highest value, covers IPO dates, market cap)
  2. INCOME_STATEMENT only when revenue/earnings claimed (1 call)
  3. Economic indicators only when GDP/CPI/inflation claimed (1 call)
  4. Skip price history lookups on free tier (expensive, lower verification value)

Acceptance: "Tesla went public in 2010" → SYMBOL_SEARCH("Tesla") → OVERVIEW("TSLA") → IPODate: 2010-06-29 → corroborated.

Challenge 3: Tests

File: packages/ai/src/__tests__/alphavantage-client.test.ts (new)

  • Symbol search response parsing
  • Company overview parsing (market cap, IPO date, sector)
  • Economic indicator parsing
  • Cache behavior (especially TTL differences: 1h fundamentals vs 15min prices)
  • Rate limit tracking and warning
  • Financial topic detection in fact context
  • Graceful degradation when API key missing or rate limited

Acceptance: bun run test passes.

Evidence Confidence Impact

  • Company overview found with matching IPO date → boost apiConfidence by 0.15 (authoritative)
  • Revenue figure matches within 5% → boost apiConfidence by 0.1
  • Economic indicator matches claim → boost apiConfidence by 0.15
  • Company found but data contradicts claim → flag as critical
  • No results or rate limited → fall through to existing sources (no penalty)

Cost

Free tier: 25 requests/day. Sufficient for validation pipeline (not bulk ingestion). Premium: $49.99/month for 75 req/min if needed at scale.

Dependencies

  • ALPHA_VANTAGE_API_KEY in .env.local (already done)
  • Add to packages/config/src/index.ts env schema
  • Add to .env.example

Rate Budget

Validation ScenarioCallsNotes
Company fact (IPO, market cap)2SYMBOL_SEARCH + OVERVIEW
Company + revenue claim3+ INCOME_STATEMENT
Economic indicator (GDP, CPI)1Single indicator lookup
Commodity/crypto price1Single price lookup
Daily budget25~8-12 financial facts/day on free tier

Relationship to Other Evidence Plans

PlanDomainData
API-SportsSportsMatch results, player stats, game data
OpenAlex + Nobel PrizeScience, academiaAuthors, papers, institutions, prize attribution
Alpha VantageFinance, business, economicsFundamentals, revenue, GDP, inflation, commodities
DBpediaGeneral-purpose fallbackStructured Wikipedia infobox properties