- Extract shared route_utils.py (validate_symbol, safe decorator)
removing duplication from 6 route files
- Extract shared obb_utils.py (to_list, extract_single, safe_last)
removing duplication from calendar_service and market_service
- Fix _to_list dict mutation during iteration (use comprehension)
- Fix double vars() call and live __dict__ mutation risk
- Fix route ordering: /etf/search and /crypto/search now registered
before /{symbol} path params to prevent shadowing
- Add date format validation (YYYY-MM-DD pattern) on calendar routes
- Use timezone-aware datetime.now(tz=timezone.utc) in all services
- Add explicit type annotation for asyncio.gather results
19 lines
621 B
Python
19 lines
621 B
Python
"""Routes for technical analysis indicators."""
|
|
|
|
from fastapi import APIRouter, Path
|
|
|
|
from models import ApiResponse
|
|
from route_utils import safe, validate_symbol
|
|
import technical_service
|
|
|
|
router = APIRouter(prefix="/api/v1")
|
|
|
|
|
|
@router.get("/stock/{symbol}/technical", response_model=ApiResponse)
|
|
@safe
|
|
async def stock_technical(symbol: str = Path(..., min_length=1, max_length=20)):
|
|
"""Get technical indicators: RSI, MACD, SMA, EMA, Bollinger Bands + signal interpretation."""
|
|
symbol = validate_symbol(symbol)
|
|
data = await technical_service.get_technical_indicators(symbol)
|
|
return ApiResponse(data=data)
|