Files
All-in-one-Financial-Analysis/atlas-terminal/server/routers/fmp.py
T
shawnkim1997andClaude Opus 4.6 51cbaf7f8d feat: major codebase audit — 21 routers, 37 services, 12 pages fully documented
- Add missing numpy, scipy, dbnomics to requirements.txt (fixes ImportError on fresh install)
- Sync claude.md with actual codebase: §3 file structure (37 services, 21 routers),
  §5 API endpoints (92 routes), §6 frontend pages (12), §13 TODO status
- Update README.md with current architecture (92 API routes, 21 routers, 37 services),
  multi-asset overview, research grid, macro dashboard, screener+backtest,
  multi-jurisdiction filings, and 2026-03-26 changelog entry
- Add new routers: dart, edinet, fmp, macro, research
- Add new services: cache, dart_fetcher, dart_filing_service, economic_calendar,
  ecos_fetcher, edinet_filing_service, fmp_client, global_macro_quadrant,
  kpi_history_service, macro_cycle, macro_fetcher, oecd_cycle,
  peer_comparison_service, research_dashboard, smart_money_service, yield_fx_service
- Add new frontend: macro page, screener+backtest, research grid components,
  overview (Equity/ETF/Commodity), filings (SEC/DART/EDINET), error boundaries
- Remove 6 unused services: copilot_context, crypto_fetcher, fx_fetcher,
  gemini_analysis, market_data, technical_analysis
- Remove obsolete docs: .agent/, AGENT.md, ATLAS_EVALUATION.md, docs/

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 21:39:07 +00:00

46 lines
1.6 KiB
Python

"""FMP-backed valuation ratios and key metrics (optional API key)."""
from typing import Any, Dict
from fastapi import APIRouter, Query
from server.services import fmp_client
router = APIRouter()
@router.get(
"/key-metrics/{ticker}",
summary="Historical key metrics (FMP or Yahoo fallback)",
)
async def get_key_metrics(
ticker: str,
period: str = Query("annual", description="annual or quarter"),
limit: int = Query(10, ge=1, le=40),
) -> Dict[str, Any]:
"""Return FMP key-metrics time series when ``FMP_API_KEY`` is set; else Yahoo snapshot."""
sym = ticker.strip().upper()
rows = await fmp_client.fetch_key_metrics(sym, period=period, limit=limit)
if rows:
return {"ticker": sym, "source": "fmp", "period": period, "data": rows}
fb = await fmp_client.fallback_valuation_snapshot(sym)
return {"ticker": sym, "source": "fallback", "period": period, "data": [], "snapshot": fb}
@router.get(
"/ratios/{ticker}",
summary="Historical financial ratios (FMP or Yahoo fallback)",
)
async def get_ratios(
ticker: str,
period: str = Query("annual", description="annual or quarter"),
limit: int = Query(10, ge=1, le=40),
) -> Dict[str, Any]:
"""Return FMP ratios time series when key is set; else Yahoo snapshot."""
sym = ticker.strip().upper()
rows = await fmp_client.fetch_ratios(sym, period=period, limit=limit)
if rows:
return {"ticker": sym, "source": "fmp", "period": period, "data": rows}
fb = await fmp_client.fallback_valuation_snapshot(sym)
return {"ticker": sym, "source": "fallback", "period": period, "data": [], "snapshot": fb}