Spaces:
Sleeping
Sleeping
| from fastapi import APIRouter, HTTPException, Query | |
| from app.schemas import PredictionResponse, ChartForecastResponse | |
| from app.services.prediction import predict_path | |
| router = APIRouter(prefix="/api") | |
| def get_prediction( | |
| ticker: str = Query(..., min_length=1), | |
| days: int = Query(7, ge=1), | |
| ): | |
| try: | |
| prediction_payload, _chart_payload = predict_path(ticker, days) | |
| return prediction_payload | |
| except HTTPException: | |
| raise | |
| except Exception as e: | |
| raise HTTPException(status_code=500, detail=str(e)) | |
| def get_price_forecast( | |
| ticker: str = Query(..., min_length=1), | |
| days: int = Query(7, ge=1), | |
| ): | |
| try: | |
| _prediction_payload, chart_payload = predict_path(ticker, days) | |
| return chart_payload | |
| except HTTPException: | |
| raise | |
| except Exception as e: | |
| raise HTTPException(status_code=500, detail=str(e)) | |