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:
@@ -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"])
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user