fix(ml): make pair and timeframe optional in PredictRequest

- Change pair and timeframe fields from required to optional
- Frontend only sends candles array, not pair/timeframe metadata
- These fields are only used for logging, not prediction logic
- Update logging to handle None values with 'unknown' fallback
- Fixes 422 validation error on /predict endpoint
This commit is contained in:
Marko Djordjevic 2026-02-15 21:43:14 +01:00
parent 5a7c901980
commit 6d0d67e39b
2 changed files with 3 additions and 3 deletions

View file

@ -71,8 +71,8 @@ class CandleData(BaseModel):
class PredictRequest(BaseModel): class PredictRequest(BaseModel):
"""Request model for /predict endpoint.""" """Request model for /predict endpoint."""
pair: str = Field(..., description="Trading pair (e.g., EURUSD)") pair: Optional[str] = Field(None, description="Trading pair (e.g., EURUSD)")
timeframe: str = Field(..., description="Timeframe (e.g., 1H, 4H, 1D)") timeframe: Optional[str] = Field(None, description="Timeframe (e.g., 1H, 4H, 1D)")
candles: List[CandleData] = Field(..., min_length=1, description="Array of candle data") candles: List[CandleData] = Field(..., min_length=1, description="Array of candle data")
@ -518,7 +518,7 @@ async def predict(request: PredictRequest):
detail="Pipeline configuration not loaded" detail="Pipeline configuration not loaded"
) )
logger.info(f"Predict request: {request.pair} {request.timeframe}, {len(request.candles)} candles") logger.info(f"Predict request: {request.pair or 'unknown'} {request.timeframe or 'unknown'}, {len(request.candles)} candles")
try: try:
# Convert candles to list of dicts # Convert candles to list of dicts