Prefer CTP PnL-consistent entry when vnpy avg differs from SimNow.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+8
-3
@@ -564,7 +564,9 @@ def install_trading(app, *, login_required, require_nav, get_db, get_setting, se
|
||||
continue
|
||||
if not _match_ctp_symbol(p.get("symbol") or "", sym):
|
||||
continue
|
||||
entry, _ = resolve_ctp_entry(sym, direction, p, trades)
|
||||
entry, _ = resolve_ctp_entry(
|
||||
sym, direction, p, trades, tick=ctp_get_tick_price(mode, sym),
|
||||
)
|
||||
if entry > 0:
|
||||
return float(entry)
|
||||
return fallback
|
||||
@@ -578,12 +580,14 @@ def install_trading(app, *, login_required, require_nav, get_db, get_setting, se
|
||||
if not ctp:
|
||||
return 0.0, "none"
|
||||
trades: list = []
|
||||
tick = None
|
||||
if ctp_status(mode).get("connected"):
|
||||
try:
|
||||
trades = ctp_list_trades(mode)
|
||||
except Exception:
|
||||
pass
|
||||
return resolve_ctp_entry(sym, direction, ctp, trades)
|
||||
tick = ctp_get_tick_price(mode, sym)
|
||||
return resolve_ctp_entry(sym, direction, ctp, trades, tick=tick)
|
||||
|
||||
def _open_commission_from_ctp_trades(
|
||||
mode: str, sym: str, direction: str,
|
||||
@@ -1874,7 +1878,8 @@ def install_trading(app, *, login_required, require_nav, get_db, get_setting, se
|
||||
return
|
||||
mode = get_trading_mode(get_setting)
|
||||
if trading_state.try_lock_entry_prices():
|
||||
_push_position_snapshot_async(fast=True)
|
||||
_push_position_snapshot_async(fast=False)
|
||||
return
|
||||
payload = _build_position_quotes_payload(mode)
|
||||
if payload.get("quotes"):
|
||||
position_hub.push_event("position_quotes", payload)
|
||||
|
||||
Reference in New Issue
Block a user