feat条件单页本页划入交易户,避免跳转丢失新建表单。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-10-13 14:30:36 +08:00
parent 88337ecdaf
commit 1c3ea77db8
8 changed files with 235 additions and 16 deletions
+55
View File
@@ -325,6 +325,61 @@ def pull_all_stats(window: str = "7d") -> list[dict[str, Any]]:
return results
def post_instance_transfer(
inst: dict[str, Any],
*,
amount: float,
from_acct: str = "funding",
to_acct: str = "trading",
ccy: str = "USDT",
) -> dict[str, Any]:
"""中控指令:实例账户内划转."""
base = (inst.get("base_url") or "").rstrip("/")
token = (inst.get("bridge_token") or "").strip()
out: dict[str, Any] = {
"ok": False,
"msg": "",
"instance_id": inst.get("id"),
"instance_name": inst.get("name"),
}
if not base or not token:
out["msg"] = "缺少 URL 或 Token"
return out
url = f"{base}/api/hub/options/transfer"
try:
r = requests.post(
url,
headers=_headers(token),
json={
"amount": float(amount),
"from": from_acct,
"to": to_acct,
"ccy": ccy,
},
timeout=max(_timeout(), 30.0),
)
data, err = _response_json(r)
if data is None:
out["msg"] = err or f"HTTP {r.status_code}"
return out
if not isinstance(data, dict):
out["msg"] = f"HTTP {r.status_code}"
return out
out.update(data)
out["instance_id"] = inst.get("id")
out["instance_name"] = inst.get("name")
if r.status_code >= 400 and not out.get("ok"):
out["ok"] = False
out.setdefault("msg", err or f"HTTP {r.status_code}")
return out
except requests.Timeout:
out["msg"] = "划转超时"
return out
except Exception as e:
out["msg"] = str(e) or "划转失败"
return out
def fetch_one_pnl_curve(inst: dict[str, Any], *, range_key: str = "7d") -> dict[str, Any]:
"""拉取单机累计已实现盈亏曲线."""
base = (inst.get("base_url") or "").rstrip("/")
+6
View File
@@ -68,6 +68,10 @@ def _candidates_from_snaps(rows: list[dict[str, Any]]) -> list[dict[str, Any]]:
trading_usdt = round(float(trading_usdt), 4)
if funding_usdt is not None:
funding_usdt = round(float(funding_usdt), 4)
transfer_blocked = bool(snap.get("transfer_blocked")) or has_pos
transfer_block_msg = str(snap.get("transfer_block_msg") or "").strip()
if has_pos and not transfer_block_msg:
transfer_block_msg = "期权持仓中禁止划转"
out.append(
{
"id": row.get("id"),
@@ -80,6 +84,8 @@ def _candidates_from_snaps(rows: list[dict[str, Any]]) -> list[dict[str, Any]]:
"error": row.get("error") or "",
"trading_usdt": trading_usdt,
"funding_usdt": funding_usdt,
"transfer_blocked": transfer_blocked,
"transfer_block_msg": transfer_block_msg,
}
)
return out