Show premium paid on options position card and parse strike/type from instId when OKX omits them.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-08 10:40:07 +08:00
parent 43fa1ad1f3
commit 75a64c5d24
5 changed files with 64 additions and 3 deletions
+18
View File
@@ -306,6 +306,24 @@ def register_options_routes(app: Flask, cfg: dict[str, Any]) -> None:
return jsonify({"ok": False, "msg": err})
raw = cfg["fetch_option_positions"](ex)
rows = [cfg["format_position_row"](p) for p in raw]
conn = cfg["get_db"]()
try:
for row in rows:
inst = row.get("inst_id")
if not inst:
continue
rec = conn.execute(
"""
SELECT premium_paid FROM options_trades
WHERE inst_id = ? AND status = 'open'
ORDER BY id DESC LIMIT 1
""",
(inst,),
).fetchone()
if rec and rec["premium_paid"] is not None:
row["premium_paid"] = round(float(rec["premium_paid"]), 4)
finally:
conn.close()
return jsonify({"ok": True, "positions": rows})
@app.route("/api/options/close", methods=["POST"])
+1 -1
View File
@@ -136,4 +136,4 @@
</div>
</div>
</div>
<script src="/static/options_panel.js?v=11"></script>
<script src="/static/options_panel.js?v=12"></script>