From 7aa5697d727528f667f01f23b538d687474ef989 Mon Sep 17 00:00:00 2001 From: "zhangkun9038@dingtalk.com" Date: Sun, 14 Sep 2025 23:59:52 +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 | 1 + freqtrade/templates/freqaiprimer.py | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/freqtrade/templates/freqaiprimer.json b/freqtrade/templates/freqaiprimer.json index a64b2ee4..014cb29c 100644 --- a/freqtrade/templates/freqaiprimer.json +++ b/freqtrade/templates/freqaiprimer.json @@ -37,6 +37,7 @@ "exit_bb_upper_deviation": 0.98, "exit_volume_multiplier": 1.5, "roi_param_a": -0.0001, + "roi_param_k": 50, "roi_param_t": 0.06, "rsi_overbought": 55 }, diff --git a/freqtrade/templates/freqaiprimer.py b/freqtrade/templates/freqaiprimer.py index 9ad1b998..28c0fc3a 100644 --- a/freqtrade/templates/freqaiprimer.py +++ b/freqtrade/templates/freqaiprimer.py @@ -106,9 +106,10 @@ 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参数 - 用于线性函数: y = (a * x) + t + # 线性ROI参数 - 用于线性函数: y = (a * (x + k)) + 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 + roi_param_k = IntParameter(20, 150, default=50, optimize=True, load=True, space='sell') # 偏移量k + roi_param_t = DecimalParameter(0.02, 0.18, 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') @@ -556,11 +557,12 @@ class FreqaiPrimer(IStrategy): if trade_age_minutes < 0: trade_age_minutes = 0 - # 使用可优化的线性函数: y = (a * x) + t + # 使用可优化的线性函数: y = (a * (x + k)) + t a = self.roi_param_a.value # 系数a (可优化参数) + k = self.roi_param_k.value # 偏移量k (可优化参数) t = self.roi_param_t.value # 常数项t (可优化参数) - dynamic_roi_threshold = (a * trade_age_minutes) + t + dynamic_roi_threshold = (a * (trade_age_minutes + k)) + t # 确保ROI阈值不小于0 if dynamic_roi_threshold < 0: dynamic_roi_threshold = 0.0