Add strategy residual table with manual close at panel bottom.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+28
-1
@@ -1,8 +1,10 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from typing import Annotated
|
||||
|
||||
from fastapi import APIRouter, Depends
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from ..strategy import get_engine
|
||||
from .auth import require_user
|
||||
@@ -28,3 +30,28 @@ async def plan_pause(_user: Annotated[str, Depends(require_user)]) -> dict:
|
||||
@router.post("/emergency-close")
|
||||
async def plan_emergency(_user: Annotated[str, Depends(require_user)]) -> dict:
|
||||
return await get_engine().emergency_close()
|
||||
|
||||
|
||||
class ResidualCloseBody(BaseModel):
|
||||
group_id: str = Field(min_length=1, max_length=128)
|
||||
|
||||
|
||||
@router.post("/residual/close")
|
||||
async def plan_residual_close(
|
||||
body: ResidualCloseBody,
|
||||
_user: Annotated[str, Depends(require_user)],
|
||||
) -> dict:
|
||||
"""手动平单条残留:只验流动性,不验权利金回收比例。"""
|
||||
matcher = get_engine().matcher
|
||||
result = await asyncio.to_thread(matcher.close_residual_manual, body.group_id)
|
||||
if not result.ok:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail=result.detail or "平残留失败",
|
||||
)
|
||||
return {
|
||||
"ok": True,
|
||||
"detail": result.detail,
|
||||
"data": result.data,
|
||||
"liquidity_wait": result.liquidity_wait,
|
||||
}
|
||||
|
||||
@@ -245,7 +245,7 @@ class StrategyEngine:
|
||||
"open_capacity": open_cap,
|
||||
"last_error": last_error,
|
||||
"position": upl,
|
||||
"residuals": self.matcher.list_residual_options(pending_only=True),
|
||||
"residuals": self.matcher.list_residual_options_enriched(),
|
||||
"ledger": self.ledger.snapshot(),
|
||||
"mode": "SIM" if s.is_sim else "LIVE",
|
||||
"sim": s.is_sim,
|
||||
|
||||
Reference in New Issue
Block a user