Add app bootstrap and best market endpoint
Этот коммит содержится в:
@@ -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')
|
@app.get('/api/v1/demo/account')
|
||||||
async def demo_account(db: Session = Depends(get_db)) -> dict:
|
async def demo_account(db: Session = Depends(get_db)) -> dict:
|
||||||
return demo_service.snapshot(db).model_dump(mode='json')
|
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
|
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')
|
@app.post('/api/v1/bot/decide')
|
||||||
async def bot_decide(market: str | None = None, db: Session = Depends(get_db)) -> dict:
|
async def bot_decide(market: str | None = None, db: Session = Depends(get_db)) -> dict:
|
||||||
try:
|
try:
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user