fix: 限制单笔报单最大50手,防止以损定仓计算出超大委托
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+5
-2
@@ -9,6 +9,9 @@ from contract_specs import get_contract_spec
|
||||
MODE_FIXED = "fixed"
|
||||
MODE_RISK = "risk"
|
||||
|
||||
# 单笔报单手数上限(防止以损定仓在止损过近时算出超大手数)
|
||||
DEFAULT_MAX_ORDER_LOTS = 50
|
||||
|
||||
|
||||
def normalize_sizing_mode(raw: str) -> str:
|
||||
m = (raw or MODE_RISK).strip().lower()
|
||||
@@ -63,8 +66,8 @@ def calc_lots_by_risk(
|
||||
if max_by_margin < 1:
|
||||
return None, "可用资金不足以覆盖 1 手保证金"
|
||||
lots = min(lots, max_by_margin)
|
||||
if max_lots is not None:
|
||||
lots = min(lots, int(max_lots))
|
||||
cap_lots = max_lots if max_lots is not None else DEFAULT_MAX_ORDER_LOTS
|
||||
lots = min(lots, cap_lots)
|
||||
return lots, None
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user