Files
signal-platform/app/routers/market.py
T
dennisthiessen c4f2673799
Deploy / lint (push) Successful in 6s
Deploy / test (push) Successful in 36s
Deploy / deploy (push) Successful in 25s
add market-regime guard (SPY trend) — inform + warn
New market_regime_service computes a benchmark (SPY) trend from its 50/200-day
SMAs, cached in a SystemSetting and refreshed by a nightly job; GET /market/regime
exposes it. Dashboard shows a regime banner; setup cards flag a counter-trend
caution when a setup fights the regime (LONG in a bearish market / SHORT in a
bullish one). Informational only — nothing is suppressed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-15 12:34:07 +02:00

22 lines
722 B
Python

"""Market-level endpoints (benchmark regime)."""
from fastapi import APIRouter, Depends
from sqlalchemy.ext.asyncio import AsyncSession
from app.dependencies import get_db, require_access
from app.models.user import User
from app.schemas.common import APIEnvelope
from app.services.market_regime_service import get_market_regime
router = APIRouter(tags=["market"])
@router.get("/market/regime", response_model=APIEnvelope)
async def market_regime(
_user: User = Depends(require_access),
db: AsyncSession = Depends(get_db),
) -> APIEnvelope:
"""Current benchmark (SPY) trend regime: bullish / bearish / neutral."""
data = await get_market_regime(db)
return APIEnvelope(status="success", data=data)