Align margin display with CTP counter rates and position margin.

Read margin ratios from CTP instrument query and margin-rate API instead of vnpy ContractData (which lacks ratios). Keep occupied margin on position UseMargin; use per-lot max rate for recommend table.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-29 10:21:44 +08:00
parent 71c480a587
commit 19676943d0
5 changed files with 332 additions and 50 deletions
+1 -1
View File
@@ -216,7 +216,7 @@ def assess_product_for_capital(
code_for_margin = (main_code or "").strip() or (ths + "8888")
if p > 0 and ctp_connected:
margin_one, margin_source, spec_used = margin_one_lot(
code_for_margin, p, trading_mode=trading_mode,
code_for_margin, p, direction="max", trading_mode=trading_mode,
)
if spec_used.get("mult"):
mult = spec_used["mult"]