Add control residual options table with liquidity-only manual close.
Fleet status exposes enriched residuals; manual close skips the premium recovery gate while auto mid-close remains unchanged. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import hashlib
|
||||
import hmac
|
||||
import logging
|
||||
@@ -233,6 +234,12 @@ async def fleet_status(_tok: Annotated[str, Depends(require_fleet_token)]) -> di
|
||||
except Exception:
|
||||
latest_funds = 0.0
|
||||
|
||||
residuals: list[dict] = []
|
||||
try:
|
||||
residuals = get_engine().matcher.list_residual_options_enriched()
|
||||
except Exception:
|
||||
residuals = []
|
||||
|
||||
return {
|
||||
"ok": True,
|
||||
"mode": settings.mode,
|
||||
@@ -240,6 +247,7 @@ async def fleet_status(_tok: Annotated[str, Depends(require_fleet_token)]) -> di
|
||||
"exchange": exchange_name,
|
||||
"sim": settings.is_sim,
|
||||
"latest_funds": latest_funds,
|
||||
"residuals": residuals,
|
||||
"market_connected": bool(snap.connected) if snap else False,
|
||||
"pair": snap.pair.to_dict() if snap and snap.pair else None,
|
||||
"index_px": (
|
||||
@@ -315,6 +323,31 @@ async def fleet_pause(_tok: Annotated[str, Depends(require_fleet_token)]) -> dic
|
||||
return await get_engine().pause()
|
||||
|
||||
|
||||
class ResidualCloseBody(BaseModel):
|
||||
group_id: str = Field(min_length=1, max_length=128)
|
||||
|
||||
|
||||
@router.post("/residual/close")
|
||||
async def fleet_residual_close(
|
||||
body: ResidualCloseBody,
|
||||
_tok: Annotated[str, Depends(require_fleet_token)],
|
||||
) -> 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,
|
||||
}
|
||||
|
||||
|
||||
@router.post("/issue-login")
|
||||
async def fleet_issue_login(_tok: Annotated[str, Depends(require_fleet_token)]) -> dict:
|
||||
username, _ = get_credentials()
|
||||
|
||||
Reference in New Issue
Block a user