From b0173e9a0959c47cd25042a7fb656d3edd5ef67a Mon Sep 17 00:00:00 2001 From: "zhangkun9038@dingtalk.com" Date: Sun, 14 Sep 2025 23:45:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E4=BD=BF=E7=94=A8=E4=B8=80?= =?UTF-8?q?=E6=AC=A1=E5=87=BD=E6=95=B0,=20=E4=B8=8D=E5=86=8D=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E5=8F=8D=E6=AD=A3=E5=88=87=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- freqtrade/templates/freqaiprimer.json | 5 ++--- freqtrade/templates/freqaiprimer.py | 18 +++++++++--------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/freqtrade/templates/freqaiprimer.json b/freqtrade/templates/freqaiprimer.json index 446a2ee8..a64b2ee4 100644 --- a/freqtrade/templates/freqaiprimer.json +++ b/freqtrade/templates/freqaiprimer.json @@ -36,9 +36,8 @@ "sell": { "exit_bb_upper_deviation": 0.98, "exit_volume_multiplier": 1.5, - "roi_param_a": 0.039, - "roi_param_k": 0.0101, - "roi_param_t0": 908, + "roi_param_a": -0.0001, + "roi_param_t": 0.06, "rsi_overbought": 55 }, "protection": {} diff --git a/freqtrade/templates/freqaiprimer.py b/freqtrade/templates/freqaiprimer.py index ee2aab27..9ad1b998 100644 --- a/freqtrade/templates/freqaiprimer.py +++ b/freqtrade/templates/freqaiprimer.py @@ -106,10 +106,9 @@ class FreqaiPrimer(IStrategy): add_position_callback = DecimalParameter(0.03, 0.06, decimals=3, default=0.047, optimize=True, load=True, space='buy') # 加仓回调百分比 stake_divisor = IntParameter(2, 4, default=2, optimize=False, load=True, space='buy') # 加仓金额分母 - # 动态ROI参数 - 指数衰减函数参数 (ROI(t) = a·e^(-k·t) + c) - roi_param_a = DecimalParameter(0.03, 0.08, decimals=3, default=0.05, optimize=True, load=True, space='sell') # 初始ROI水平 - roi_param_k = DecimalParameter(0.007, 0.013, decimals=4, default=0.01, optimize=True, load=True, space='sell') # 衰减速率 - roi_param_t0 = IntParameter(300, 960, default=360, optimize=True, load=True, space='sell') # 最低ROI水平 + # 线性ROI参数 - 用于线性函数: y = (a * x) + t + roi_param_a = DecimalParameter(-0.0002, -0.00005, decimals=5, default=-0.0001, optimize=True, load=True, space='sell') # 系数a + roi_param_t = DecimalParameter(0.04, 0.08, decimals=3, default=0.06, optimize=True, load=True, space='sell') # 常数项t # 出场条件阈值参数 exit_bb_upper_deviation = DecimalParameter(0.98, 1.02, decimals=2, default=1.0, optimize=True, load=True, space='sell') exit_volume_multiplier = DecimalParameter(1.5, 3.0, decimals=1, default=2.0, optimize=True, load=True, space='sell') @@ -557,11 +556,12 @@ class FreqaiPrimer(IStrategy): if trade_age_minutes < 0: trade_age_minutes = 0 - a = self.roi_param_a.value - k = self.roi_param_k.value - t0 = self.roi_param_t0.value - - dynamic_roi_threshold = -a * math.atan(k * (trade_age_minutes - t0)) + # 使用可优化的线性函数: y = (a * x) + t + a = self.roi_param_a.value # 系数a (可优化参数) + t = self.roi_param_t.value # 常数项t (可优化参数) + + dynamic_roi_threshold = (a * trade_age_minutes) + t + # 确保ROI阈值不小于0 if dynamic_roi_threshold < 0: dynamic_roi_threshold = 0.0