This commit is contained in:
薇薇安 2026-01-27 16:19:23 +08:00
parent 1d25b3cb79
commit fb04f69965
2 changed files with 10 additions and 24 deletions

View File

@ -755,12 +755,10 @@ class ConfigManager:
if key in percent_keys: if key in percent_keys:
# 如果值>1认为是百分比形式旧数据转换为比例形式 # 如果值>1认为是百分比形式旧数据转换为比例形式
# 数据迁移完成后,所有值都应该<=1此逻辑可以移除 # 静默转换,不输出警告(用户已确认数据库应存储小数形式)
if value > 1: if value > 1:
old_value = value
value = value / 100.0 value = value / 100.0
logger.warning(f"配置值格式转换(临时兼容): {key} = {value*100:.2f}% (从百分比形式{old_value}转换为比例形式,建议执行数据迁移)") # 静默更新Redis缓存避免下次读取时再次触发转换
# ⚠️ 关键修复转换后立即更新Redis缓存避免下次读取时再次触发转换
try: try:
if key in RISK_KNOBS_KEYS: if key in RISK_KNOBS_KEYS:
# 风险旋钮更新当前账号的Redis缓存 # 风险旋钮更新当前账号的Redis缓存
@ -774,18 +772,6 @@ class ConfigManager:
global_config_mgr._cache[key] = value global_config_mgr._cache[key] = value
except Exception as e: except Exception as e:
logger.debug(f"更新Redis缓存失败不影响使用: {key} = {e}") logger.debug(f"更新Redis缓存失败不影响使用: {key} = {e}")
# ⚠️ 关键修复转换后立即更新Redis缓存避免下次读取时再次触发转换
try:
if key in RISK_KNOBS_KEYS:
# 风险旋钮更新当前账号的Redis缓存
self._set_to_redis(key, value)
else:
# 全局配置更新全局配置的Redis缓存
global_config_mgr._set_to_redis(key, value)
# 同时更新本地缓存
global_config_mgr._cache[key] = value
except Exception as e:
logger.debug(f"更新Redis缓存失败不影响使用: {key} = {e}")
return value return value

View File

@ -2861,15 +2861,15 @@ class PositionManager:
logger.warning(f"{symbol} [实时监控] ⚠️ 异常:盈利单触发止损但未激活移动止损,标记为移动止损") logger.warning(f"{symbol} [实时监控] ⚠️ 异常:盈利单触发止损但未激活移动止损,标记为移动止损")
else: else:
# 正常止损逻辑 # 正常止损逻辑
should_close_due_to_sl = True should_close_due_to_sl = True
# ⚠️ 2026-01-27优化如果已部分止盈细分状态 # ⚠️ 2026-01-27优化如果已部分止盈细分状态
if partial_profit_taken: if partial_profit_taken:
if position_info.get('trailingStopActivated'): if position_info.get('trailingStopActivated'):
exit_reason_sl = 'take_profit_partial_then_trailing_stop' exit_reason_sl = 'take_profit_partial_then_trailing_stop'
else:
exit_reason_sl = 'take_profit_partial_then_stop'
else: else:
exit_reason_sl = 'take_profit_partial_then_stop' exit_reason_sl = 'trailing_stop' if position_info.get('trailingStopActivated') else 'stop_loss'
else:
exit_reason_sl = 'trailing_stop' if position_info.get('trailingStopActivated') else 'stop_loss'
# 计算持仓时间 # 计算持仓时间
entry_time = position_info.get('entryTime') entry_time = position_info.get('entryTime')