feat: collect Bybit orderbook observations for training
This commit is contained in:
@@ -149,6 +149,27 @@ def create_app(settings: Settings | None = None) -> FastAPI:
|
||||
async def training_status(_: None = Depends(authorizer.require)) -> dict[str, Any]:
|
||||
return training.status()
|
||||
|
||||
@app.get("/api/training/market-observations")
|
||||
async def training_market_observations(
|
||||
symbol: str,
|
||||
after_id: int = 0,
|
||||
limit: int = 5000,
|
||||
_: None = Depends(authorizer.require_training),
|
||||
) -> dict[str, Any]:
|
||||
normalized_symbol = symbol.strip().upper()
|
||||
if not normalized_symbol:
|
||||
raise HTTPException(status_code=400, detail="symbol is required")
|
||||
items = storage.market_observations_after(
|
||||
symbol=normalized_symbol,
|
||||
after_id=max(0, after_id),
|
||||
limit=max(1, min(limit, 5000)),
|
||||
)
|
||||
return {
|
||||
"symbol": normalized_symbol,
|
||||
"items": items,
|
||||
"next_after_id": int(items[-1]["id"]) if items else max(0, after_id),
|
||||
}
|
||||
|
||||
@app.post("/api/training/retrain")
|
||||
async def training_retrain(
|
||||
payload: dict[str, Any] | None = None,
|
||||
@@ -407,6 +428,8 @@ def _safe_config(settings: Settings) -> dict[str, Any]:
|
||||
"time_series_require_fresh_model": settings.time_series_require_fresh_model,
|
||||
"time_series_model_max_age_hours": settings.time_series_model_max_age_hours,
|
||||
"market_ticker_max_age_seconds": settings.market_ticker_max_age_seconds,
|
||||
"market_observation_enabled": settings.market_observation_enabled,
|
||||
"market_observation_sample_seconds": settings.market_observation_sample_seconds,
|
||||
"time_series_model_artifact": _time_series_model_artifact(settings),
|
||||
"stop_loss_percent": settings.stop_loss_percent,
|
||||
"stop_loss_exit_enabled": settings.stop_loss_exit_enabled,
|
||||
|
||||
Reference in New Issue
Block a user