From 7e2a2fce041d65e89fbe55024a87abee777e6e93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=B8=D0=BA=D1=82=D0=BE=D1=80?= <78488229+viktor138irk@users.noreply.github.com> Date: Fri, 8 May 2026 03:54:50 +0900 Subject: [PATCH] Add app bootstrap and best market endpoint --- app/main.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/app/main.py b/app/main.py index acb9056..ba90ea9 100644 --- a/app/main.py +++ b/app/main.py @@ -42,6 +42,19 @@ async def health() -> dict: } +@app.get('/api/v1/app/bootstrap') +async def app_bootstrap(db: Session = Depends(get_db)) -> dict: + state = ai_bot.get_or_create_state(db) + account = demo_service.snapshot(db) + return { + 'app': settings.app_name, + 'default_market': settings.default_market, + 'markets': settings.markets, + 'bot': ai_bot.state_to_dict(state), + 'account': account.model_dump(mode='json'), + } + + @app.get('/api/v1/demo/account') async def demo_account(db: Session = Depends(get_db)) -> dict: return demo_service.snapshot(db).model_dump(mode='json') @@ -133,6 +146,15 @@ async def analyze_market(market: str | None = None, db: Session = Depends(get_db raise HTTPException(status_code=400, detail=str(exc)) from exc +@app.get('/api/v1/bot/best-market') +async def best_market(db: Session = Depends(get_db)) -> dict: + try: + pack = await ai_bot.choose_best_market(db) + return pack.as_dict() + except ValueError as exc: + raise HTTPException(status_code=400, detail=str(exc)) from exc + + @app.post('/api/v1/bot/decide') async def bot_decide(market: str | None = None, db: Session = Depends(get_db)) -> dict: try: