Fix CTP exchange routing for non-SHFE contracts and duplicate trade closes.

Resolve CZCE/DCE symbols to the correct exchange for orders, dedupe stop-loss closes and trade logs, and rely on CTP sync for authoritative records.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-26 14:06:49 +08:00
parent 382a9a0e14
commit 4ef33a367f
7 changed files with 191 additions and 45 deletions
+4 -1
View File
@@ -16,7 +16,7 @@ from contract_specs import calc_position_metrics
from ctp_symbol import ths_to_vnpy_symbol
from fee_specs import calc_round_trip_fee
from symbols import ths_to_codes
from trade_log_lib import calc_equity_after, ensure_trade_log_columns
from trade_log_lib import calc_equity_after, purge_duplicate_local_trade_logs, ensure_trade_log_columns
from vnpy_bridge import ctp_list_trades, ctp_status
logger = logging.getLogger(__name__)
@@ -292,4 +292,7 @@ def sync_trade_logs_from_ctp(
refresh_stats_cache(conn, capital)
except Exception as exc:
logger.debug("stats refresh after ctp trade sync: %s", exc)
purged = purge_duplicate_local_trade_logs(conn)
if purged:
stats["purged"] = purged
return stats