波动系数
This commit is contained in:
parent
586da576b4
commit
dafa793e5f
@ -90,17 +90,17 @@ class FreqaiPrimer(IStrategy):
|
||||
|
||||
# 确保EMA值在合理范围内
|
||||
final_coef = max(0.1, min(5.0, ema_volatility_coef))
|
||||
self.log_once(f"计算波动系数EMA完成 {pair}: 最终系数={final_coef:.4f} (历史数据点数={len(self._volatility_history[pair])})")
|
||||
logger.info(f"计算波动系数EMA完成 {pair}: 最终系数={final_coef:.4f} (历史数据点数={len(self._volatility_history[pair])})")
|
||||
return final_coef
|
||||
else:
|
||||
# 如果历史数据不足,返回当前波动系数(或默认值)
|
||||
# 当历史数据少于EMA周期时,使用简单移动平均或直接返回当前值
|
||||
# 这里选择直接返回当前波动系数,并限制范围
|
||||
final_coef = max(0.1, min(5.0, current_volatility_coef))
|
||||
self.log_once(f"计算波动系数EMA完成 {pair}: 最终系数={final_coef:.4f} (历史数据不足,使用当前值)")
|
||||
logger.info(f"计算波动系数EMA完成 {pair}: 最终系数={final_coef:.4f} (历史数据不足,使用当前值)")
|
||||
return final_coef
|
||||
except Exception as e:
|
||||
self.log_once(f"计算波动系数EMA时出错 {pair}: {str(e)}", logger=self.logger.warning)
|
||||
logger.warning(f"计算波动系数EMA时出错 {pair}: {str(e)}")
|
||||
return 1.0 # 出错时返回默认值1.0
|
||||
|
||||
def _calculate_current_volatility_coef(self, pair: str) -> float:
|
||||
@ -142,7 +142,7 @@ class FreqaiPrimer(IStrategy):
|
||||
# 下限设置为0.1(非常稳定的币对)
|
||||
return max(0.1, min(5.0, volatility_coef))
|
||||
except Exception as e:
|
||||
self.log_once(f"计算当前波动系数时出错 {pair}: {str(e)}", logger=self.logger.warning)
|
||||
logger.warning(f"计算当前波动系数时出错 {pair}: {str(e)}")
|
||||
return 1.0 # 出错时返回默认值1.0
|
||||
|
||||
# 其他辅助方法可以在这里添加
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user