feat: add remaining 5 endpoints (VWAP, relative rotation, fred-regional, primary dealer)

Complete all 67 planned endpoints:
- VWAP and Relative Rotation technical indicators
- FRED regional data (by state/county/MSA)
- Primary dealer positioning (Fed data)
This commit is contained in:
Yaojia Wang
2026-03-19 17:31:08 +01:00
parent 87260f4b10
commit 615f17a3bb
4 changed files with 111 additions and 0 deletions

View File

@@ -382,6 +382,47 @@ async def get_ad(symbol: str, days: int = 400) -> dict[str, Any]:
return {"symbol": symbol, "error": "Failed to compute A/D Line"}
async def get_vwap(symbol: str, days: int = 5) -> dict[str, Any]:
"""Volume Weighted Average Price -- intraday fair value benchmark."""
hist = await fetch_historical(symbol, days)
if hist is None:
return {"symbol": symbol, "error": "No historical data"}
try:
result = await asyncio.to_thread(obb.technical.vwap, data=hist.results)
latest = _extract_latest(result)
return {
"symbol": symbol,
"vwap": latest.get("VWAP_D"),
}
except Exception:
logger.warning("VWAP failed for %s", symbol, exc_info=True)
return {"symbol": symbol, "error": "Failed to compute VWAP"}
async def get_relative_rotation(
symbols: str, benchmark: str = "SPY", days: int = 365,
) -> dict[str, Any]:
"""Relative Rotation -- strength ratio and momentum vs benchmark."""
hist = await fetch_historical(symbols, days)
bench_hist = await fetch_historical(benchmark, days)
if hist is None or bench_hist is None:
return {"symbols": symbols, "benchmark": benchmark, "error": "No historical data"}
try:
result = await asyncio.to_thread(
obb.technical.relative_rotation,
data=hist.results, benchmark=bench_hist.results,
)
items = to_list(result)
return {
"symbols": symbols,
"benchmark": benchmark,
"data": items[-10:] if len(items) > 10 else items,
}
except Exception:
logger.warning("Relative rotation failed for %s", symbols, exc_info=True)
return {"symbols": symbols, "error": "Failed to compute relative rotation"}
async def get_cones(symbol: str, days: int = 365) -> dict[str, Any]:
"""Volatility Cones -- realized volatility quantiles for options analysis."""
hist = await fetch_historical(symbol, days)