This commit is contained in:
薇薇安 2026-01-23 13:53:36 +08:00
parent 6aeed50d83
commit 63f1ea05f0
3 changed files with 5 additions and 5 deletions

View File

@ -19,7 +19,7 @@ class ATRStrategy:
def __init__(self): def __init__(self):
"""初始化ATR策略""" """初始化ATR策略"""
self.use_atr = config.TRADING_CONFIG.get('USE_ATR_STOP_LOSS', True) self.use_atr = config.TRADING_CONFIG.get('USE_ATR_STOP_LOSS', True)
self.atr_sl_multiplier = config.TRADING_CONFIG.get('ATR_STOP_LOSS_MULTIPLIER', 1.8) self.atr_sl_multiplier = config.TRADING_CONFIG.get('ATR_STOP_LOSS_MULTIPLIER', 2.5) # 默认2.5,放宽止损提升胜率
self.atr_tp_multiplier = config.TRADING_CONFIG.get('ATR_TAKE_PROFIT_MULTIPLIER', 1.5) self.atr_tp_multiplier = config.TRADING_CONFIG.get('ATR_TAKE_PROFIT_MULTIPLIER', 1.5)
self.risk_reward_ratio = config.TRADING_CONFIG.get('RISK_REWARD_RATIO', 1.5) self.risk_reward_ratio = config.TRADING_CONFIG.get('RISK_REWARD_RATIO', 1.5)
self.atr_period = config.TRADING_CONFIG.get('ATR_PERIOD', 14) self.atr_period = config.TRADING_CONFIG.get('ATR_PERIOD', 14)
@ -37,7 +37,7 @@ class ATRStrategy:
try: try:
cfg = getattr(config, "TRADING_CONFIG", {}) or {} cfg = getattr(config, "TRADING_CONFIG", {}) or {}
self.use_atr = bool(cfg.get('USE_ATR_STOP_LOSS', True)) self.use_atr = bool(cfg.get('USE_ATR_STOP_LOSS', True))
self.atr_sl_multiplier = float(cfg.get('ATR_STOP_LOSS_MULTIPLIER', 1.8)) self.atr_sl_multiplier = float(cfg.get('ATR_STOP_LOSS_MULTIPLIER', 2.5)) # 默认2.5,放宽止损提升胜率
self.atr_tp_multiplier = float(cfg.get('ATR_TAKE_PROFIT_MULTIPLIER', 1.5)) self.atr_tp_multiplier = float(cfg.get('ATR_TAKE_PROFIT_MULTIPLIER', 1.5))
self.risk_reward_ratio = float(cfg.get('RISK_REWARD_RATIO', 1.5)) self.risk_reward_ratio = float(cfg.get('RISK_REWARD_RATIO', 1.5))
self.atr_period = int(cfg.get('ATR_PERIOD', 14)) self.atr_period = int(cfg.get('ATR_PERIOD', 14))

View File

@ -211,7 +211,7 @@ class PositionManager:
# 估算止损价格(用于固定风险计算) # 估算止损价格(用于固定风险计算)
estimated_stop_loss = None estimated_stop_loss = None
if atr and atr > 0: if atr and atr > 0:
atr_multiplier = config.TRADING_CONFIG.get('ATR_STOP_LOSS_MULTIPLIER', 1.8) atr_multiplier = config.TRADING_CONFIG.get('ATR_STOP_LOSS_MULTIPLIER', 2.5) # 默认2.5,放宽止损提升胜率
if estimated_side == 'BUY': if estimated_side == 'BUY':
estimated_stop_loss = estimated_entry_price - (atr * atr_multiplier) estimated_stop_loss = estimated_entry_price - (atr * atr_multiplier)
else: # SELL else: # SELL
@ -506,7 +506,7 @@ class PositionManager:
if atr is not None and atr > 0 and entry_price > 0: if atr is not None and atr > 0 and entry_price > 0:
atr_percent = atr / entry_price atr_percent = atr / entry_price
atr_multiplier = config.TRADING_CONFIG.get('ATR_STOP_LOSS_MULTIPLIER', 1.8) atr_multiplier = config.TRADING_CONFIG.get('ATR_STOP_LOSS_MULTIPLIER', 2.5) # 默认2.5,放宽止损提升胜率
stop_distance_for_tp = entry_price * atr_percent * atr_multiplier stop_distance_for_tp = entry_price * atr_percent * atr_multiplier
take_profit_pct_margin = config.TRADING_CONFIG.get('TAKE_PROFIT_PERCENT', 0.30) take_profit_pct_margin = config.TRADING_CONFIG.get('TAKE_PROFIT_PERCENT', 0.30)

View File

@ -297,7 +297,7 @@ class RiskManager:
if stop_loss_price is None: if stop_loss_price is None:
# 尝试使用ATR估算止损距离 # 尝试使用ATR估算止损距离
if atr and atr > 0: if atr and atr > 0:
atr_multiplier = config.TRADING_CONFIG.get('ATR_STOP_LOSS_MULTIPLIER', 1.8) atr_multiplier = config.TRADING_CONFIG.get('ATR_STOP_LOSS_MULTIPLIER', 2.5) # 默认2.5,放宽止损提升胜率
if side == 'BUY': if side == 'BUY':
estimated_stop_loss = entry_price - (atr * atr_multiplier) estimated_stop_loss = entry_price - (atr * atr_multiplier)
else: # SELL else: # SELL