feat: 修改委托后展示最新风险,四所持仓卡增加张数
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -7498,6 +7498,13 @@ def api_price_snapshot():
|
||||
exchange_tpsl=exchange_tpsl,
|
||||
format_price_fn=format_price_for_symbol,
|
||||
symbol=r["symbol"],
|
||||
margin_capital=margin,
|
||||
leverage=leverage,
|
||||
exchange_notional=ex_metrics.get("notional") if ex_metrics else None,
|
||||
contracts=abs(_position_row_effective_contracts(prow)) if prow else None,
|
||||
contract_size=float(get_contract_size(r["symbol"])) if r["symbol"] else 1.0,
|
||||
mark_price=ex_metrics.get("mark_price") if ex_metrics else price,
|
||||
funds_decimals=FUNDS_DECIMALS,
|
||||
)
|
||||
apply_time_close_to_payload(payload, r)
|
||||
payload["opened_at"] = r["opened_at"] if "opened_at" in r.keys() else None
|
||||
@@ -7617,6 +7624,32 @@ def api_order_place_tpsl(order_id):
|
||||
conn.commit()
|
||||
ex_sym = resolve_monitor_exchange_symbol(row)
|
||||
slots = fetch_exchange_tpsl_slots(ex_sym, direction)
|
||||
prow = None
|
||||
ex_metrics = None
|
||||
if exchange_private_api_configured():
|
||||
try:
|
||||
rows = exchange.fetch_positions([ex_sym]) or exchange.fetch_positions() or []
|
||||
prow = _select_live_position_row(rows, ex_sym, direction)
|
||||
if prow:
|
||||
ex_metrics = parse_ccxt_position_metrics(prow, order_leverage=row["leverage"])
|
||||
except Exception:
|
||||
pass
|
||||
from lib.trade.order_monitor_display_lib import enrich_active_monitor_tpsl_json
|
||||
|
||||
display_extra = enrich_active_monitor_tpsl_json(
|
||||
row,
|
||||
stop_loss,
|
||||
take_profit,
|
||||
slots,
|
||||
position_row=prow,
|
||||
exchange_notional=ex_metrics.get("notional") if ex_metrics else None,
|
||||
contract_size=float(get_contract_size(symbol)) if symbol else 1.0,
|
||||
mark_price=live_price,
|
||||
calc_rr_ratio_fn=calc_rr_ratio,
|
||||
format_price_fn=format_price_for_symbol,
|
||||
symbol=symbol,
|
||||
funds_decimals=FUNDS_DECIMALS,
|
||||
)
|
||||
conn.close()
|
||||
return jsonify(
|
||||
{
|
||||
@@ -7626,6 +7659,7 @@ def api_order_place_tpsl(order_id):
|
||||
"take_profit": take_profit,
|
||||
"planned_rr": planned_rr,
|
||||
"exchange_tpsl": slots,
|
||||
**display_extra,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user