chore: restore codebase to state before 2026-08-11 changes
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -2028,8 +2028,7 @@ async def _fetch_flask_json(
|
||||
return parsed
|
||||
return _parse_http_json_body(r)
|
||||
except Exception as e:
|
||||
err = str(e)
|
||||
return {"ok": False, "error": err, "msg": err}
|
||||
return {"ok": False, "error": str(e)}
|
||||
|
||||
|
||||
async def _notify_instance_user_close(
|
||||
@@ -2568,8 +2567,8 @@ def _merge_flask_exchange_tpsl(agent_row: dict, snap: dict | None, hub_mon: dict
|
||||
|
||||
async def _fetch_exchange_flask_bundle(
|
||||
client: httpx.AsyncClient, ex: dict, *, trading_day: str | None = None
|
||||
) -> tuple:
|
||||
"""单所 Flask:monitor / meta / price_snapshot / account / trades/today / options 并行拉取."""
|
||||
) -> tuple[dict | None, dict | None, list | None, dict | None, dict | None, dict | None]:
|
||||
"""单所 Flask:monitor / meta / price_snapshot / account / trades/today(有 flask_url 时)并行拉取."""
|
||||
caps = ex.get("capabilities") or []
|
||||
tasks = [
|
||||
_fetch_flask_json(client, ex, "/api/hub/monitor"),
|
||||
@@ -2577,7 +2576,6 @@ async def _fetch_exchange_flask_bundle(
|
||||
]
|
||||
has_flask = bool((ex.get("flask_url") or "").strip())
|
||||
day = (trading_day or "").strip()
|
||||
want_options = has_flask and "options" in caps
|
||||
if has_flask:
|
||||
tasks.extend(
|
||||
[
|
||||
@@ -2594,26 +2592,15 @@ async def _fetch_exchange_flask_bundle(
|
||||
params={"trading_day": day},
|
||||
)
|
||||
)
|
||||
if want_options:
|
||||
tasks.append(_fetch_flask_json(client, ex, "/api/hub/options/snapshot"))
|
||||
results = await asyncio.gather(*tasks)
|
||||
hub_mon = results[0]
|
||||
meta = results[1]
|
||||
idx = 2
|
||||
snap = None
|
||||
account = None
|
||||
trades_today = None
|
||||
snap = results[2] if has_flask and len(results) > 2 else None
|
||||
account = results[3] if has_flask and len(results) > 3 else None
|
||||
trades_today = results[4] if has_flask and day and len(results) > 4 else None
|
||||
options_snap = None
|
||||
if has_flask:
|
||||
snap = results[idx]
|
||||
idx += 1
|
||||
account = results[idx]
|
||||
idx += 1
|
||||
if day:
|
||||
trades_today = results[idx]
|
||||
idx += 1
|
||||
if want_options:
|
||||
options_snap = results[idx]
|
||||
if has_flask and "options" in caps:
|
||||
options_snap = await _fetch_flask_json(client, ex, "/api/hub/options/snapshot")
|
||||
key_prices = None
|
||||
want_prices = HUB_BOARD_KEY_PRICES and "key" in caps
|
||||
if want_prices and isinstance(snap, dict):
|
||||
|
||||
@@ -3930,19 +3930,6 @@
|
||||
|
||||
function renderOptionsTargetCell(target) {
|
||||
if (!target) return "<td>—</td>";
|
||||
const rr =
|
||||
target.profit_rr != null
|
||||
? Number(target.profit_rr)
|
||||
: target.oo_profit_rr != null
|
||||
? Number(target.oo_profit_rr)
|
||||
: null;
|
||||
if (rr != null && Number.isFinite(rr) && rr > 0) {
|
||||
const txt = `盈亏比×${fmt(rr, 2)}`;
|
||||
if (target.managed_by === "hedge_plan") {
|
||||
return `<td class="hub-opt-target-cell is-on is-hedge" title="由对冲计划监控">对冲#${esc(target.plan_id)} ${esc(txt)}</td>`;
|
||||
}
|
||||
return `<td class="hub-opt-target-cell is-on" title="盈亏比监控">${esc(txt)}</td>`;
|
||||
}
|
||||
const side = String(target.opt_type || "").toUpperCase() === "P" ? "Put≤" : "Call≥";
|
||||
const px = target.target_index != null ? fmt(target.target_index, 1) : "—";
|
||||
if (target.managed_by === "hedge_plan") {
|
||||
@@ -3955,7 +3942,7 @@
|
||||
if (!pos.length) return '<div class="empty-hint hub-slot-pos">暂无期权持仓</div>';
|
||||
const showPnl = showAccountPnlPref();
|
||||
let html = '<div class="table-wrap hub-options-table-wrap"><table class="hub-options-table"><thead><tr>';
|
||||
html += "<th>合约</th><th>类型</th><th>张数</th><th>到期倒计时</th><th>盈亏比</th>";
|
||||
html += "<th>合约</th><th>类型</th><th>张数</th><th>到期倒计时</th><th>目标监控</th>";
|
||||
if (showPnl) html += "<th>净盈亏</th><th>收益率</th>";
|
||||
html += "</tr></thead><tbody>";
|
||||
pos.forEach((p) => {
|
||||
@@ -4022,26 +4009,20 @@
|
||||
function renderOptionsSectionBody(row, opts) {
|
||||
const options = opts || {};
|
||||
const layout = options.layout || "table";
|
||||
const caps = Array.isArray(row.capabilities) ? row.capabilities : [];
|
||||
const wantsOptions = caps.indexOf("options") >= 0;
|
||||
const opt = row.options;
|
||||
const opt = row.options || {};
|
||||
let html = "";
|
||||
if (wantsOptions && (opt == null || typeof opt !== "object")) {
|
||||
html += '<div class="section-title hub-options-title">期权持仓</div>';
|
||||
html += `<div class="err">期权数据不可用</div>`;
|
||||
} else if ((opt || {}).enabled === false) {
|
||||
html += renderOptionsAccountStatRow(opt || {});
|
||||
if (opt.enabled === false) {
|
||||
html += renderOptionsAccountStatRow(opt);
|
||||
html += '<div class="section-title hub-options-title">期权持仓</div>';
|
||||
html += '<div class="empty-hint">期权未启用(OKX_OPTIONS_ENABLED)</div>';
|
||||
} else if ((opt || {}).ok === false) {
|
||||
html += renderOptionsAccountStatRow(opt || {});
|
||||
} else if (opt.ok === false) {
|
||||
html += renderOptionsAccountStatRow(opt);
|
||||
html += '<div class="section-title hub-options-title">期权持仓</div>';
|
||||
html += `<div class="err">${esc((opt && (opt.msg || opt.error)) || "期权数据不可用")}</div>`;
|
||||
html += `<div class="err">${esc(opt.msg || "期权数据不可用")}</div>`;
|
||||
} else {
|
||||
const optSafe = opt || {};
|
||||
const pos = Array.isArray(optSafe.positions) ? optSafe.positions : [];
|
||||
const targets = Array.isArray(optSafe.target_monitors) ? optSafe.target_monitors : [];
|
||||
html += renderOptionsAccountStatRow(optSafe);
|
||||
const pos = Array.isArray(opt.positions) ? opt.positions : [];
|
||||
const targets = Array.isArray(opt.target_monitors) ? opt.target_monitors : [];
|
||||
html += renderOptionsAccountStatRow(opt);
|
||||
html += `<div class="section-title hub-options-title">期权持仓 · ${pos.length} 仓</div>`;
|
||||
html +=
|
||||
layout === "cards"
|
||||
|
||||
@@ -115,7 +115,7 @@
|
||||
<span class="plan-radio-row" id="plan-create-direction"></span>
|
||||
</label>
|
||||
<label class="plan-field">
|
||||
<span>盈亏比</span>
|
||||
<span>目标位</span>
|
||||
<input id="plan-create-target" type="text" placeholder="如 68500" autocomplete="off" data-lpignore="true" data-1p-ignore="true" data-form-type="other" />
|
||||
</label>
|
||||
<label class="plan-field">
|
||||
@@ -1765,8 +1765,8 @@
|
||||
<script src="/assets/ai_review_render.js?v=3"></script>
|
||||
<script src="/assets/time_close_ui.js?v=3"></script>
|
||||
<script src="/assets/options_expiry_countdown.js?v=1"></script>
|
||||
<script src="/assets/options_position_cards.js?v=5"></script>
|
||||
<script src="/assets/options_position_cards.js?v=4"></script>
|
||||
<script src="/assets/backup.js?v=1"></script>
|
||||
<script src="/assets/app.js?v=20260811-opt-rr"></script>
|
||||
<script src="/assets/app.js?v=20260807-opt-float"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user