This commit is contained in:
zhangkun9038@dingtalk.com 2025-05-01 12:33:24 +08:00
parent e6402d08dd
commit cdce4eba5b
26 changed files with 18262 additions and 201 deletions

View File

@ -0,0 +1,6 @@
<<<<<<< HEAD
=======
dataframe['target'] = np.where(short_ma > long_ma, 2,
np.where(short_ma < long_ma, 0, 1))
>>>>>>> Snippet

2
.gitignore vendored
View File

@ -120,3 +120,5 @@ target/
docker-compose-*.yml
data/
!result/

126
config_examples/basic.json Normal file
View File

@ -0,0 +1,126 @@
{
"$schema": "https://schema.freqtrade.io/schema.json",
"trading_mode": "spot",
"margin_mode": "isolated",
"max_open_trades": 4,
"stake_currency": "USDT",
"stake_amount": 150,
"startup_candle_count": 30,
"tradable_balance_ratio": 1,
"fiat_display_currency": "USD",
"dry_run": true,
"timeframe": "3m",
"dry_run_wallet": 1000,
"cancel_open_orders_on_exit": true,
"stoploss": -0.05,
"unfilledtimeout": {
"entry": 5,
"exit": 15
},
"exchange": {
"name": "okx",
"key": "eca767d4-fda5-4a1b-bb28-49ae18093307",
"secret": "8CA3628A556ED137977DB298D37BC7F3",
"enable_ws": false,
"ccxt_config": {
"enableRateLimit": true,
"rateLimit": 500,
"options": {
"defaultType": "spot"
}
},
"ccxt_async_config": {
"enableRateLimit": true,
"rateLimit": 500,
"timeout": 20000
},
"pair_whitelist": [
"BTC/USDT",
"SOL/USDT"
],
"pair_blacklist": []
},
"entry_pricing": {
"price_side": "same",
"use_order_book": true,
"order_book_top": 1,
"price_last_balance": 0.0,
"check_depth_of_market": {
"enabled": false,
"bids_to_ask_delta": 1
}
},
"exit_pricing": {
"price_side": "other",
"use_order_book": true,
"order_book_top": 1
},
"pairlists": [
{
"method": "StaticPairList"
}
],
"freqai": {
"enabled": true,
"data_kitchen": {
"fillna": "ffill",
"feature_parameters": {
"DI_threshold": 0.9,
"weight_factor": 0.9
}
},
"freqaimodel": "XGBoostRegressor",
"purge_old_models": 2,
"identifier": "test175",
"train_period_days": 30,
"backtest_period_days": 10,
"live_retrain_hours": 0,
"feature_selection": {
"method": "recursive_elimination",
"threshold": 0.01
},
"feature_parameters": {
"include_timeframes": ["5m", "1h"],
"include_corr_pairlist": ["BTC/USDT"],
"label_period_candles": 10,
"use_SVM_to_remove_outliers": true,
"principal_component_analysis": true
},
"model": "XGBoostRegressor",
"data_split_parameters": {
"test_size": 0.2,
"shuffle": true,
"random_state": 42
},
"model_training_parameters": {
"n_estimators": 200,
"learning_rate": 0.05,
"max_depth": 5,
"subsample": 0.8,
"colsample_bytree": 0.8,
"objective": "reg:squarederror",
"eval_metric": "rmse",
"early_stopping_rounds": 50
}
},
"api_server": {
"enabled": true,
"listen_ip_address": "0.0.0.0",
"listen_port": 8080,
"verbosity": "error",
"enable_openapi": false,
"jwt_secret_key": "6a599ab046dbb419014807dffd7b8823bfa7e5df56b17d545485deb87331b4ca",
"ws_token": "6O5pBDiRigiZrmIsofaE2rkKMJtf9h8zVQ",
"CORS_origins": [],
"username": "freqAdmin",
"password": "admin"
},
"bot_name": "freqtrade",
"initial_state": "running",
"force_entry_enable": false,
"internals": {
"process_throttle_secs": 5,
"heartbeat_interval": 20,
"loglevel": "DEBUG"
}
}

2334
debug.log Normal file

File diff suppressed because it is too large Load Diff

View File

@ -60,13 +60,14 @@ services:
# --hyperopt-loss SharpeHyperOptLoss
# --spaces roi stoploss
# -e 200
#--config /freqtrade/templates/FreqaiExampleStrategy.json
command: >
backtesting
--logfile /freqtrade/user_data/logs/freqtrade.log
--freqaimodel XGBoostRegressor
--config /freqtrade/config_examples/config_freqai.okx.json
--config /freqtrade/templates/FreqaiExampleStrategy.json
--strategy-path /freqtrade/templates
--strategy FreqaiExampleStrategy
--timerange 20250401-20250420

407
e6402d0.diff Normal file
View File

@ -0,0 +1,407 @@
diff --git a/freqtrade/templates/FreqaiExampleStrategy.py b/freqtrade/templates/FreqaiExampleStrategy.py
index 00ff1d2..40a1adc 100644
--- a/freqtrade/templates/FreqaiExampleStrategy.py
+++ b/freqtrade/templates/FreqaiExampleStrategy.py
@@ -9,44 +9,47 @@ from freqtrade.strategy import IStrategy, IntParameter, DecimalParameter
logger = logging.getLogger(__name__)
class FreqaiExampleStrategy(IStrategy):
- # 移除硬编码的 minimal_roi 和 stoploss改为动态适配
- minimal_roi = {} # 将在 populate_indicators 中动态生成
- stoploss = 0.0 # 将在 populate_indicators 中动态设置
+ # 动态适配 minimal_roi 和 stoploss
+ minimal_roi = {} # populate_indicators 中动态设定
+ stoploss = -0.15 # 默认固定止损
trailing_stop = True
+ trailing_stop_positive = 0.05
+ trailing_stop_positive_offset = 0.1
process_only_new_candles = True
use_exit_signal = True
startup_candle_count: int = 40
can_short = False
- # 参数定义FreqAI 动态适配 buy_rsi 和 sell_rsi禁用 Hyperopt 优化
+ # 可训练参数(用于 Hyperopt
buy_rsi = IntParameter(low=10, high=50, default=27, space="buy", optimize=False, load=True)
sell_rsi = IntParameter(low=50, high=90, default=59, space="sell", optimize=False, load=True)
- # 为 Hyperopt 优化添加 ROI 和 stoploss 参数
roi_0 = DecimalParameter(low=0.01, high=0.2, default=0.038, space="roi", optimize=True, load=True)
roi_15 = DecimalParameter(low=0.005, high=0.1, default=0.027, space="roi", optimize=True, load=True)
roi_30 = DecimalParameter(low=0.001, high=0.05, default=0.009, space="roi", optimize=True, load=True)
- stoploss_param = DecimalParameter(low=-0.35, high=-0.1, default=-0.182, space="stoploss", optimize=True, load=True)
+ stoploss_param = DecimalParameter(
+ low=-0.35, high=-0.1, default=-0.182, space="stoploss", optimize=True, load=True
+ )
# FreqAI 配置
freqai_info = {
- "model": "CatboostClassifier", # 与config保持一致
+ "model": "CatboostClassifier",
"feature_parameters": {
- "include_timeframes": ["3m", "15m", "1h"], # 与config一致
- "include_corr_pairlist": ["BTC/USDT", "SOL/USDT"], # 添加相关交易对
- "label_period_candles": 20, # 与config一致
- "include_shifted_candles": 2, # 与config一致
+ "include_timeframes": ["3m", "15m", "1h"],
+ "include_corr_pairlist": ["BTC/USDT", "SOL/USDT"],
+ "label_period_candles": 20,
+ "include_shifted_candles": 2,
},
"data_split_parameters": {
"test_size": 0.2,
- "shuffle": True, # 启用shuffle
+ "shuffle": True,
},
"model_training_parameters": {
- "n_estimators": 100, # 减少树的数量
- "learning_rate": 0.1, # 提高学习率
- "max_depth": 6, # 限制树深度
- "subsample": 0.8, # 添加子采样
- "colsample_bytree": 0.8, # 添加特征采样
+ "n_estimators": 100,
+ "learning_rate": 0.1,
+ "max_depth": 6,
+ "subsample": 0.8,
+ "colsample_bytree": 0.8,
"objective": "reg:squarederror",
"eval_metric": "rmse",
"early_stopping_rounds": 20,
@@ -54,8 +57,8 @@ class FreqaiExampleStrategy(IStrategy):
},
"data_kitchen": {
"feature_parameters": {
- "DI_threshold": 1.5, # 降低异常值过滤阈值
- "use_DBSCAN_to_remove_outliers": False # 禁用DBSCAN
+ "DI_threshold": 1.5,
+ "use_DBSCAN_to_remove_outliers": False
}
}
}
@@ -72,265 +75,113 @@ class FreqaiExampleStrategy(IStrategy):
}
def feature_engineering_expand_all(self, dataframe: DataFrame, period: int, metadata: dict, **kwargs) -> DataFrame:
- # 保留关键的技术指标
+ # RSI 计算
dataframe["rsi"] = ta.RSI(dataframe, timeperiod=14)
- # 确保 MACD 列被正确计算并保留
+ # MACD 计算并容错
try:
macd = ta.MACD(dataframe, fastperiod=12, slowperiod=26, signalperiod=9)
dataframe["macd"] = macd["macd"]
dataframe["macdsignal"] = macd["macdsignal"]
except Exception as e:
- logger.error(f"计算 MACD 列时出错:{str(e)}")
+ logger.error(f"MACD 计算失败: {e}")
dataframe["macd"] = np.nan
dataframe["macdsignal"] = np.nan
- # 检查 MACD 列是否存在
- if "macd" not in dataframe.columns or "macdsignal" not in dataframe.columns:
- logger.error("MACD 或 MACD 信号列缺失,无法生成买入信号")
- raise ValueError("DataFrame 缺少必要的 MACD 列")
-
- # 确保 MACD 列存在
- if "macd" not in dataframe.columns or "macdsignal" not in dataframe.columns:
- logger.error("MACD 或 MACD 信号列缺失,无法生成买入信号")
- raise ValueError("DataFrame 缺少必要的 MACD 列")
-
- # 保留布林带相关特征
+ # 布林带
bollinger = qtpylib.bollinger_bands(qtpylib.typical_price(dataframe), window=20, stds=2)
dataframe["bb_lowerband"] = bollinger["lower"]
dataframe["bb_middleband"] = bollinger["mid"]
dataframe["bb_upperband"] = bollinger["upper"]
- # 保留成交量相关特征
+ # 成交量均线
dataframe["volume_ma"] = dataframe["volume"].rolling(window=20).mean()
- # 数据清理
+ # 清理无穷大值
for col in dataframe.columns:
if dataframe[col].dtype in ["float64", "int64"]:
dataframe[col] = dataframe[col].replace([np.inf, -np.inf], np.nan)
- dataframe[col] = dataframe[col].ffill().fillna(0)
-
- logger.info(f"特征工程完成,特征数量:{len(dataframe.columns)}")
+ dataframe[col] = dataframe[col].fillna(0)
+
return dataframe
def feature_engineering_expand_basic(self, dataframe: DataFrame, metadata: dict, **kwargs) -> DataFrame:
dataframe["%-pct-change"] = dataframe["close"].pct_change()
dataframe["%-raw_volume"] = dataframe["volume"]
dataframe["%-raw_price"] = dataframe["close"]
-# 数据清理逻辑
+
+ # 数据清理
for col in dataframe.columns:
if dataframe[col].dtype in ["float64", "int64"]:
dataframe[col] = dataframe[col].replace([np.inf, -np.inf], 0)
- dataframe[col] = dataframe[col].ffill()
- dataframe[col] = dataframe[col].fillna(0)
-
- # 检查是否仍有无效值
- if dataframe[col].isna().any() or np.isinf(dataframe[col]).any():
- logger.warning(f"列 {col} 仍包含无效值,已填充为默认值")
- dataframe[col] = dataframe[col].fillna(0)
- return dataframe
-
- def feature_engineering_standard(self, dataframe: DataFrame, metadata: dict, **kwargs) -> DataFrame:
- dataframe["%-day_of_week"] = dataframe["date"].dt.dayofweek
- dataframe["%-hour_of_day"] = dataframe["date"].dt.hour
- dataframe.replace([np.inf, -np.inf], 0, inplace=True)
- dataframe.ffill(inplace=True)
- dataframe.fillna(0, inplace=True)
- return dataframe
-
- def set_freqai_targets(self, dataframe: DataFrame, metadata: dict, **kwargs) -> DataFrame:
- logger.info(f"设置 FreqAI 目标,交易对:{metadata['pair']}")
- if "close" not in dataframe.columns:
- logger.error("数据框缺少必要的 'close' 列")
- raise ValueError("数据框缺少必要的 'close' 列")
-
- try:
- label_period = self.freqai_info["feature_parameters"]["label_period_candles"]
-
- # 定义目标变量为未来价格变化百分比(连续值)
- dataframe["up_or_down"] = (
- dataframe["close"].shift(-label_period) - dataframe["close"]
- ) / dataframe["close"]
-
- # 数据清理:处理 NaN 和 Inf 值
- dataframe["up_or_down"] = dataframe["up_or_down"].replace([np.inf, -np.inf], np.nan)
- dataframe["up_or_down"] = dataframe["up_or_down"].ffill().fillna(0)
-
- # 确保目标变量是二维数组
- if dataframe["up_or_down"].ndim == 1:
- dataframe["up_or_down"] = dataframe["up_or_down"].values.reshape(-1, 1)
-
- # 检查并处理 NaN 或无限值
- dataframe["up_or_down"] = dataframe["up_or_down"].replace([np.inf, -np.inf], np.nan)
- dataframe["up_or_down"] = dataframe["up_or_down"].ffill().fillna(0)
-
- # 生成 %-volatility 特征
- dataframe["%-volatility"] = dataframe["close"].pct_change().rolling(20).std()
-
- # 确保 &-buy_rsi 列的值计算正确
- dataframe["&-buy_rsi"] = ta.RSI(dataframe, timeperiod=14)
-
- # 数据清理
- for col in ["&-buy_rsi", "up_or_down", "%-volatility"]:
- # 使用直接操作避免链式赋值
- dataframe[col] = dataframe[col].replace([np.inf, -np.inf], np.nan)
- dataframe[col] = dataframe[col].ffill() # 替代 fillna(method='ffill')
- dataframe[col] = dataframe[col].fillna(dataframe[col].mean()) # 使用均值填充 NaN 值
- if dataframe[col].isna().any():
- logger.warning(f"目标列 {col} 仍包含 NaN填充为默认值")
-
- except Exception as e:
- logger.error(f"创建 FreqAI 目标失败:{str(e)}")
- raise
+ dataframe[col] = dataframe[col].ffill().fillna(0)
- # Log the shape of the target variable for debugging
- logger.info(f"目标列形状:{dataframe['up_or_down'].shape}")
- logger.info(f"目标列预览:\n{dataframe[['up_or_down', '&-buy_rsi']].head().to_string()}")
return dataframe
- def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
- logger.info(f"处理交易对:{metadata['pair']}")
- dataframe = self.freqai.start(dataframe, metadata, self)
-
- # 计算传统指标
- dataframe["rsi"] = ta.RSI(dataframe, timeperiod=14)
- bollinger = qtpylib.bollinger_bands(qtpylib.typical_price(dataframe), window=20, stds=2)
- dataframe["bb_lowerband"] = bollinger["lower"]
- dataframe["bb_middleband"] = bollinger["mid"]
- dataframe["bb_upperband"] = bollinger["upper"]
- dataframe["tema"] = ta.TEMA(dataframe, timeperiod=9)
-
- # 生成 up_or_down 信号(非 FreqAI 目标)
- label_period = self.freqai_info["feature_parameters"]["label_period_candles"]
- # 使用未来价格变化方向生成 up_or_down 信号
- label_period = self.freqai_info["feature_parameters"]["label_period_candles"]
- dataframe["up_or_down"] = np.where(
- dataframe["close"].shift(-label_period) > dataframe["close"], 1, 0
- )
-
- # 动态设置参数
- if "&-buy_rsi" in dataframe.columns:
- # 派生其他目标
- dataframe["&-sell_rsi"] = dataframe["&-buy_rsi"] + 30
- dataframe["%-volatility"] = dataframe["close"].pct_change().rolling(20).std()
- # Ensure proper calculation and handle potential NaN values
- dataframe["&-stoploss"] = (-0.1 - (dataframe["%-volatility"] * 10).clip(0, 0.25)).fillna(-0.1)
- dataframe["&-roi_0"] = ((dataframe["close"] / dataframe["close"].shift(label_period) - 1).clip(0, 0.2)).fillna(0)
+ def set_freqai_targets(self, df: DataFrame, metadata: dict) -> DataFrame:
+ """定义标签"""
+ df["&-up_or_down"] = np.where(df["close"].shift(-20) > df["close"], 1, 0)
+ return df
- # Additional check to ensure no NaN values remain
- for col in ["&-stoploss", "&-roi_0"]:
- if dataframe[col].isna().any():
- logger.warning(f"列 {col} 仍包含 NaN填充为默认值")
- dataframe[col] = dataframe[col].fillna(-0.1 if col == "&-stoploss" else 0)
-
- # 简化动态参数生成逻辑
- # 放松 buy_rsi 和 sell_rsi 的生成逻辑
- # 计算 buy_rsi_pred 并清理 NaN 值
- dataframe["buy_rsi_pred"] = dataframe["rsi"].rolling(window=10).mean().clip(30, 50)
- dataframe["buy_rsi_pred"] = dataframe["buy_rsi_pred"].fillna(dataframe["buy_rsi_pred"].median())
+ def populate_indicators(self, df: DataFrame, metadata: dict) -> DataFrame:
+ # 特征工程调用
+ df = self.feature_engineering_expand_all(df, period=14, metadata=metadata)
+ df = self.feature_engineering_expand_basic(df, metadata=metadata)
+ df = self.set_freqai_targets(df, metadata)
+
+ # 动态参数预测
+ df["buy_rsi_pred"] = df["rsi"].rolling(window=10).median().clip(20, 45)
+ df["sell_rsi_pred"] = df["buy_rsi_pred"] + 20
+ df["stoploss_pred"] = -0.1 - (df["%-pct-change"].abs().rolling(20).std() * 10).clip(0.05, 0.25)
+ df["roi_0_pred"] = self.roi_0.value * 1.2
+ # 添加 do_predict 列示例每5个周期中使用3个进行预测
+ df['do_predict'] = 0
+ df.loc[df.index % 5 <= 2, 'do_predict'] = 1 # 每5根K线中前3根设为1
+
+ df.fillna(0, inplace=True)
+
+ # 更新策略参数
+ self.buy_rsi.value = float(df["buy_rsi_pred"].iloc[-1])
+ self.sell_rsi.value = float(df["sell_rsi_pred"].iloc[-1])
+ self.stoploss = float(df["stoploss_pred"].iloc[-1])
+
+ self.minimal_roi = {
+ 0: float(self.roi_0.value),
+ 15: float(self.roi_15.value),
+ 30: float(self.roi_30.value),
+ 60: 0
+ }
- # 计算 sell_rsi_pred 并清理 NaN 值
- dataframe["sell_rsi_pred"] = dataframe["buy_rsi_pred"] + 20
- dataframe["sell_rsi_pred"] = dataframe["sell_rsi_pred"].fillna(dataframe["sell_rsi_pred"].median())
+ return df
- # 计算 stoploss_pred 并清理 NaN 值
- dataframe["stoploss_pred"] = -0.1 - (dataframe["%-volatility"] * 10).clip(0, 0.25)
- dataframe["stoploss_pred"] = dataframe["stoploss_pred"].fillna(dataframe["stoploss_pred"].mean())
+ def populate_entry_trend(self, df: DataFrame, metadata: dict) -> DataFrame:
+ conditions = [
+ (df["rsi"] < df["buy_rsi_pred"]),
+ (df["volume"] > df["volume_ma"] * 1.2),
+ (df["close"] > df["bb_middleband"]),
+ (df["macd"] > df["macdsignal"]),
+ (df["do_predict"] == 1),
+ ]
- # 计算 roi_0_pred 并清理 NaN 值
- dataframe["roi_0_pred"] = dataframe["&-roi_0"].clip(0.01, 0.2)
- dataframe["roi_0_pred"] = dataframe["roi_0_pred"].fillna(dataframe["roi_0_pred"].mean())
-
- # 检查预测值
- for col in ["buy_rsi_pred", "sell_rsi_pred", "stoploss_pred", "roi_0_pred", "&-sell_rsi", "&-stoploss", "&-roi_0"]:
- if dataframe[col].isna().any():
- logger.warning(f"列 {col} 包含 NaN填充为默认值")
- dataframe[col] = dataframe[col].fillna(dataframe[col].mean())
-
- # 更保守的止损和止盈设置
- dataframe["trailing_stop_positive"] = (dataframe["roi_0_pred"] * 0.3).clip(0.01, 0.2)
- dataframe["trailing_stop_positive_offset"] = (dataframe["roi_0_pred"] * 0.5).clip(0.01, 0.3)
-
- # 设置策略级参数
- self.buy_rsi.value = float(dataframe["buy_rsi_pred"].iloc[-1])
- self.sell_rsi.value = float(dataframe["sell_rsi_pred"].iloc[-1])
-# 更保守的止损设置
- self.stoploss = -0.15 # 固定止损 15%
- self.minimal_roi = {
- 0: float(self.roi_0.value),
- 15: float(self.roi_15.value),
- 30: float(self.roi_30.value),
- 60: 0
- }
-# 更保守的追踪止损设置
- self.trailing_stop_positive = 0.05 # 追踪止损触发点
- self.trailing_stop_positive_offset = 0.1 # 追踪止损偏移量
-
- logger.info(f"动态参数buy_rsi={self.buy_rsi.value}, sell_rsi={self.sell_rsi.value}, "
- f"stoploss={self.stoploss}, trailing_stop_positive={self.trailing_stop_positive}")
-
- dataframe.replace([np.inf, -np.inf], 0, inplace=True)
- dataframe.ffill(inplace=True)
- dataframe.fillna(0, inplace=True)
-
- logger.info(f"up_or_down 值统计:\n{dataframe['up_or_down'].value_counts().to_string()}")
- logger.info(f"do_predict 值统计:\n{dataframe['do_predict'].value_counts().to_string()}")
-
- return dataframe
+ df.loc[reduce(lambda x, y: x & y, conditions), ['enter_long', 'enter_tag']] = (1, 'long_entry')
+ return df
def populate_exit_trend(self, df: DataFrame, metadata: dict) -> DataFrame:
-# 改进卖出信号条件
- exit_long_conditions = [
- (df["rsi"] > df["sell_rsi_pred"]), # RSI 高于卖出阈值
- (df["volume"] > df["volume"].rolling(window=10).mean()), # 成交量高于近期均值
- (df["close"] < df["bb_middleband"]) # 价格低于布林带中轨
+ conditions = [
+ (df["rsi"] > df["sell_rsi_pred"]),
+ (df["close"] < df["bb_middleband"]),
+ (df["do_predict"] == 0),
]
- if exit_long_conditions:
- df.loc[
- reduce(lambda x, y: x & y, exit_long_conditions),
- "exit_long"
- ] = 1
+ df.loc[reduce(lambda x, y: x & y, conditions), 'exit_long'] = 1
return df
- def populate_entry_trend(self, df: DataFrame, metadata: dict) -> DataFrame:
- # 改进买入信号条件
- # 检查 MACD 列是否存在
- if "macd" not in df.columns or "macdsignal" not in df.columns:
- logger.error("MACD 或 MACD 信号列缺失,无法生成买入信号。尝试重新计算 MACD 列。")
-
- try:
- macd = ta.MACD(df, fastperiod=12, slowperiod=26, signalperiod=9)
- df["macd"] = macd["macd"]
- df["macdsignal"] = macd["macdsignal"]
- logger.info("MACD 列已成功重新计算。")
- except Exception as e:
- logger.error(f"重新计算 MACD 列时出错:{str(e)}")
- raise ValueError("DataFrame 缺少必要的 MACD 列且无法重新计算。")
- enter_long_conditions = [
- (df["rsi"] < df["buy_rsi_pred"]), # RSI 低于买入阈值
- (df["volume"] > df["volume"].rolling(window=10).mean() * 1.2), # 成交量高于近期均值20%
- (df["close"] > df["bb_middleband"]) # 价格高于布林带中轨
- ]
-
- # 如果 MACD 列存在,则添加 MACD 金叉条件
- if "macd" in df.columns and "macdsignal" in df.columns:
- enter_long_conditions.append((df["macd"] > df["macdsignal"]))
-
- # 确保模型预测为买入
- enter_long_conditions.append((df["do_predict"] == 1))
- if enter_long_conditions:
- df.loc[
- reduce(lambda x, y: x & y, enter_long_conditions),
- ["enter_long", "enter_tag"]
- ] = (1, "long")
- return df
def confirm_trade_entry(
self, pair: str, order_type: str, amount: float, rate: float,
time_in_force: str, current_time, entry_tag, side: str, **kwargs
) -> bool:
df, _ = self.dp.get_analyzed_dataframe(pair, self.timeframe)
- last_candle = df.iloc[-1].squeeze()
+ last_candle = df.iloc[-1]
if side == "long":
- if rate > (last_candle["close"] * (1 + 0.0025)):
+ if rate > (last_candle["close"] * 1.0025): # 价格超过最新价 0.25% 则拒绝下单
return False
return True

888
filtered_output.log Normal file
View File

@ -0,0 +1,888 @@
[99] validation_0-rmse:0.13480 validation_1-rmse:0.09950
[99] validation_0-rmse:0.14079 validation_1-rmse:0.10036
[99] validation_0-rmse:0.15004 validation_1-rmse:0.09815
[99] validation_0-rmse:0.13402 validation_1-rmse:0.10289
[99] validation_0-rmse:0.14818 validation_1-rmse:0.10475
[99] validation_0-rmse:0.15738 validation_1-rmse:0.10531
[99] validation_0-rmse:0.14246 validation_1-rmse:0.11071
[99] validation_0-rmse:0.16321 validation_1-rmse:0.10649
[99] validation_0-rmse:0.15096 validation_1-rmse:0.10882
[99] validation_0-rmse:0.15694 validation_1-rmse:0.11396
[99] validation_0-rmse:0.18198 validation_1-rmse:0.10994
[99] validation_0-rmse:0.16824 validation_1-rmse:0.11403
[99] validation_0-rmse:0.16437 validation_1-rmse:0.11096
[99] validation_0-rmse:0.17746 validation_1-rmse:0.10819
[99] validation_0-rmse:0.15331 validation_1-rmse:0.11727
[99] validation_0-rmse:0.16802 validation_1-rmse:0.11547
[99] validation_0-rmse:0.15958 validation_1-rmse:0.11029
[99] validation_0-rmse:0.18742 validation_1-rmse:0.11149
[99] validation_0-rmse:0.15075 validation_1-rmse:0.09770
[99] validation_0-rmse:0.13818 validation_1-rmse:0.10038
[99] validation_0-rmse:0.12954 validation_1-rmse:0.09825
[99] validation_0-rmse:0.14837 validation_1-rmse:0.10398
Creating freqtrade_freqtrade_run ...
Creating freqtrade_freqtrade_run ... done
2025-04-29 01:54:55,246 - freqtrade - INFO - freqtrade 2025.3
2025-04-29 01:54:55,464 - numexpr.utils - INFO - NumExpr defaulting to 12 threads.
2025-04-29 01:54:56,878 - freqtrade.configuration.load_config - INFO - Using config: /freqtrade/config_examples/config_freqai.okx.json ...
2025-04-29 01:54:56,879 - freqtrade.configuration.load_config - INFO - Using config: /freqtrade/templates/FreqaiExampleStrategy.json ...
2025-04-29 01:54:56,881 - freqtrade.loggers - INFO - Enabling colorized output.
2025-04-29 01:54:56,881 - root - INFO - Logfile configured
2025-04-29 01:54:56,882 - freqtrade.loggers - INFO - Verbosity set to 0
2025-04-29 01:54:56,882 - freqtrade.configuration.configuration - INFO - Using additional Strategy lookup path: /freqtrade/templates
2025-04-29 01:54:56,883 - freqtrade.configuration.configuration - INFO - Using max_open_trades: 4 ...
2025-04-29 01:54:56,883 - freqtrade.configuration.configuration - INFO - Parameter --timerange detected: 20250101-20250420 ...
2025-04-29 01:54:56,907 - freqtrade.configuration.configuration - INFO - Using user-data directory: /freqtrade/user_data ...
2025-04-29 01:54:56,908 - freqtrade.configuration.configuration - INFO - Using data directory: /freqtrade/user_data/data/okx ...
2025-04-29 01:54:56,908 - freqtrade.configuration.configuration - INFO - Parameter --cache=none detected ...
2025-04-29 01:54:56,908 - freqtrade.configuration.configuration - INFO - Filter trades by timerange: 20250101-20250420
2025-04-29 01:54:56,909 - freqtrade.configuration.configuration - INFO - Using freqaimodel class name: XGBoostRegressor
2025-04-29 01:54:56,910 - freqtrade.exchange.check_exchange - INFO - Checking exchange...
2025-04-29 01:54:56,916 - freqtrade.exchange.check_exchange - INFO - Exchange "okx" is officially supported by the Freqtrade development team.
2025-04-29 01:54:56,916 - freqtrade.configuration.configuration - INFO - Using pairlist from configuration.
2025-04-29 01:54:56,917 - freqtrade.configuration.config_validation - INFO - Validating configuration ...
2025-04-29 01:54:56,919 - freqtrade.commands.optimize_commands - INFO - Starting freqtrade in Backtesting mode
2025-04-29 01:54:56,919 - freqtrade.exchange.exchange - INFO - Instance is running with dry_run enabled
2025-04-29 01:54:56,920 - freqtrade.exchange.exchange - INFO - Using CCXT 4.4.69
2025-04-29 01:54:56,920 - freqtrade.exchange.exchange - INFO - Applying additional ccxt config: {'enableRateLimit': True, 'rateLimit': 500, 'options': {'defaultType': 'spot'}}
2025-04-29 01:54:56,925 - freqtrade.exchange.exchange - INFO - Applying additional ccxt config: {'enableRateLimit': True, 'rateLimit': 500, 'options': {'defaultType': 'spot'}, 'timeout': 20000}
2025-04-29 01:54:56,931 - freqtrade.exchange.exchange - INFO - Using Exchange "OKX"
2025-04-29 01:54:59,471 - freqtrade.resolvers.exchange_resolver - INFO - Using resolved exchange 'Okx'...
2025-04-29 01:54:59,491 - freqtrade.resolvers.iresolver - INFO - Using resolved strategy FreqaiExampleStrategy from '/freqtrade/templates/FreqaiExampleStrategy.py'...
2025-04-29 01:54:59,491 - freqtrade.strategy.hyper - INFO - Loading parameters from file /freqtrade/templates/FreqaiExampleStrategy.json
2025-04-29 01:54:59,492 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'timeframe' with value in config file: 3m.
2025-04-29 01:54:59,492 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'stoploss' with value in config file: -0.05.
2025-04-29 01:54:59,493 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'stake_currency' with value in config file: USDT.
2025-04-29 01:54:59,493 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'stake_amount' with value in config file: 150.
2025-04-29 01:54:59,493 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'startup_candle_count' with value in config file: 30.
2025-04-29 01:54:59,494 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'unfilledtimeout' with value in config file: {'entry': 5, 'exit': 15, 'exit_timeout_count': 0, 'unit':
'minutes'}.
2025-04-29 01:54:59,494 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'max_open_trades' with value in config file: 4.
2025-04-29 01:54:59,494 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using minimal_roi: {'0': 0.132, '8': 0.047, '14': 0.007, '60': 0}
2025-04-29 01:54:59,495 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using timeframe: 3m
2025-04-29 01:54:59,495 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using stoploss: -0.05
2025-04-29 01:54:59,495 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using trailing_stop: True
2025-04-29 01:54:59,495 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using trailing_stop_positive: 0.01
2025-04-29 01:54:59,496 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using trailing_stop_positive_offset: 0.02
2025-04-29 01:54:59,496 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using trailing_only_offset_is_reached: False
2025-04-29 01:54:59,496 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using use_custom_stoploss: False
2025-04-29 01:54:59,497 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using process_only_new_candles: True
2025-04-29 01:54:59,497 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using order_types: {'entry': 'limit', 'exit': 'limit', 'stoploss': 'limit', 'stoploss_on_exchange': False,
'stoploss_on_exchange_interval': 60}
2025-04-29 01:54:59,497 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using order_time_in_force: {'entry': 'GTC', 'exit': 'GTC'}
2025-04-29 01:54:59,498 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using stake_currency: USDT
2025-04-29 01:54:59,498 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using stake_amount: 150
2025-04-29 01:54:59,498 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using startup_candle_count: 30
2025-04-29 01:54:59,499 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using unfilledtimeout: {'entry': 5, 'exit': 15, 'exit_timeout_count': 0, 'unit': 'minutes'}
2025-04-29 01:54:59,499 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using use_exit_signal: True
2025-04-29 01:54:59,499 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using exit_profit_only: False
2025-04-29 01:54:59,500 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using ignore_roi_if_entry_signal: False
2025-04-29 01:54:59,500 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using exit_profit_offset: 0.0
2025-04-29 01:54:59,500 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using disable_dataframe_checks: False
2025-04-29 01:54:59,500 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using ignore_buying_expired_candle_after: 0
2025-04-29 01:54:59,501 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using position_adjustment_enable: False
2025-04-29 01:54:59,501 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using max_entry_position_adjustment: -1
2025-04-29 01:54:59,501 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using max_open_trades: 4
2025-04-29 01:54:59,502 - freqtrade.configuration.config_validation - INFO - Validating configuration ...
2025-04-29 01:54:59,505 - freqtrade.resolvers.iresolver - INFO - Using resolved pairlist StaticPairList from '/freqtrade/freqtrade/plugins/pairlist/StaticPairList.py'...
2025-04-29 01:54:59,512 - freqtrade.optimize.backtesting - INFO - Using fee 0.1500% - worst case fee from exchange (lowest tier).
2025-04-29 01:54:59,512 - freqtrade.data.dataprovider - INFO - Increasing startup_candle_count for freqai on 3m to 14450
2025-04-29 01:54:59,513 - freqtrade.data.history.history_utils - INFO - Using indicator startup period: 14450 ...
2025-04-29 01:54:59,672 - freqtrade.optimize.backtesting - INFO - Loading data from 2024-12-01 21:30:00 up to 2025-04-20 00:00:00 (139 days).
2025-04-29 01:54:59,672 - freqtrade.optimize.backtesting - INFO - Dataload complete. Calculating indicators
2025-04-29 01:54:59,673 - freqtrade.optimize.backtesting - INFO - Running backtesting for Strategy FreqaiExampleStrategy
2025-04-29 01:55:01,274 - matplotlib.font_manager - INFO - generated new fontManager
2025-04-29 01:55:01,489 - freqtrade.resolvers.iresolver - INFO - Using resolved freqaimodel XGBoostRegressor from '/freqtrade/freqtrade/freqai/prediction_models/XGBoostRegressor.py'...
2025-04-29 01:55:01,490 - freqtrade.freqai.data_drawer - INFO - Could not find existing datadrawer, starting from scratch
2025-04-29 01:55:01,491 - freqtrade.freqai.data_drawer - INFO - Could not find existing historic_predictions, starting from scratch
2025-04-29 01:55:01,491 - freqtrade.freqai.freqai_interface - INFO - Set fresh train queue from whitelist. Queue: ['BTC/USDT', 'SOL/USDT']
2025-04-29 01:55:01,492 - freqtrade.strategy.hyper - INFO - Strategy Parameter: buy_rsi = 39.92672300850069
2025-04-29 01:55:01,492 - freqtrade.strategy.hyper - INFO - Strategy Parameter: sell_rsi = 69.92672300850067
2025-04-29 01:55:01,493 - freqtrade.strategy.hyper - INFO - No params for protection found, using default values.
2025-04-29 01:55:01,498 - FreqaiExampleStrategy - INFO - 处理交易对BTC/USDT
2025-04-29 01:55:01,500 - freqtrade.freqai.freqai_interface - INFO - Training 11 timeranges
2025-04-29 01:55:01,501 - freqtrade.freqai.freqai_interface - INFO - Training BTC/USDT, 1/2 pairs from 2024-12-02 00:00:00 to 2025-01-01 00:00:00, 1/11 trains
2025-04-29 01:55:01,502 - freqtrade.freqai.data_kitchen - INFO - Could not find backtesting prediction file at
/freqtrade/user_data/models/test175/backtesting_predictions/cb_btc_1735689600_prediction.feather
2025-04-29 01:55:01,602 - freqtrade.data.dataprovider - INFO - Increasing startup_candle_count for freqai on 5m to 8690
2025-04-29 01:55:01,603 - freqtrade.data.dataprovider - INFO - Loading data for BTC/USDT 5m from 2024-12-01 19:50:00 to 2025-04-20 00:00:00
2025-04-29 01:55:01,705 - freqtrade.data.dataprovider - INFO - Increasing startup_candle_count for freqai on 1h to 770
2025-04-29 01:55:01,706 - freqtrade.data.dataprovider - INFO - Loading data for BTC/USDT 1h from 2024-11-29 22:00:00 to 2025-04-20 00:00:00
2025-04-29 01:55:01,814 - freqtrade.data.dataprovider - INFO - Increasing startup_candle_count for freqai on 3m to 14450
2025-04-29 01:55:01,815 - freqtrade.data.dataprovider - INFO - Loading data for ETH/USDT 3m from 2024-12-01 21:30:00 to 2025-04-20 00:00:00
2025-04-29 01:55:01,942 - freqtrade.data.dataprovider - INFO - Increasing startup_candle_count for freqai on 5m to 8690
2025-04-29 01:55:01,943 - freqtrade.data.dataprovider - INFO - Loading data for ETH/USDT 5m from 2024-12-01 19:50:00 to 2025-04-20 00:00:00
2025-04-29 01:55:02,037 - freqtrade.data.dataprovider - INFO - Increasing startup_candle_count for freqai on 1h to 770
2025-04-29 01:55:02,038 - freqtrade.data.dataprovider - INFO - Loading data for ETH/USDT 1h from 2024-11-29 22:00:00 to 2025-04-20 00:00:00
2025-04-29 01:55:02,113 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对BTC/USDT
2025-04-29 01:55:02,118 - FreqaiExampleStrategy - INFO - 目标列形状:(14450,)
2025-04-29 01:55:02,121 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.003572 50.152831
1 0.003285 50.152831
2 0.001898 50.152831
3 0.000484 50.152831
4 0.001688 50.152831
2025-04-29 01:55:02,123 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对BTC/USDT
2025-04-29 01:55:02,129 - FreqaiExampleStrategy - INFO - 目标列形状:(19250,)
2025-04-29 01:55:02,130 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.003572 50.202701
1 0.003285 50.202701
2 0.001898 50.202701
3 0.000484 50.202701
4 0.001688 50.202701
2025-04-29 01:55:02,134 - freqtrade.freqai.freqai_interface - INFO - Could not find model at /freqtrade/user_data/models/test175/sub-train-BTC_1735689600/cb_btc_1735689600
2025-04-29 01:55:02,135 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Starting training BTC/USDT --------------------
2025-04-29 01:55:02,151 - freqtrade.freqai.data_kitchen - INFO - BTC/USDT: dropped 0 training points due to NaNs in populated dataset 14400.
2025-04-29 01:55:02,152 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Training on data from 2024-12-02 to 2024-12-31 --------------------
2025-04-29 01:55:07,277 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 75 features
2025-04-29 01:55:07,278 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 11520 data points
2025-04-29 01:55:08,221 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Done training BTC/USDT (6.09 secs) --------------------
2025-04-29 01:55:08,222 - freqtrade.freqai.freqai_interface - INFO - Saving metadata to disk.
2025-04-29 01:55:08,903 - freqtrade.freqai.freqai_interface - INFO - Training BTC/USDT, 1/2 pairs from 2024-12-12 00:00:00 to 2025-01-11 00:00:00, 2/11 trains
2025-04-29 01:55:08,904 - freqtrade.freqai.data_kitchen - INFO - Could not find backtesting prediction file at
/freqtrade/user_data/models/test175/backtesting_predictions/cb_btc_1736553600_prediction.feather
2025-04-29 01:55:08,907 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对BTC/USDT
2025-04-29 01:55:08,912 - FreqaiExampleStrategy - INFO - 目标列形状:(19250,)
2025-04-29 01:55:08,914 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.003572 50.202701
1 0.003285 50.202701
2 0.001898 50.202701
3 0.000484 50.202701
4 0.001688 50.202701
2025-04-29 01:55:08,917 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对BTC/USDT
2025-04-29 01:55:08,924 - FreqaiExampleStrategy - INFO - 目标列形状:(24050,)
2025-04-29 01:55:08,925 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.003572 50.367593
1 0.003285 50.367593
2 0.001898 50.367593
3 0.000484 50.367593
4 0.001688 50.367593
2025-04-29 01:55:08,929 - freqtrade.freqai.freqai_interface - INFO - Could not find model at /freqtrade/user_data/models/test175/sub-train-BTC_1736553600/cb_btc_1736553600
2025-04-29 01:55:08,930 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Starting training BTC/USDT --------------------
2025-04-29 01:55:08,946 - freqtrade.freqai.data_kitchen - INFO - BTC/USDT: dropped 0 training points due to NaNs in populated dataset 14400.
2025-04-29 01:55:08,947 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Training on data from 2024-12-12 to 2025-01-10 --------------------
2025-04-29 01:55:13,908 - datasieve.pipeline - INFO - DI tossed 5 predictions for being too far from training data.
2025-04-29 01:55:13,911 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 75 features
2025-04-29 01:55:13,912 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 11520 data points
2025-04-29 01:55:14,692 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Done training BTC/USDT (5.76 secs) --------------------
2025-04-29 01:55:14,693 - freqtrade.freqai.freqai_interface - INFO - Saving metadata to disk.
2025-04-29 01:55:15,250 - freqtrade.freqai.freqai_interface - INFO - Training BTC/USDT, 1/2 pairs from 2024-12-22 00:00:00 to 2025-01-21 00:00:00, 3/11 trains
2025-04-29 01:55:15,250 - freqtrade.freqai.data_kitchen - INFO - Could not find backtesting prediction file at
/freqtrade/user_data/models/test175/backtesting_predictions/cb_btc_1737417600_prediction.feather
2025-04-29 01:55:15,254 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对BTC/USDT
2025-04-29 01:55:15,261 - FreqaiExampleStrategy - INFO - 目标列形状:(24050,)
2025-04-29 01:55:15,262 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.003572 50.367593
1 0.003285 50.367593
2 0.001898 50.367593
3 0.000484 50.367593
4 0.001688 50.367593
2025-04-29 01:55:15,268 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对BTC/USDT
2025-04-29 01:55:15,275 - FreqaiExampleStrategy - INFO - 目标列形状:(28850,)
2025-04-29 01:55:15,276 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.003572 50.305589
1 0.003285 50.305589
2 0.001898 50.305589
3 0.000484 50.305589
4 0.001688 50.305589
2025-04-29 01:55:15,281 - freqtrade.freqai.freqai_interface - INFO - Could not find model at /freqtrade/user_data/models/test175/sub-train-BTC_1737417600/cb_btc_1737417600
2025-04-29 01:55:15,281 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Starting training BTC/USDT --------------------
2025-04-29 01:55:15,297 - freqtrade.freqai.data_kitchen - INFO - BTC/USDT: dropped 0 training points due to NaNs in populated dataset 14400.
2025-04-29 01:55:15,298 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Training on data from 2024-12-22 to 2025-01-20 --------------------
2025-04-29 01:55:20,324 - datasieve.pipeline - INFO - DI tossed 1622 predictions for being too far from training data.
2025-04-29 01:55:20,327 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 75 features
2025-04-29 01:55:20,327 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 11520 data points
2025-04-29 01:55:21,007 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Done training BTC/USDT (5.73 secs) --------------------
2025-04-29 01:55:21,008 - freqtrade.freqai.freqai_interface - INFO - Saving metadata to disk.
2025-04-29 01:55:21,504 - freqtrade.freqai.freqai_interface - INFO - Training BTC/USDT, 1/2 pairs from 2025-01-01 00:00:00 to 2025-01-31 00:00:00, 4/11 trains
2025-04-29 01:55:21,505 - freqtrade.freqai.data_kitchen - INFO - Could not find backtesting prediction file at
/freqtrade/user_data/models/test175/backtesting_predictions/cb_btc_1738281600_prediction.feather
2025-04-29 01:55:21,510 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对BTC/USDT
2025-04-29 01:55:21,516 - FreqaiExampleStrategy - INFO - 目标列形状:(28850,)
2025-04-29 01:55:21,517 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.003572 50.305589
1 0.003285 50.305589
2 0.001898 50.305589
3 0.000484 50.305589
4 0.001688 50.305589
2025-04-29 01:55:21,522 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对BTC/USDT
2025-04-29 01:55:21,528 - FreqaiExampleStrategy - INFO - 目标列形状:(33650,)
2025-04-29 01:55:21,529 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.003572 50.168798
1 0.003285 50.168798
2 0.001898 50.168798
3 0.000484 50.168798
4 0.001688 50.168798
2025-04-29 01:55:21,533 - freqtrade.freqai.freqai_interface - INFO - Could not find model at /freqtrade/user_data/models/test175/sub-train-BTC_1738281600/cb_btc_1738281600
2025-04-29 01:55:21,534 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Starting training BTC/USDT --------------------
2025-04-29 01:55:21,550 - freqtrade.freqai.data_kitchen - INFO - BTC/USDT: dropped 0 training points due to NaNs in populated dataset 14400.
2025-04-29 01:55:21,550 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Training on data from 2025-01-01 to 2025-01-30 --------------------
2025-04-29 01:55:26,605 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 75 features
2025-04-29 01:55:26,606 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 11520 data points
2025-04-29 01:55:27,556 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Done training BTC/USDT (6.02 secs) --------------------
2025-04-29 01:55:27,557 - freqtrade.freqai.freqai_interface - INFO - Saving metadata to disk.
2025-04-29 01:55:28,076 - freqtrade.freqai.freqai_interface - INFO - Training BTC/USDT, 1/2 pairs from 2025-01-11 00:00:00 to 2025-02-10 00:00:00, 5/11 trains
2025-04-29 01:55:28,077 - freqtrade.freqai.data_kitchen - INFO - Could not find backtesting prediction file at
/freqtrade/user_data/models/test175/backtesting_predictions/cb_btc_1739145600_prediction.feather
2025-04-29 01:55:28,081 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对BTC/USDT
2025-04-29 01:55:28,088 - FreqaiExampleStrategy - INFO - 目标列形状:(33650,)
2025-04-29 01:55:28,089 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.003572 50.168798
1 0.003285 50.168798
2 0.001898 50.168798
3 0.000484 50.168798
4 0.001688 50.168798
2025-04-29 01:55:28,094 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对BTC/USDT
2025-04-29 01:55:28,100 - FreqaiExampleStrategy - INFO - 目标列形状:(38450,)
2025-04-29 01:55:28,102 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.003572 50.167897
1 0.003285 50.167897
2 0.001898 50.167897
3 0.000484 50.167897
4 0.001688 50.167897
2025-04-29 01:55:28,106 - freqtrade.freqai.freqai_interface - INFO - Could not find model at /freqtrade/user_data/models/test175/sub-train-BTC_1739145600/cb_btc_1739145600
2025-04-29 01:55:28,107 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Starting training BTC/USDT --------------------
2025-04-29 01:55:28,123 - freqtrade.freqai.data_kitchen - INFO - BTC/USDT: dropped 0 training points due to NaNs in populated dataset 14400.
2025-04-29 01:55:28,124 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Training on data from 2025-01-11 to 2025-02-09 --------------------
2025-04-29 01:55:33,123 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 75 features
2025-04-29 01:55:33,124 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 11520 data points
2025-04-29 01:55:33,929 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Done training BTC/USDT (5.82 secs) --------------------
2025-04-29 01:55:33,930 - freqtrade.freqai.freqai_interface - INFO - Saving metadata to disk.
2025-04-29 01:55:34,433 - freqtrade.freqai.freqai_interface - INFO - Training BTC/USDT, 1/2 pairs from 2025-01-21 00:00:00 to 2025-02-20 00:00:00, 6/11 trains
2025-04-29 01:55:34,434 - freqtrade.freqai.data_kitchen - INFO - Could not find backtesting prediction file at
/freqtrade/user_data/models/test175/backtesting_predictions/cb_btc_1740009600_prediction.feather
2025-04-29 01:55:34,440 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对BTC/USDT
2025-04-29 01:55:34,447 - FreqaiExampleStrategy - INFO - 目标列形状:(38450,)
2025-04-29 01:55:34,448 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.003572 50.167897
1 0.003285 50.167897
2 0.001898 50.167897
3 0.000484 50.167897
4 0.001688 50.167897
2025-04-29 01:55:34,453 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对BTC/USDT
2025-04-29 01:55:34,459 - FreqaiExampleStrategy - INFO - 目标列形状:(43250,)
2025-04-29 01:55:34,461 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.003572 50.107698
1 0.003285 50.107698
2 0.001898 50.107698
3 0.000484 50.107698
4 0.001688 50.107698
2025-04-29 01:55:34,465 - freqtrade.freqai.freqai_interface - INFO - Could not find model at /freqtrade/user_data/models/test175/sub-train-BTC_1740009600/cb_btc_1740009600
2025-04-29 01:55:34,466 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Starting training BTC/USDT --------------------
2025-04-29 01:55:34,482 - freqtrade.freqai.data_kitchen - INFO - BTC/USDT: dropped 0 training points due to NaNs in populated dataset 14400.
2025-04-29 01:55:34,483 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Training on data from 2025-01-21 to 2025-02-19 --------------------
2025-04-29 01:55:39,369 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 75 features
2025-04-29 01:55:39,370 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 11520 data points
2025-04-29 01:55:40,266 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Done training BTC/USDT (5.80 secs) --------------------
2025-04-29 01:55:40,267 - freqtrade.freqai.freqai_interface - INFO - Saving metadata to disk.
2025-04-29 01:55:40,801 - freqtrade.freqai.freqai_interface - INFO - Training BTC/USDT, 1/2 pairs from 2025-01-31 00:00:00 to 2025-03-02 00:00:00, 7/11 trains
2025-04-29 01:55:40,802 - freqtrade.freqai.data_kitchen - INFO - Could not find backtesting prediction file at
/freqtrade/user_data/models/test175/backtesting_predictions/cb_btc_1740873600_prediction.feather
2025-04-29 01:55:40,807 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对BTC/USDT
2025-04-29 01:55:40,814 - FreqaiExampleStrategy - INFO - 目标列形状:(43250,)
2025-04-29 01:55:40,816 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.003572 50.107698
1 0.003285 50.107698
2 0.001898 50.107698
3 0.000484 50.107698
4 0.001688 50.107698
2025-04-29 01:55:40,821 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对BTC/USDT
2025-04-29 01:55:40,827 - FreqaiExampleStrategy - INFO - 目标列形状:(48050,)
2025-04-29 01:55:40,829 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.003572 50.079166
1 0.003285 50.079166
2 0.001898 50.079166
3 0.000484 50.079166
4 0.001688 50.079166
2025-04-29 01:55:40,833 - freqtrade.freqai.freqai_interface - INFO - Could not find model at /freqtrade/user_data/models/test175/sub-train-BTC_1740873600/cb_btc_1740873600
2025-04-29 01:55:40,834 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Starting training BTC/USDT --------------------
2025-04-29 01:55:40,849 - freqtrade.freqai.data_kitchen - INFO - BTC/USDT: dropped 0 training points due to NaNs in populated dataset 14400.
2025-04-29 01:55:40,850 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Training on data from 2025-01-31 to 2025-03-01 --------------------
2025-04-29 01:55:45,643 - datasieve.pipeline - INFO - DI tossed 2275 predictions for being too far from training data.
2025-04-29 01:55:45,646 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 75 features
2025-04-29 01:55:45,647 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 11520 data points
2025-04-29 01:55:46,544 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Done training BTC/USDT (5.71 secs) --------------------
2025-04-29 01:55:46,544 - freqtrade.freqai.freqai_interface - INFO - Saving metadata to disk.
2025-04-29 01:55:47,092 - freqtrade.freqai.freqai_interface - INFO - Training BTC/USDT, 1/2 pairs from 2025-02-10 00:00:00 to 2025-03-12 00:00:00, 8/11 trains
2025-04-29 01:55:47,092 - freqtrade.freqai.data_kitchen - INFO - Could not find backtesting prediction file at
/freqtrade/user_data/models/test175/backtesting_predictions/cb_btc_1741737600_prediction.feather
2025-04-29 01:55:47,100 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对BTC/USDT
2025-04-29 01:55:47,107 - FreqaiExampleStrategy - INFO - 目标列形状:(48050,)
2025-04-29 01:55:47,109 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.003572 50.079166
1 0.003285 50.079166
2 0.001898 50.079166
3 0.000484 50.079166
4 0.001688 50.079166
2025-04-29 01:55:47,115 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对BTC/USDT
2025-04-29 01:55:47,122 - FreqaiExampleStrategy - INFO - 目标列形状:(52850,)
2025-04-29 01:55:47,123 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.003572 50.102027
1 0.003285 50.102027
2 0.001898 50.102027
3 0.000484 50.102027
4 0.001688 50.102027
2025-04-29 01:55:47,128 - freqtrade.freqai.freqai_interface - INFO - Could not find model at /freqtrade/user_data/models/test175/sub-train-BTC_1741737600/cb_btc_1741737600
2025-04-29 01:55:47,129 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Starting training BTC/USDT --------------------
2025-04-29 01:55:47,145 - freqtrade.freqai.data_kitchen - INFO - BTC/USDT: dropped 0 training points due to NaNs in populated dataset 14400.
2025-04-29 01:55:47,145 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Training on data from 2025-02-10 to 2025-03-11 --------------------
2025-04-29 01:55:51,987 - datasieve.pipeline - INFO - DI tossed 18 predictions for being too far from training data.
2025-04-29 01:55:51,989 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 75 features
2025-04-29 01:55:51,989 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 11520 data points
2025-04-29 01:55:52,741 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Done training BTC/USDT (5.61 secs) --------------------
2025-04-29 01:55:52,742 - freqtrade.freqai.freqai_interface - INFO - Saving metadata to disk.
2025-04-29 01:55:53,285 - freqtrade.freqai.freqai_interface - INFO - Training BTC/USDT, 1/2 pairs from 2025-02-20 00:00:00 to 2025-03-22 00:00:00, 9/11 trains
2025-04-29 01:55:53,286 - freqtrade.freqai.data_kitchen - INFO - Could not find backtesting prediction file at
/freqtrade/user_data/models/test175/backtesting_predictions/cb_btc_1742601600_prediction.feather
2025-04-29 01:55:53,291 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对BTC/USDT
2025-04-29 01:55:53,298 - FreqaiExampleStrategy - INFO - 目标列形状:(52850,)
2025-04-29 01:55:53,300 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.003572 50.102027
1 0.003285 50.102027
2 0.001898 50.102027
3 0.000484 50.102027
4 0.001688 50.102027
2025-04-29 01:55:53,309 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对BTC/USDT
2025-04-29 01:55:53,316 - FreqaiExampleStrategy - INFO - 目标列形状:(57650,)
2025-04-29 01:55:53,318 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.003572 50.079967
1 0.003285 50.079967
2 0.001898 50.079967
3 0.000484 50.079967
4 0.001688 50.079967
2025-04-29 01:55:53,322 - freqtrade.freqai.freqai_interface - INFO - Could not find model at /freqtrade/user_data/models/test175/sub-train-BTC_1742601600/cb_btc_1742601600
2025-04-29 01:55:53,323 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Starting training BTC/USDT --------------------
2025-04-29 01:55:53,339 - freqtrade.freqai.data_kitchen - INFO - BTC/USDT: dropped 0 training points due to NaNs in populated dataset 14400.
2025-04-29 01:55:53,340 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Training on data from 2025-02-20 to 2025-03-21 --------------------
2025-04-29 01:55:58,184 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 75 features
2025-04-29 01:55:58,185 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 11520 data points
2025-04-29 01:55:59,097 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Done training BTC/USDT (5.77 secs) --------------------
2025-04-29 01:55:59,098 - freqtrade.freqai.freqai_interface - INFO - Saving metadata to disk.
2025-04-29 01:55:59,706 - freqtrade.freqai.freqai_interface - INFO - Training BTC/USDT, 1/2 pairs from 2025-03-02 00:00:00 to 2025-04-01 00:00:00, 10/11 trains
2025-04-29 01:55:59,706 - freqtrade.freqai.data_kitchen - INFO - Could not find backtesting prediction file at
/freqtrade/user_data/models/test175/backtesting_predictions/cb_btc_1743465600_prediction.feather
2025-04-29 01:55:59,715 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对BTC/USDT
2025-04-29 01:55:59,723 - FreqaiExampleStrategy - INFO - 目标列形状:(57650,)
2025-04-29 01:55:59,725 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.003572 50.079967
1 0.003285 50.079967
2 0.001898 50.079967
3 0.000484 50.079967
4 0.001688 50.079967
2025-04-29 01:55:59,732 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对BTC/USDT
2025-04-29 01:55:59,739 - FreqaiExampleStrategy - INFO - 目标列形状:(62450,)
2025-04-29 01:55:59,741 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.003572 50.024153
1 0.003285 50.024153
2 0.001898 50.024153
3 0.000484 50.024153
4 0.001688 50.024153
2025-04-29 01:55:59,745 - freqtrade.freqai.freqai_interface - INFO - Could not find model at /freqtrade/user_data/models/test175/sub-train-BTC_1743465600/cb_btc_1743465600
2025-04-29 01:55:59,746 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Starting training BTC/USDT --------------------
2025-04-29 01:55:59,762 - freqtrade.freqai.data_kitchen - INFO - BTC/USDT: dropped 0 training points due to NaNs in populated dataset 14400.
2025-04-29 01:55:59,762 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Training on data from 2025-03-02 to 2025-03-31 --------------------
2025-04-29 01:56:04,571 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 75 features
2025-04-29 01:56:04,571 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 11520 data points
2025-04-29 01:56:05,520 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Done training BTC/USDT (5.77 secs) --------------------
2025-04-29 01:56:05,521 - freqtrade.freqai.freqai_interface - INFO - Saving metadata to disk.
2025-04-29 01:56:06,027 - freqtrade.freqai.freqai_interface - INFO - Training BTC/USDT, 1/2 pairs from 2025-03-12 00:00:00 to 2025-04-11 00:00:00, 11/11 trains
2025-04-29 01:56:06,027 - freqtrade.freqai.data_kitchen - INFO - Could not find backtesting prediction file at
/freqtrade/user_data/models/test175/backtesting_predictions/cb_btc_1744329600_prediction.feather
2025-04-29 01:56:06,037 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对BTC/USDT
2025-04-29 01:56:06,045 - FreqaiExampleStrategy - INFO - 目标列形状:(62450,)
2025-04-29 01:56:06,046 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.003572 50.024153
1 0.003285 50.024153
2 0.001898 50.024153
3 0.000484 50.024153
4 0.001688 50.024153
2025-04-29 01:56:06,057 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对BTC/USDT
2025-04-29 01:56:06,064 - FreqaiExampleStrategy - INFO - 目标列形状:(66770,)
2025-04-29 01:56:06,065 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.003572 50.093162
1 0.003285 50.093162
2 0.001898 50.093162
3 0.000484 50.093162
4 0.001688 50.093162
2025-04-29 01:56:06,070 - freqtrade.freqai.freqai_interface - INFO - Could not find model at /freqtrade/user_data/models/test175/sub-train-BTC_1744329600/cb_btc_1744329600
2025-04-29 01:56:06,071 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Starting training BTC/USDT --------------------
2025-04-29 01:56:06,087 - freqtrade.freqai.data_kitchen - INFO - BTC/USDT: dropped 0 training points due to NaNs in populated dataset 14400.
2025-04-29 01:56:06,088 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Training on data from 2025-03-12 to 2025-04-10 --------------------
2025-04-29 01:56:10,904 - datasieve.pipeline - INFO - DI tossed 2001 predictions for being too far from training data.
2025-04-29 01:56:10,907 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 75 features
2025-04-29 01:56:10,907 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 11520 data points
2025-04-29 01:56:11,705 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Done training BTC/USDT (5.63 secs) --------------------
2025-04-29 01:56:11,706 - freqtrade.freqai.freqai_interface - INFO - Saving metadata to disk.
2025-04-29 01:56:12,255 - FreqaiExampleStrategy - INFO - 动态参数buy_rsi=39.26145316407591, sell_rsi=59.26145316407591, stoploss=-0.15, trailing_stop_positive=0.05
2025-04-29 01:56:12,275 - FreqaiExampleStrategy - INFO - up_or_down 值统计:
up_or_down
1 33535
0 33236
2025-04-29 01:56:12,276 - FreqaiExampleStrategy - INFO - do_predict 值统计:
do_predict
0.0 35773
1.0 30998
2025-04-29 01:56:12,279 - FreqaiExampleStrategy - INFO - 处理交易对SOL/USDT
2025-04-29 01:56:12,281 - freqtrade.freqai.freqai_interface - INFO - Training 11 timeranges
2025-04-29 01:56:12,282 - freqtrade.freqai.freqai_interface - INFO - Training SOL/USDT, 2/2 pairs from 2024-12-02 00:00:00 to 2025-01-01 00:00:00, 1/11 trains
2025-04-29 01:56:12,283 - freqtrade.freqai.data_kitchen - INFO - Could not find backtesting prediction file at
/freqtrade/user_data/models/test175/backtesting_predictions/cb_sol_1735689600_prediction.feather
2025-04-29 01:56:12,334 - freqtrade.data.dataprovider - INFO - Increasing startup_candle_count for freqai on 5m to 8690
2025-04-29 01:56:12,335 - freqtrade.data.dataprovider - INFO - Loading data for SOL/USDT 5m from 2024-12-01 19:50:00 to 2025-04-20 00:00:00
2025-04-29 01:56:12,422 - freqtrade.data.dataprovider - INFO - Increasing startup_candle_count for freqai on 1h to 770
2025-04-29 01:56:12,422 - freqtrade.data.dataprovider - INFO - Loading data for SOL/USDT 1h from 2024-11-29 22:00:00 to 2025-04-20 00:00:00
2025-04-29 01:56:12,518 - freqtrade.data.dataprovider - INFO - Increasing startup_candle_count for freqai on 3m to 14450
2025-04-29 01:56:12,519 - freqtrade.data.dataprovider - INFO - Loading data for BTC/USDT 3m from 2024-12-01 21:30:00 to 2025-04-20 00:00:00
2025-04-29 01:56:13,040 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对SOL/USDT
2025-04-29 01:56:13,046 - FreqaiExampleStrategy - INFO - 目标列形状:(14450,)
2025-04-29 01:56:13,047 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.002704 49.58814
1 0.003044 49.58814
2 0.000465 49.58814
3 -0.000380 49.58814
4 0.002829 49.58814
2025-04-29 01:56:13,052 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对SOL/USDT
2025-04-29 01:56:13,057 - FreqaiExampleStrategy - INFO - 目标列形状:(19250,)
2025-04-29 01:56:13,059 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.002704 49.68088
1 0.003044 49.68088
2 0.000465 49.68088
3 -0.000380 49.68088
4 0.002829 49.68088
2025-04-29 01:56:13,066 - freqtrade.freqai.freqai_interface - INFO - Could not find model at /freqtrade/user_data/models/test175/sub-train-SOL_1735689600/cb_sol_1735689600
2025-04-29 01:56:13,066 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Starting training SOL/USDT --------------------
2025-04-29 01:56:13,095 - freqtrade.freqai.data_kitchen - INFO - SOL/USDT: dropped 0 training points due to NaNs in populated dataset 14400.
2025-04-29 01:56:13,096 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Training on data from 2024-12-02 to 2024-12-31 --------------------
2025-04-29 01:56:18,126 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 111 features
2025-04-29 01:56:18,126 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 11520 data points
2025-04-29 01:56:19,586 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Done training SOL/USDT (6.52 secs) --------------------
2025-04-29 01:56:19,587 - freqtrade.freqai.freqai_interface - INFO - Saving metadata to disk.
2025-04-29 01:56:20,174 - freqtrade.freqai.freqai_interface - INFO - Training SOL/USDT, 2/2 pairs from 2024-12-12 00:00:00 to 2025-01-11 00:00:00, 2/11 trains
2025-04-29 01:56:20,175 - freqtrade.freqai.data_kitchen - INFO - Could not find backtesting prediction file at
/freqtrade/user_data/models/test175/backtesting_predictions/cb_sol_1736553600_prediction.feather
2025-04-29 01:56:20,179 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对SOL/USDT
2025-04-29 01:56:20,185 - FreqaiExampleStrategy - INFO - 目标列形状:(19250,)
2025-04-29 01:56:20,186 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.002704 49.68088
1 0.003044 49.68088
2 0.000465 49.68088
3 -0.000380 49.68088
4 0.002829 49.68088
2025-04-29 01:56:20,192 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对SOL/USDT
2025-04-29 01:56:20,197 - FreqaiExampleStrategy - INFO - 目标列形状:(24050,)
2025-04-29 01:56:20,199 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.002704 49.97721
1 0.003044 49.97721
2 0.000465 49.97721
3 -0.000380 49.97721
4 0.002829 49.97721
2025-04-29 01:56:20,204 - freqtrade.freqai.freqai_interface - INFO - Could not find model at /freqtrade/user_data/models/test175/sub-train-SOL_1736553600/cb_sol_1736553600
2025-04-29 01:56:20,205 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Starting training SOL/USDT --------------------
2025-04-29 01:56:20,227 - freqtrade.freqai.data_kitchen - INFO - SOL/USDT: dropped 0 training points due to NaNs in populated dataset 14400.
2025-04-29 01:56:20,228 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Training on data from 2024-12-12 to 2025-01-10 --------------------
2025-04-29 01:56:25,109 - datasieve.pipeline - INFO - DI tossed 5 predictions for being too far from training data.
2025-04-29 01:56:25,112 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 111 features
2025-04-29 01:56:25,112 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 11520 data points
2025-04-29 01:56:26,510 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Done training SOL/USDT (6.30 secs) --------------------
2025-04-29 01:56:26,511 - freqtrade.freqai.freqai_interface - INFO - Saving metadata to disk.
2025-04-29 01:56:27,072 - freqtrade.freqai.freqai_interface - INFO - Training SOL/USDT, 2/2 pairs from 2024-12-22 00:00:00 to 2025-01-21 00:00:00, 3/11 trains
2025-04-29 01:56:27,073 - freqtrade.freqai.data_kitchen - INFO - Could not find backtesting prediction file at
/freqtrade/user_data/models/test175/backtesting_predictions/cb_sol_1737417600_prediction.feather
2025-04-29 01:56:27,079 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对SOL/USDT
2025-04-29 01:56:27,085 - FreqaiExampleStrategy - INFO - 目标列形状:(24050,)
2025-04-29 01:56:27,086 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.002704 49.97721
1 0.003044 49.97721
2 0.000465 49.97721
3 -0.000380 49.97721
4 0.002829 49.97721
2025-04-29 01:56:27,094 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对SOL/USDT
2025-04-29 01:56:27,100 - FreqaiExampleStrategy - INFO - 目标列形状:(28850,)
2025-04-29 01:56:27,102 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.002704 49.941408
1 0.003044 49.941408
2 0.000465 49.941408
3 -0.000380 49.941408
4 0.002829 49.941408
2025-04-29 01:56:27,108 - freqtrade.freqai.freqai_interface - INFO - Could not find model at /freqtrade/user_data/models/test175/sub-train-SOL_1737417600/cb_sol_1737417600
2025-04-29 01:56:27,109 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Starting training SOL/USDT --------------------
2025-04-29 01:56:27,130 - freqtrade.freqai.data_kitchen - INFO - SOL/USDT: dropped 0 training points due to NaNs in populated dataset 14400.
2025-04-29 01:56:27,131 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Training on data from 2024-12-22 to 2025-01-20 --------------------
2025-04-29 01:56:32,206 - datasieve.pipeline - INFO - DI tossed 1523 predictions for being too far from training data.
2025-04-29 01:56:32,209 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 111 features
2025-04-29 01:56:32,210 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 11520 data points
2025-04-29 01:56:33,558 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Done training SOL/USDT (6.45 secs) --------------------
2025-04-29 01:56:33,558 - freqtrade.freqai.freqai_interface - INFO - Saving metadata to disk.
2025-04-29 01:56:34,118 - freqtrade.freqai.freqai_interface - INFO - Training SOL/USDT, 2/2 pairs from 2025-01-01 00:00:00 to 2025-01-31 00:00:00, 4/11 trains
2025-04-29 01:56:34,119 - freqtrade.freqai.data_kitchen - INFO - Could not find backtesting prediction file at
/freqtrade/user_data/models/test175/backtesting_predictions/cb_sol_1738281600_prediction.feather
2025-04-29 01:56:34,124 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对SOL/USDT
2025-04-29 01:56:34,130 - FreqaiExampleStrategy - INFO - 目标列形状:(28850,)
2025-04-29 01:56:34,131 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.002704 49.941408
1 0.003044 49.941408
2 0.000465 49.941408
3 -0.000380 49.941408
4 0.002829 49.941408
2025-04-29 01:56:34,137 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对SOL/USDT
2025-04-29 01:56:34,143 - FreqaiExampleStrategy - INFO - 目标列形状:(33650,)
2025-04-29 01:56:34,144 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.002704 49.830756
1 0.003044 49.830756
2 0.000465 49.830756
3 -0.000380 49.830756
4 0.002829 49.830756
2025-04-29 01:56:34,149 - freqtrade.freqai.freqai_interface - INFO - Could not find model at /freqtrade/user_data/models/test175/sub-train-SOL_1738281600/cb_sol_1738281600
2025-04-29 01:56:34,150 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Starting training SOL/USDT --------------------
2025-04-29 01:56:34,173 - freqtrade.freqai.data_kitchen - INFO - SOL/USDT: dropped 0 training points due to NaNs in populated dataset 14400.
2025-04-29 01:56:34,173 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Training on data from 2025-01-01 to 2025-01-30 --------------------
2025-04-29 01:56:39,271 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 111 features
2025-04-29 01:56:39,271 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 11520 data points
2025-04-29 01:56:40,600 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Done training SOL/USDT (6.45 secs) --------------------
2025-04-29 01:56:40,601 - freqtrade.freqai.freqai_interface - INFO - Saving metadata to disk.
2025-04-29 01:56:41,171 - freqtrade.freqai.freqai_interface - INFO - Training SOL/USDT, 2/2 pairs from 2025-01-11 00:00:00 to 2025-02-10 00:00:00, 5/11 trains
2025-04-29 01:56:41,172 - freqtrade.freqai.data_kitchen - INFO - Could not find backtesting prediction file at
/freqtrade/user_data/models/test175/backtesting_predictions/cb_sol_1739145600_prediction.feather
2025-04-29 01:56:41,177 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对SOL/USDT
2025-04-29 01:56:41,183 - FreqaiExampleStrategy - INFO - 目标列形状:(33650,)
2025-04-29 01:56:41,185 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.002704 49.830756
1 0.003044 49.830756
2 0.000465 49.830756
3 -0.000380 49.830756
4 0.002829 49.830756
2025-04-29 01:56:41,193 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对SOL/USDT
2025-04-29 01:56:41,200 - FreqaiExampleStrategy - INFO - 目标列形状:(38450,)
2025-04-29 01:56:41,201 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.002704 49.714422
1 0.003044 49.714422
2 0.000465 49.714422
3 -0.000380 49.714422
4 0.002829 49.714422
2025-04-29 01:56:41,206 - freqtrade.freqai.freqai_interface - INFO - Could not find model at /freqtrade/user_data/models/test175/sub-train-SOL_1739145600/cb_sol_1739145600
2025-04-29 01:56:41,207 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Starting training SOL/USDT --------------------
2025-04-29 01:56:41,228 - freqtrade.freqai.data_kitchen - INFO - SOL/USDT: dropped 0 training points due to NaNs in populated dataset 14400.
2025-04-29 01:56:41,229 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Training on data from 2025-01-11 to 2025-02-09 --------------------
2025-04-29 01:56:46,277 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 111 features
2025-04-29 01:56:46,278 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 11520 data points
2025-04-29 01:56:47,778 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Done training SOL/USDT (6.57 secs) --------------------
2025-04-29 01:56:47,779 - freqtrade.freqai.freqai_interface - INFO - Saving metadata to disk.
2025-04-29 01:56:48,320 - freqtrade.freqai.freqai_interface - INFO - Training SOL/USDT, 2/2 pairs from 2025-01-21 00:00:00 to 2025-02-20 00:00:00, 6/11 trains
2025-04-29 01:56:48,321 - freqtrade.freqai.data_kitchen - INFO - Could not find backtesting prediction file at
/freqtrade/user_data/models/test175/backtesting_predictions/cb_sol_1740009600_prediction.feather
2025-04-29 01:56:48,327 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对SOL/USDT
2025-04-29 01:56:48,333 - FreqaiExampleStrategy - INFO - 目标列形状:(38450,)
2025-04-29 01:56:48,334 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.002704 49.714422
1 0.003044 49.714422
2 0.000465 49.714422
3 -0.000380 49.714422
4 0.002829 49.714422
2025-04-29 01:56:48,346 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对SOL/USDT
2025-04-29 01:56:48,353 - FreqaiExampleStrategy - INFO - 目标列形状:(43250,)
2025-04-29 01:56:48,354 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.002704 49.626186
1 0.003044 49.626186
2 0.000465 49.626186
3 -0.000380 49.626186
4 0.002829 49.626186
2025-04-29 01:56:48,361 - freqtrade.freqai.freqai_interface - INFO - Could not find model at /freqtrade/user_data/models/test175/sub-train-SOL_1740009600/cb_sol_1740009600
2025-04-29 01:56:48,361 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Starting training SOL/USDT --------------------
2025-04-29 01:56:48,383 - freqtrade.freqai.data_kitchen - INFO - SOL/USDT: dropped 0 training points due to NaNs in populated dataset 14400.
2025-04-29 01:56:48,383 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Training on data from 2025-01-21 to 2025-02-19 --------------------
2025-04-29 01:56:53,532 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 111 features
2025-04-29 01:56:53,533 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 11520 data points
2025-04-29 01:56:54,862 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Done training SOL/USDT (6.50 secs) --------------------
2025-04-29 01:56:54,863 - freqtrade.freqai.freqai_interface - INFO - Saving metadata to disk.
2025-04-29 01:56:55,419 - freqtrade.freqai.freqai_interface - INFO - Training SOL/USDT, 2/2 pairs from 2025-01-31 00:00:00 to 2025-03-02 00:00:00, 7/11 trains
2025-04-29 01:56:55,420 - freqtrade.freqai.data_kitchen - INFO - Could not find backtesting prediction file at
/freqtrade/user_data/models/test175/backtesting_predictions/cb_sol_1740873600_prediction.feather
2025-04-29 01:56:55,426 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对SOL/USDT
2025-04-29 01:56:55,433 - FreqaiExampleStrategy - INFO - 目标列形状:(43250,)
2025-04-29 01:56:55,435 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.002704 49.626186
1 0.003044 49.626186
2 0.000465 49.626186
3 -0.000380 49.626186
4 0.002829 49.626186
2025-04-29 01:56:55,445 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对SOL/USDT
2025-04-29 01:56:55,452 - FreqaiExampleStrategy - INFO - 目标列形状:(48050,)
2025-04-29 01:56:55,453 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.002704 49.568812
1 0.003044 49.568812
2 0.000465 49.568812
3 -0.000380 49.568812
4 0.002829 49.568812
2025-04-29 01:56:55,459 - freqtrade.freqai.freqai_interface - INFO - Could not find model at /freqtrade/user_data/models/test175/sub-train-SOL_1740873600/cb_sol_1740873600
2025-04-29 01:56:55,459 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Starting training SOL/USDT --------------------
2025-04-29 01:56:55,481 - freqtrade.freqai.data_kitchen - INFO - SOL/USDT: dropped 0 training points due to NaNs in populated dataset 14400.
2025-04-29 01:56:55,482 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Training on data from 2025-01-31 to 2025-03-01 --------------------
2025-04-29 01:57:00,566 - datasieve.pipeline - INFO - DI tossed 2417 predictions for being too far from training data.
2025-04-29 01:57:00,569 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 111 features
2025-04-29 01:57:00,570 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 11520 data points
2025-04-29 01:57:02,441 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Done training SOL/USDT (6.98 secs) --------------------
2025-04-29 01:57:02,442 - freqtrade.freqai.freqai_interface - INFO - Saving metadata to disk.
2025-04-29 01:57:02,968 - freqtrade.freqai.freqai_interface - INFO - Training SOL/USDT, 2/2 pairs from 2025-02-10 00:00:00 to 2025-03-12 00:00:00, 8/11 trains
2025-04-29 01:57:02,968 - freqtrade.freqai.data_kitchen - INFO - Could not find backtesting prediction file at
/freqtrade/user_data/models/test175/backtesting_predictions/cb_sol_1741737600_prediction.feather
2025-04-29 01:57:02,980 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对SOL/USDT
2025-04-29 01:57:02,987 - FreqaiExampleStrategy - INFO - 目标列形状:(48050,)
2025-04-29 01:57:02,989 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.002704 49.568812
1 0.003044 49.568812
2 0.000465 49.568812
3 -0.000380 49.568812
4 0.002829 49.568812
2025-04-29 01:57:03,001 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对SOL/USDT
2025-04-29 01:57:03,007 - FreqaiExampleStrategy - INFO - 目标列形状:(52850,)
2025-04-29 01:57:03,009 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.002704 49.623338
1 0.003044 49.623338
2 0.000465 49.623338
3 -0.000380 49.623338
4 0.002829 49.623338
2025-04-29 01:57:03,014 - freqtrade.freqai.freqai_interface - INFO - Could not find model at /freqtrade/user_data/models/test175/sub-train-SOL_1741737600/cb_sol_1741737600
2025-04-29 01:57:03,015 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Starting training SOL/USDT --------------------
2025-04-29 01:57:03,042 - freqtrade.freqai.data_kitchen - INFO - SOL/USDT: dropped 0 training points due to NaNs in populated dataset 14400.
2025-04-29 01:57:03,042 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Training on data from 2025-02-10 to 2025-03-11 --------------------
2025-04-29 01:57:08,138 - datasieve.pipeline - INFO - DI tossed 3 predictions for being too far from training data.
2025-04-29 01:57:08,141 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 111 features
2025-04-29 01:57:08,141 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 11520 data points
2025-04-29 01:57:09,614 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Done training SOL/USDT (6.60 secs) --------------------
2025-04-29 01:57:09,615 - freqtrade.freqai.freqai_interface - INFO - Saving metadata to disk.
2025-04-29 01:57:10,150 - freqtrade.freqai.freqai_interface - INFO - Training SOL/USDT, 2/2 pairs from 2025-02-20 00:00:00 to 2025-03-22 00:00:00, 9/11 trains
2025-04-29 01:57:10,151 - freqtrade.freqai.data_kitchen - INFO - Could not find backtesting prediction file at
/freqtrade/user_data/models/test175/backtesting_predictions/cb_sol_1742601600_prediction.feather
2025-04-29 01:57:10,159 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对SOL/USDT
2025-04-29 01:57:10,167 - FreqaiExampleStrategy - INFO - 目标列形状:(52850,)
2025-04-29 01:57:10,168 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.002704 49.623338
1 0.003044 49.623338
2 0.000465 49.623338
3 -0.000380 49.623338
4 0.002829 49.623338
2025-04-29 01:57:10,181 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对SOL/USDT
2025-04-29 01:57:10,188 - FreqaiExampleStrategy - INFO - 目标列形状:(57650,)
2025-04-29 01:57:10,190 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.002704 49.644115
1 0.003044 49.644115
2 0.000465 49.644115
3 -0.000380 49.644115
4 0.002829 49.644115
2025-04-29 01:57:10,195 - freqtrade.freqai.freqai_interface - INFO - Could not find model at /freqtrade/user_data/models/test175/sub-train-SOL_1742601600/cb_sol_1742601600
2025-04-29 01:57:10,196 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Starting training SOL/USDT --------------------
2025-04-29 01:57:10,218 - freqtrade.freqai.data_kitchen - INFO - SOL/USDT: dropped 0 training points due to NaNs in populated dataset 14400.
2025-04-29 01:57:10,218 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Training on data from 2025-02-20 to 2025-03-21 --------------------
2025-04-29 01:57:15,185 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 111 features
2025-04-29 01:57:15,186 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 11520 data points
2025-04-29 01:57:16,538 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Done training SOL/USDT (6.34 secs) --------------------
2025-04-29 01:57:16,539 - freqtrade.freqai.freqai_interface - INFO - Saving metadata to disk.
2025-04-29 01:57:17,068 - freqtrade.freqai.freqai_interface - INFO - Training SOL/USDT, 2/2 pairs from 2025-03-02 00:00:00 to 2025-04-01 00:00:00, 10/11 trains
2025-04-29 01:57:17,069 - freqtrade.freqai.data_kitchen - INFO - Could not find backtesting prediction file at
/freqtrade/user_data/models/test175/backtesting_predictions/cb_sol_1743465600_prediction.feather
2025-04-29 01:57:17,084 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对SOL/USDT
2025-04-29 01:57:17,092 - FreqaiExampleStrategy - INFO - 目标列形状:(57650,)
2025-04-29 01:57:17,094 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.002704 49.644115
1 0.003044 49.644115
2 0.000465 49.644115
3 -0.000380 49.644115
4 0.002829 49.644115
2025-04-29 01:57:17,108 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对SOL/USDT
2025-04-29 01:57:17,115 - FreqaiExampleStrategy - INFO - 目标列形状:(62450,)
2025-04-29 01:57:17,117 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.002704 49.601082
1 0.003044 49.601082
2 0.000465 49.601082
3 -0.000380 49.601082
4 0.002829 49.601082
2025-04-29 01:57:17,124 - freqtrade.freqai.freqai_interface - INFO - Could not find model at /freqtrade/user_data/models/test175/sub-train-SOL_1743465600/cb_sol_1743465600
2025-04-29 01:57:17,125 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Starting training SOL/USDT --------------------
2025-04-29 01:57:17,151 - freqtrade.freqai.data_kitchen - INFO - SOL/USDT: dropped 0 training points due to NaNs in populated dataset 14400.
2025-04-29 01:57:17,151 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Training on data from 2025-03-02 to 2025-03-31 --------------------
2025-04-29 01:57:22,430 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 111 features
2025-04-29 01:57:22,430 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 11520 data points
2025-04-29 01:57:23,725 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Done training SOL/USDT (6.60 secs) --------------------
2025-04-29 01:57:23,726 - freqtrade.freqai.freqai_interface - INFO - Saving metadata to disk.
2025-04-29 01:57:24,305 - freqtrade.freqai.freqai_interface - INFO - Training SOL/USDT, 2/2 pairs from 2025-03-12 00:00:00 to 2025-04-11 00:00:00, 11/11 trains
2025-04-29 01:57:24,305 - freqtrade.freqai.data_kitchen - INFO - Could not find backtesting prediction file at
/freqtrade/user_data/models/test175/backtesting_predictions/cb_sol_1744329600_prediction.feather
2025-04-29 01:57:24,318 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对SOL/USDT
2025-04-29 01:57:24,325 - FreqaiExampleStrategy - INFO - 目标列形状:(62450,)
2025-04-29 01:57:24,327 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.002704 49.601082
1 0.003044 49.601082
2 0.000465 49.601082
3 -0.000380 49.601082
4 0.002829 49.601082
2025-04-29 01:57:24,337 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对SOL/USDT
2025-04-29 01:57:24,345 - FreqaiExampleStrategy - INFO - 目标列形状:(66770,)
2025-04-29 01:57:24,346 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.002704 49.729824
1 0.003044 49.729824
2 0.000465 49.729824
3 -0.000380 49.729824
4 0.002829 49.729824
2025-04-29 01:57:24,352 - freqtrade.freqai.freqai_interface - INFO - Could not find model at /freqtrade/user_data/models/test175/sub-train-SOL_1744329600/cb_sol_1744329600
2025-04-29 01:57:24,353 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Starting training SOL/USDT --------------------
2025-04-29 01:57:24,376 - freqtrade.freqai.data_kitchen - INFO - SOL/USDT: dropped 0 training points due to NaNs in populated dataset 14400.
2025-04-29 01:57:24,376 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Training on data from 2025-03-12 to 2025-04-10 --------------------
2025-04-29 01:57:29,392 - datasieve.pipeline - INFO - DI tossed 1948 predictions for being too far from training data.
2025-04-29 01:57:29,396 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 111 features
2025-04-29 01:57:29,396 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 11520 data points
2025-04-29 01:57:30,474 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Done training SOL/USDT (6.12 secs) --------------------
2025-04-29 01:57:30,475 - freqtrade.freqai.freqai_interface - INFO - Saving metadata to disk.
2025-04-29 01:57:31,077 - FreqaiExampleStrategy - INFO - 动态参数buy_rsi=50.0, sell_rsi=70.0, stoploss=-0.15, trailing_stop_positive=0.05
2025-04-29 01:57:31,096 - FreqaiExampleStrategy - INFO - up_or_down 值统计:
up_or_down
0 33825
1 32946
2025-04-29 01:57:31,097 - FreqaiExampleStrategy - INFO - do_predict 值统计:
do_predict
0.0 36730
1.0 30041
2025-04-29 01:57:31,105 - freqtrade.optimize.backtesting - INFO - Backtesting with data from 2025-01-01 00:00:00 up to 2025-04-20 00:00:00 (109 days).
2025-04-29 01:57:31,109 - FreqaiExampleStrategy - ERROR - MACD 或 MACD 信号列缺失,无法生成买入信号。尝试重新计算 MACD 列。
2025-04-29 01:57:31,111 - FreqaiExampleStrategy - INFO - MACD 列已成功重新计算。
2025-04-29 01:57:31,193 - FreqaiExampleStrategy - ERROR - MACD 或 MACD 信号列缺失,无法生成买入信号。尝试重新计算 MACD 列。
2025-04-29 01:57:31,195 - FreqaiExampleStrategy - INFO - MACD 列已成功重新计算。
2025-04-29 01:57:33,776 - freqtrade.misc - INFO - dumping json to "/freqtrade/user_data/backtest_results/backtest-result-2025-04-29_01-57-33.meta.json"
Result for strategy FreqaiExampleStrategy
BACKTESTING REPORT
┏━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Pair ┃ Trades ┃ Avg Profit % ┃ Tot Profit USDT ┃ Tot Profit % ┃ Avg Duration ┃ Win Draw Loss Win% ┃
┡━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━┩
│ BTC/USDT │ 38 │ -0.39 │ -22.029 │ -2.2 │ 22:13:00 │ 5 32 1 13.2 │
│ SOL/USDT │ 44 │ -1.94 │ -128.236 │ -12.82 │ 16:35:00 │ 12 26 6 27.3 │
│ TOTAL │ 82 │ -1.22 │ -150.265 │ -15.03 │ 19:12:00 │ 17 58 7 20.7 │
└──────────┴────────┴──────────────┴─────────────────┴──────────────┴──────────────┴────────────────────────┘
LEFT OPEN TRADES REPORT
┏━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Pair ┃ Trades ┃ Avg Profit % ┃ Tot Profit USDT ┃ Tot Profit % ┃ Avg Duration ┃ Win Draw Loss Win% ┃
┡━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━┩
│ TOTAL │ 0 │ 0.0 │ 0.000 │ 0.0 │ 0:00 │ 0 0 0 0 │
└───────┴────────┴──────────────┴─────────────────┴──────────────┴──────────────┴────────────────────────┘
ENTER TAG STATS
┏━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Enter Tag ┃ Entries ┃ Avg Profit % ┃ Tot Profit USDT ┃ Tot Profit % ┃ Avg Duration ┃ Win Draw Loss Win% ┃
┡━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━┩
│ long │ 82 │ -1.22 │ -150.265 │ -15.03 │ 19:12:00 │ 17 58 7 20.7 │
│ TOTAL │ 82 │ -1.22 │ -150.265 │ -15.03 │ 19:12:00 │ 17 58 7 20.7 │
└───────────┴─────────┴──────────────┴─────────────────┴──────────────┴──────────────┴────────────────────────┘
EXIT REASON STATS
┏━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Exit Reason ┃ Exits ┃ Avg Profit % ┃ Tot Profit USDT ┃ Tot Profit % ┃ Avg Duration ┃ Win Draw Loss Win% ┃
┡━━━━━━━━━━━━━━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━┩
│ roi │ 75 │ 0.07 │ 7.926 │ 0.79 │ 14:48:00 │ 17 58 0 100 │
│ trailing_stop_loss │ 7 │ -15.04 │ -158.191 │ -15.82 │ 2 days, 18:13:00 │ 0 0 7 0 │
│ TOTAL │ 82 │ -1.22 │ -150.265 │ -15.03 │ 19:12:00 │ 17 58 7 20.7 │
└────────────────────┴───────┴──────────────┴─────────────────┴──────────────┴──────────────────┴────────────────────────┘
MIXED TAG STATS
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Enter Tag ┃ Exit Reason ┃ Trades ┃ Avg Profit % ┃ Tot Profit USDT ┃ Tot Profit % ┃ Avg Duration ┃ Win Draw Loss Win% ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━┩
│ ('long', 'roi') │ │ 75 │ 0.07 │ 7.926 │ 0.79 │ 14:48:00 │ 17 58 0 100 │
│ ('long', 'trailing_stop_loss') │ │ 7 │ -15.04 │ -158.191 │ -15.82 │ 2 days, 18:13:00 │ 0 0 7 0 │
│ TOTAL │ │ 82 │ -1.22 │ -150.265 │ -15.03 │ 19:12:00 │ 17 58 7 20.7 │
└────────────────────────────────┴─────────────┴────────┴──────────────┴─────────────────┴──────────────┴──────────────────┴────────────────────────┘
SUMMARY METRICS
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃ Metric ┃ Value ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ Backtesting from │ 2025-01-01 00:00:00 │
│ Backtesting to │ 2025-04-20 00:00:00 │
│ Trading Mode │ Spot │
│ Max open trades │ 2 │
│ │ │
│ Total/Daily Avg Trades │ 82 / 0.75 │
│ Starting balance │ 1000 USDT │
│ Final balance │ 849.735 USDT │
│ Absolute profit │ -150.265 USDT │
│ Total profit % │ -15.03% │
│ CAGR % │ -42.03% │
│ Sortino │ -252.56 │
│ Sharpe │ -4.15 │
│ Calmar │ -17.48 │
│ SQN │ -2.60 │
│ Profit factor │ 0.05 │
│ Expectancy (Ratio) │ -1.83 (-0.79) │
│ Avg. daily profit % │ -0.14% │
│ Avg. stake amount │ 150 USDT │
│ Total trade volume │ 24523.15 USDT │
│ │ │
│ Best Pair │ BTC/USDT -2.20% │
│ Worst Pair │ SOL/USDT -12.82% │
│ Best trade │ SOL/USDT 0.90% │
│ Worst trade │ SOL/USDT -15.19% │
│ Best day │ 1.76 USDT │
│ Worst day │ -22.827 USDT │
│ Days win/draw/lose │ 14 / 80 / 7 │
│ Avg. Duration Winners │ 0:55:00 │
│ Avg. Duration Loser │ 2 days, 18:13:00 │
│ Max Consecutive Wins / Loss │ 2 / 16 │
│ Rejected Entry signals │ 0 │
│ Entry/Exit Timeouts │ 0 / 0 │
│ │ │
│ Min balance │ 849.735 USDT │
│ Max balance │ 1000.508 USDT │
│ Max % of account underwater │ 15.07% │
│ Absolute Drawdown (Account) │ 15.07% │
│ Absolute Drawdown │ 150.773 USDT │
│ Drawdown high │ 0.508 USDT │
│ Drawdown low │ -150.265 USDT │
│ Drawdown Start │ 2025-01-06 19:48:00 │
│ Drawdown End │ 2025-04-06 23:15:00 │
│ Market change │ -26.79% │
└─────────────────────────────┴─────────────────────┘
Backtested 2025-01-01 00:00:00 -> 2025-04-20 00:00:00 | Max open trades : 2
STRATEGY SUMMARY
┏━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━┓
┃ Strategy ┃ Trades ┃ Avg Profit % ┃ Tot Profit USDT ┃ Tot Profit % ┃ Avg Duration ┃ Win Draw Loss Win% ┃ Drawdown ┃
┡━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━┩
│ FreqaiExampleStrategy │ 82 │ -1.22 │ -150.265 │ -15.03 │ 19:12:00 │ 17 58 7 20.7 │ 150.773 USDT 15.07% │
└───────────────────────┴────────┴──────────────┴─────────────────┴──────────────┴──────────────┴────────────────────────┴──────────────────────┘

3066
freqtrade.log Normal file

File diff suppressed because it is too large Load Diff

336
freqtrade/abc.py Normal file
View File

@ -0,0 +1,336 @@
import logging
import numpy as np
from functools import reduce
import talib.abstract as ta
from pandas import DataFrame
from technical import qtpylib
from freqtrade.strategy import IStrategy, IntParameter, DecimalParameter
logger = logging.getLogger(__name__)
class FreqaiExampleStrategy(IStrategy):
# 移除硬编码的 minimal_roi 和 stoploss改为动态适配
minimal_roi = {} # 将在 populate_indicators 中动态生成
stoploss = 0.0 # 将在 populate_indicators 中动态设置
trailing_stop = True
process_only_new_candles = True
use_exit_signal = True
startup_candle_count: int = 40
can_short = False
# 参数定义FreqAI 动态适配 buy_rsi 和 sell_rsi禁用 Hyperopt 优化
buy_rsi = IntParameter(low=10, high=50, default=27, space="buy", optimize=False, load=True)
sell_rsi = IntParameter(low=50, high=90, default=59, space="sell", optimize=False, load=True)
# 为 Hyperopt 优化添加 ROI 和 stoploss 参数
roi_0 = DecimalParameter(low=0.01, high=0.2, default=0.038, space="roi", optimize=True, load=True)
roi_15 = DecimalParameter(low=0.005, high=0.1, default=0.027, space="roi", optimize=True, load=True)
roi_30 = DecimalParameter(low=0.001, high=0.05, default=0.009, space="roi", optimize=True, load=True)
stoploss_param = DecimalParameter(low=-0.35, high=-0.1, default=-0.182, space="stoploss", optimize=True, load=True)
# FreqAI 配置
freqai_info = {
"model": "CatboostClassifier", # 与config保持一致
"feature_parameters": {
"include_timeframes": ["3m", "15m", "1h"], # 与config一致
"include_corr_pairlist": ["BTC/USDT", "SOL/USDT"], # 添加相关交易对
"label_period_candles": 20, # 与config一致
"include_shifted_candles": 2, # 与config一致
},
"data_split_parameters": {
"test_size": 0.2,
"shuffle": True, # 启用shuffle
},
"model_training_parameters": {
"n_estimators": 100, # 减少树的数量
"learning_rate": 0.1, # 提高学习率
"max_depth": 6, # 限制树深度
"subsample": 0.8, # 添加子采样
"colsample_bytree": 0.8, # 添加特征采样
"objective": "reg:squarederror",
"eval_metric": "rmse",
"early_stopping_rounds": 20,
"verbose": 0,
},
"data_kitchen": {
"feature_parameters": {
"DI_threshold": 1.5, # 降低异常值过滤阈值
"use_DBSCAN_to_remove_outliers": False # 禁用DBSCAN
}
}
}
plot_config = {
"main_plot": {},
"subplots": {
"&-buy_rsi": {"&-buy_rsi": {"color": "green"}},
"&-sell_rsi": {"&-sell_rsi": {"color": "red"}},
"&-stoploss": {"&-stoploss": {"color": "purple"}},
"&-roi_0": {"&-roi_0": {"color": "orange"}},
"do_predict": {"do_predict": {"color": "brown"}},
},
}
def feature_engineering_expand_all(self, dataframe: DataFrame, period: int, metadata: dict, **kwargs) -> DataFrame:
# 保留关键的技术指标
dataframe["rsi"] = ta.RSI(dataframe, timeperiod=14)
# 确保 MACD 列被正确计算并保留
try:
macd = ta.MACD(dataframe, fastperiod=12, slowperiod=26, signalperiod=9)
dataframe["macd"] = macd["macd"]
dataframe["macdsignal"] = macd["macdsignal"]
except Exception as e:
logger.error(f"计算 MACD 列时出错:{str(e)}")
dataframe["macd"] = np.nan
dataframe["macdsignal"] = np.nan
# 检查 MACD 列是否存在
if "macd" not in dataframe.columns or "macdsignal" not in dataframe.columns:
logger.error("MACD 或 MACD 信号列缺失,无法生成买入信号")
raise ValueError("DataFrame 缺少必要的 MACD 列")
# 确保 MACD 列存在
if "macd" not in dataframe.columns or "macdsignal" not in dataframe.columns:
logger.error("MACD 或 MACD 信号列缺失,无法生成买入信号")
raise ValueError("DataFrame 缺少必要的 MACD 列")
# 保留布林带相关特征
bollinger = qtpylib.bollinger_bands(qtpylib.typical_price(dataframe), window=20, stds=2)
dataframe["bb_lowerband"] = bollinger["lower"]
dataframe["bb_middleband"] = bollinger["mid"]
dataframe["bb_upperband"] = bollinger["upper"]
# 保留成交量相关特征
dataframe["volume_ma"] = dataframe["volume"].rolling(window=20).mean()
# 数据清理
for col in dataframe.columns:
if dataframe[col].dtype in ["float64", "int64"]:
dataframe[col] = dataframe[col].replace([np.inf, -np.inf], np.nan)
dataframe[col] = dataframe[col].ffill().fillna(0)
logger.info(f"特征工程完成,特征数量:{len(dataframe.columns)}")
return dataframe
def feature_engineering_expand_basic(self, dataframe: DataFrame, metadata: dict, **kwargs) -> DataFrame:
dataframe["%-pct-change"] = dataframe["close"].pct_change()
dataframe["%-raw_volume"] = dataframe["volume"]
dataframe["%-raw_price"] = dataframe["close"]
# 数据清理逻辑
for col in dataframe.columns:
if dataframe[col].dtype in ["float64", "int64"]:
dataframe[col] = dataframe[col].replace([np.inf, -np.inf], 0)
dataframe[col] = dataframe[col].ffill()
dataframe[col] = dataframe[col].fillna(0)
# 检查是否仍有无效值
if dataframe[col].isna().any() or np.isinf(dataframe[col]).any():
logger.warning(f"{col} 仍包含无效值,已填充为默认值")
dataframe[col] = dataframe[col].fillna(0)
return dataframe
def feature_engineering_standard(self, dataframe: DataFrame, metadata: dict, **kwargs) -> DataFrame:
dataframe["%-day_of_week"] = dataframe["date"].dt.dayofweek
dataframe["%-hour_of_day"] = dataframe["date"].dt.hour
dataframe.replace([np.inf, -np.inf], 0, inplace=True)
dataframe.ffill(inplace=True)
dataframe.fillna(0, inplace=True)
return dataframe
def set_freqai_targets(self, dataframe: DataFrame, metadata: dict, **kwargs) -> DataFrame:
logger.info(f"设置 FreqAI 目标,交易对:{metadata['pair']}")
if "close" not in dataframe.columns:
logger.error("数据框缺少必要的 'close'")
raise ValueError("数据框缺少必要的 'close'")
try:
label_period = self.freqai_info["feature_parameters"]["label_period_candles"]
# 定义目标变量为未来价格变化百分比(连续值)
dataframe["up_or_down"] = (
dataframe["close"].shift(-label_period) - dataframe["close"]
) / dataframe["close"]
# 数据清理:处理 NaN 和 Inf 值
dataframe["up_or_down"] = dataframe["up_or_down"].replace([np.inf, -np.inf], np.nan)
dataframe["up_or_down"] = dataframe["up_or_down"].ffill().fillna(0)
# 确保目标变量是二维数组
if dataframe["up_or_down"].ndim == 1:
dataframe["up_or_down"] = dataframe["up_or_down"].values.reshape(-1, 1)
# 检查并处理 NaN 或无限值
dataframe["up_or_down"] = dataframe["up_or_down"].replace([np.inf, -np.inf], np.nan)
dataframe["up_or_down"] = dataframe["up_or_down"].ffill().fillna(0)
# 生成 %-volatility 特征
dataframe["%-volatility"] = dataframe["close"].pct_change().rolling(20).std()
# 确保 &-buy_rsi 列的值计算正确
dataframe["&-buy_rsi"] = ta.RSI(dataframe, timeperiod=14)
# 数据清理
for col in ["&-buy_rsi", "up_or_down", "%-volatility"]:
# 使用直接操作避免链式赋值
dataframe[col] = dataframe[col].replace([np.inf, -np.inf], np.nan)
dataframe[col] = dataframe[col].ffill() # 替代 fillna(method='ffill')
dataframe[col] = dataframe[col].fillna(dataframe[col].mean()) # 使用均值填充 NaN 值
if dataframe[col].isna().any():
logger.warning(f"目标列 {col} 仍包含 NaN填充为默认值")
except Exception as e:
logger.error(f"创建 FreqAI 目标失败:{str(e)}")
raise
# Log the shape of the target variable for debugging
logger.info(f"目标列形状:{dataframe['up_or_down'].shape}")
logger.info(f"目标列预览:\n{dataframe[['up_or_down', '&-buy_rsi']].head().to_string()}")
return dataframe
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
logger.info(f"处理交易对:{metadata['pair']}")
dataframe = self.freqai.start(dataframe, metadata, self)
# 计算传统指标
dataframe["rsi"] = ta.RSI(dataframe, timeperiod=14)
bollinger = qtpylib.bollinger_bands(qtpylib.typical_price(dataframe), window=20, stds=2)
dataframe["bb_lowerband"] = bollinger["lower"]
dataframe["bb_middleband"] = bollinger["mid"]
dataframe["bb_upperband"] = bollinger["upper"]
dataframe["tema"] = ta.TEMA(dataframe, timeperiod=9)
# 生成 up_or_down 信号(非 FreqAI 目标)
label_period = self.freqai_info["feature_parameters"]["label_period_candles"]
# 使用未来价格变化方向生成 up_or_down 信号
label_period = self.freqai_info["feature_parameters"]["label_period_candles"]
dataframe["up_or_down"] = np.where(
dataframe["close"].shift(-label_period) > dataframe["close"], 1, 0
)
# 动态设置参数
if "&-buy_rsi" in dataframe.columns:
# 派生其他目标
dataframe["&-sell_rsi"] = dataframe["&-buy_rsi"] + 30
dataframe["%-volatility"] = dataframe["close"].pct_change().rolling(20).std()
# Ensure proper calculation and handle potential NaN values
dataframe["&-stoploss"] = (-0.1 - (dataframe["%-volatility"] * 10).clip(0, 0.25)).fillna(-0.1)
dataframe["&-roi_0"] = ((dataframe["close"] / dataframe["close"].shift(label_period) - 1).clip(0, 0.2)).fillna(0)
# Additional check to ensure no NaN values remain
for col in ["&-stoploss", "&-roi_0"]:
if dataframe[col].isna().any():
logger.warning(f"{col} 仍包含 NaN填充为默认值")
dataframe[col] = dataframe[col].fillna(-0.1 if col == "&-stoploss" else 0)
# 简化动态参数生成逻辑
# 放松 buy_rsi 和 sell_rsi 的生成逻辑
# 计算 buy_rsi_pred 并清理 NaN 值
dataframe["buy_rsi_pred"] = dataframe["rsi"].rolling(window=10).mean().clip(30, 50)
dataframe["buy_rsi_pred"] = dataframe["buy_rsi_pred"].fillna(dataframe["buy_rsi_pred"].median())
# 计算 sell_rsi_pred 并清理 NaN 值
dataframe["sell_rsi_pred"] = dataframe["buy_rsi_pred"] + 20
dataframe["sell_rsi_pred"] = dataframe["sell_rsi_pred"].fillna(dataframe["sell_rsi_pred"].median())
# 计算 stoploss_pred 并清理 NaN 值
dataframe["stoploss_pred"] = -0.1 - (dataframe["%-volatility"] * 10).clip(0, 0.25)
dataframe["stoploss_pred"] = dataframe["stoploss_pred"].fillna(dataframe["stoploss_pred"].mean())
# 计算 roi_0_pred 并清理 NaN 值
dataframe["roi_0_pred"] = dataframe["&-roi_0"].clip(0.01, 0.2)
dataframe["roi_0_pred"] = dataframe["roi_0_pred"].fillna(dataframe["roi_0_pred"].mean())
# 检查预测值
for col in ["buy_rsi_pred", "sell_rsi_pred", "stoploss_pred", "roi_0_pred", "&-sell_rsi", "&-stoploss", "&-roi_0"]:
if dataframe[col].isna().any():
logger.warning(f"{col} 包含 NaN填充为默认值")
dataframe[col] = dataframe[col].fillna(dataframe[col].mean())
# 更保守的止损和止盈设置
dataframe["trailing_stop_positive"] = (dataframe["roi_0_pred"] * 0.3).clip(0.01, 0.2)
dataframe["trailing_stop_positive_offset"] = (dataframe["roi_0_pred"] * 0.5).clip(0.01, 0.3)
# 设置策略级参数
self.buy_rsi.value = float(dataframe["buy_rsi_pred"].iloc[-1])
self.sell_rsi.value = float(dataframe["sell_rsi_pred"].iloc[-1])
# 更保守的止损设置
self.stoploss = -0.15 # 固定止损 15%
self.minimal_roi = {
0: float(self.roi_0.value),
15: float(self.roi_15.value),
30: float(self.roi_30.value),
60: 0
}
# 更保守的追踪止损设置
self.trailing_stop_positive = 0.05 # 追踪止损触发点
self.trailing_stop_positive_offset = 0.1 # 追踪止损偏移量
logger.info(f"动态参数buy_rsi={self.buy_rsi.value}, sell_rsi={self.sell_rsi.value}, "
f"stoploss={self.stoploss}, trailing_stop_positive={self.trailing_stop_positive}")
dataframe.replace([np.inf, -np.inf], 0, inplace=True)
dataframe.ffill(inplace=True)
dataframe.fillna(0, inplace=True)
logger.info(f"up_or_down 值统计:\n{dataframe['up_or_down'].value_counts().to_string()}")
logger.info(f"do_predict 值统计:\n{dataframe['do_predict'].value_counts().to_string()}")
return dataframe
def populate_exit_trend(self, df: DataFrame, metadata: dict) -> DataFrame:
# 改进卖出信号条件
exit_long_conditions = [
(df["rsi"] > df["sell_rsi_pred"]), # RSI 高于卖出阈值
(df["volume"] > df["volume"].rolling(window=10).mean()), # 成交量高于近期均值
(df["close"] < df["bb_middleband"]) # 价格低于布林带中轨
]
if exit_long_conditions:
df.loc[
reduce(lambda x, y: x & y, exit_long_conditions),
"exit_long"
] = 1
return df
def populate_entry_trend(self, df: DataFrame, metadata: dict) -> DataFrame:
# 改进买入信号条件
# 检查 MACD 列是否存在
if "macd" not in df.columns or "macdsignal" not in df.columns:
logger.error("MACD 或 MACD 信号列缺失,无法生成买入信号。尝试重新计算 MACD 列。")
try:
macd = ta.MACD(df, fastperiod=12, slowperiod=26, signalperiod=9)
df["macd"] = macd["macd"]
df["macdsignal"] = macd["macdsignal"]
logger.info("MACD 列已成功重新计算。")
except Exception as e:
logger.error(f"重新计算 MACD 列时出错:{str(e)}")
raise ValueError("DataFrame 缺少必要的 MACD 列且无法重新计算。")
enter_long_conditions = [
(df["rsi"] < df["buy_rsi_pred"]), # RSI 低于买入阈值
(df["volume"] > df["volume"].rolling(window=10).mean() * 1.2), # 成交量高于近期均值20%
(df["close"] > df["bb_middleband"]) # 价格高于布林带中轨
]
# 如果 MACD 列存在,则添加 MACD 金叉条件
if "macd" in df.columns and "macdsignal" in df.columns:
enter_long_conditions.append((df["macd"] > df["macdsignal"]))
# 确保模型预测为买入
enter_long_conditions.append((df["do_predict"] == 1))
if enter_long_conditions:
df.loc[
reduce(lambda x, y: x & y, enter_long_conditions),
["enter_long", "enter_tag"]
] = (1, "long")
return df
def confirm_trade_entry(
self, pair: str, order_type: str, amount: float, rate: float,
time_in_force: str, current_time, entry_tag, side: str, **kwargs
) -> bool:
df, _ = self.dp.get_analyzed_dataframe(pair, self.timeframe)
last_candle = df.iloc[-1].squeeze()
if side == "long":
if rate > (last_candle["close"] * (1 + 0.0025)):
return False
return True

295
freqtrade/new.py Normal file
View File

@ -0,0 +1,295 @@
import logging
import numpy as np
from functools import reduce
import talib.abstract as ta
from pandas import DataFrame
from technical import qtpylib
from freqtrade.strategy import IStrategy, IntParameter, DecimalParameter
logger = logging.getLogger(__name__)
class FreqaiExampleStrategy(IStrategy):
# 移除硬编码的 minimal_roi 和 stoploss改为动态适配
minimal_roi = {} # 将在 populate_indicators 中动态生成
stoploss = 0.0 # 将在 populate_indicators 中动态设置
trailing_stop = True
process_only_new_candles = True
use_exit_signal = True
startup_candle_count: int = 40
can_short = False
# 可训练参数(用于 Hyperopt
buy_rsi = IntParameter(low=10, high=50, default=27, space="buy", optimize=False, load=True)
sell_rsi = IntParameter(low=50, high=90, default=59, space="sell", optimize=False, load=True)
roi_0 = DecimalParameter(low=0.01, high=0.2, default=0.038, space="roi", optimize=True, load=True)
roi_15 = DecimalParameter(low=0.005, high=0.1, default=0.027, space="roi", optimize=True, load=True)
roi_30 = DecimalParameter(low=0.001, high=0.05, default=0.009, space="roi", optimize=True, load=True)
stoploss_param = DecimalParameter(low=-0.35, high=-0.1, default=-0.182, space="stoploss", optimize=True, load=True)
# FreqAI 配置
freqai_info = {
"model": "CatboostClassifier",
"feature_parameters": {
"include_timeframes": ["3m", "15m", "1h"], # 与config一致
"include_corr_pairlist": ["BTC/USDT", "SOL/USDT"], # 添加相关交易对
"label_period_candles": 20, # 与config一致
"include_shifted_candles": 2, # 与config一致
},
"data_split_parameters": {
"test_size": 0.2,
"shuffle": True,
},
"model_training_parameters": {
"n_estimators": 100, # 减少树的数量
"learning_rate": 0.1, # 提高学习率
"max_depth": 6, # 限制树深度
"subsample": 0.8, # 添加子采样
"colsample_bytree": 0.8, # 添加特征采样
"objective": "reg:squarederror",
"eval_metric": "rmse",
"early_stopping_rounds": 20,
"verbose": 0,
},
"data_kitchen": {
"feature_parameters": {
"DI_threshold": 1.5,
"use_DBSCAN_to_remove_outliers": False
}
}
}
plot_config = {
"main_plot": {},
"subplots": {
"&-buy_rsi": {"&-buy_rsi": {"color": "green"}},
"&-sell_rsi": {"&-sell_rsi": {"color": "red"}},
"&-stoploss": {"&-stoploss": {"color": "purple"}},
"&-roi_0": {"&-roi_0": {"color": "orange"}},
"do_predict": {"do_predict": {"color": "brown"}},
},
}
def feature_engineering_expand_all(self, dataframe: DataFrame, period: int, metadata: dict, **kwargs) -> DataFrame:
# RSI 计算
dataframe["rsi"] = ta.RSI(dataframe, timeperiod=14)
# MACD 计算并容错
try:
macd = ta.MACD(dataframe, fastperiod=12, slowperiod=26, signalperiod=9)
dataframe["macd"] = macd["macd"]
dataframe["macdsignal"] = macd["macdsignal"]
except Exception as e:
logger.error(f"MACD 计算失败: {e}")
dataframe["macd"] = np.nan
dataframe["macdsignal"] = np.nan
# 检查 MACD 列是否存在
if "macd" not in dataframe.columns or "macdsignal" not in dataframe.columns:
logger.error("MACD 或 MACD 信号列缺失,无法生成买入信号")
raise ValueError("DataFrame 缺少必要的 MACD 列")
# 确保 MACD 列存在
if "macd" not in dataframe.columns or "macdsignal" not in dataframe.columns:
logger.error("MACD 或 MACD 信号列缺失,无法生成买入信号")
raise ValueError("DataFrame 缺少必要的 MACD 列")
# 保留布林带相关特征
bollinger = qtpylib.bollinger_bands(qtpylib.typical_price(dataframe), window=20, stds=2)
dataframe["bb_lowerband"] = bollinger["lower"]
dataframe["bb_middleband"] = bollinger["mid"]
dataframe["bb_upperband"] = bollinger["upper"]
# 成交量均线
dataframe["volume_ma"] = dataframe["volume"].rolling(window=20).mean()
# 清理无穷大值
for col in dataframe.columns:
if dataframe[col].dtype in ["float64", "int64"]:
dataframe[col] = dataframe[col].replace([np.inf, -np.inf], np.nan)
dataframe[col] = dataframe[col].ffill().fillna(0)
return dataframe
def feature_engineering_expand_basic(self, dataframe: DataFrame, metadata: dict, **kwargs) -> DataFrame:
dataframe["%-pct-change"] = dataframe["close"].pct_change()
dataframe["%-raw_volume"] = dataframe["volume"]
dataframe["%-raw_price"] = dataframe["close"]
# 数据清理逻辑
for col in dataframe.columns:
if dataframe[col].dtype in ["float64", "int64"]:
dataframe[col] = dataframe[col].replace([np.inf, -np.inf], 0)
dataframe[col] = dataframe[col].ffill()
dataframe[col] = dataframe[col].fillna(0)
# 检查是否仍有无效值
if dataframe[col].isna().any() or np.isinf(dataframe[col]).any():
logger.warning(f"{col} 仍包含无效值,已填充为默认值")
dataframe[col] = dataframe[col].fillna(0)
return dataframe
def feature_engineering_standard(self, dataframe: DataFrame, metadata: dict, **kwargs) -> DataFrame:
dataframe["%-day_of_week"] = dataframe["date"].dt.dayofweek
dataframe["%-hour_of_day"] = dataframe["date"].dt.hour
dataframe.replace([np.inf, -np.inf], 0, inplace=True)
dataframe.ffill(inplace=True)
dataframe.fillna(0, inplace=True)
return dataframe
def set_freqai_targets(self, dataframe: DataFrame, metadata: dict, **kwargs) -> DataFrame:
logger.info(f"设置 FreqAI 目标,交易对:{metadata['pair']}")
if "close" not in dataframe.columns:
logger.error("数据框缺少必要的 'close'")
raise ValueError("数据框缺少必要的 'close'")
try:
label_period = self.freqai_info["feature_parameters"]["label_period_candles"]
# 定义目标变量为未来价格变化百分比(连续值)
dataframe["up_or_down"] = (
dataframe["close"].shift(-label_period) - dataframe["close"]
) / dataframe["close"]
# 数据清理:处理 NaN 和 Inf 值
dataframe["up_or_down"] = dataframe["up_or_down"].replace([np.inf, -np.inf], np.nan)
dataframe["up_or_down"] = dataframe["up_or_down"].ffill().fillna(0)
# 确保目标变量是二维数组
if dataframe["up_or_down"].ndim == 1:
dataframe["up_or_down"] = dataframe["up_or_down"].values.reshape(-1, 1)
# 检查并处理 NaN 或无限值
dataframe["up_or_down"] = dataframe["up_or_down"].replace([np.inf, -np.inf], np.nan)
dataframe["up_or_down"] = dataframe["up_or_down"].ffill().fillna(0)
# 生成 %-volatility 特征
dataframe["%-volatility"] = dataframe["close"].pct_change().rolling(20).std()
# 确保 &-buy_rsi 列的值计算正确
dataframe["&-buy_rsi"] = ta.RSI(dataframe, timeperiod=14)
# 数据清理
for col in ["&-buy_rsi", "up_or_down", "%-volatility"]:
# 使用直接操作避免链式赋值
dataframe[col] = dataframe[col].replace([np.inf, -np.inf], np.nan)
dataframe[col] = dataframe[col].ffill() # 替代 fillna(method='ffill')
dataframe[col] = dataframe[col].fillna(dataframe[col].mean()) # 使用均值填充 NaN 值
if dataframe[col].isna().any():
logger.warning(f"目标列 {col} 仍包含 NaN填充为默认值")
except Exception as e:
logger.error(f"创建 FreqAI 目标失败:{str(e)}")
raise
return dataframe
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
logger.info(f"处理交易对:{metadata['pair']}")
dataframe = self.freqai.start(dataframe, metadata, self)
# 计算传统指标
dataframe["rsi"] = ta.RSI(dataframe, timeperiod=14)
bollinger = qtpylib.bollinger_bands(qtpylib.typical_price(dataframe), window=20, stds=2)
dataframe["bb_lowerband"] = bollinger["lower"]
dataframe["bb_middleband"] = bollinger["mid"]
dataframe["bb_upperband"] = bollinger["upper"]
dataframe["tema"] = ta.TEMA(dataframe, timeperiod=9)
# 生成 up_or_down 信号(非 FreqAI 目标)
label_period = self.freqai_info["feature_parameters"]["label_period_candles"]
# 使用未来价格变化方向生成 up_or_down 信号
label_period = self.freqai_info["feature_parameters"]["label_period_candles"]
dataframe["up_or_down"] = np.where(
dataframe["close"].shift(-label_period) > dataframe["close"], 1, 0
)
# 动态设置参数
if "&-buy_rsi" in dataframe.columns:
# 派生其他目标
dataframe["&-sell_rsi"] = dataframe["&-buy_rsi"] + 30
dataframe["%-volatility"] = dataframe["close"].pct_change().rolling(20).std()
# Ensure proper calculation and handle potential NaN values
dataframe["&-stoploss"] = (-0.1 - (dataframe["%-volatility"] * 10).clip(0, 0.25)).fillna(-0.1)
dataframe["&-roi_0"] = ((dataframe["close"] / dataframe["close"].shift(label_period) - 1).clip(0, 0.2)).fillna(0)
# Additional check to ensure no NaN values remain
for col in ["&-stoploss", "&-roi_0"]:
if dataframe[col].isna().any():
logger.warning(f"{col} 仍包含 NaN填充为默认值")
dataframe[col] = dataframe[col].fillna(-0.1 if col == "&-stoploss" else 0)
# 简化动态参数生成逻辑
# 放松 buy_rsi 和 sell_rsi 的生成逻辑
# 计算 buy_rsi_pred 并清理 NaN 值
dataframe["buy_rsi_pred"] = dataframe["rsi"].rolling(window=10).mean().clip(30, 50)
dataframe["buy_rsi_pred"] = dataframe["buy_rsi_pred"].fillna(dataframe["buy_rsi_pred"].median())
# 计算 sell_rsi_pred 并清理 NaN 值
dataframe["sell_rsi_pred"] = dataframe["buy_rsi_pred"] + 20
dataframe["sell_rsi_pred"] = dataframe["sell_rsi_pred"].fillna(dataframe["sell_rsi_pred"].median())
# 计算 stoploss_pred 并清理 NaN 值
dataframe["stoploss_pred"] = -0.1 - (dataframe["%-volatility"] * 10).clip(0, 0.25)
dataframe["stoploss_pred"] = dataframe["stoploss_pred"].fillna(dataframe["stoploss_pred"].mean())
# 计算 roi_0_pred 并清理 NaN 值
dataframe["roi_0_pred"] = dataframe["&-roi_0"].clip(0.01, 0.2)
dataframe["roi_0_pred"] = dataframe["roi_0_pred"].fillna(dataframe["roi_0_pred"].mean())
# 检查预测值
for col in ["buy_rsi_pred", "sell_rsi_pred", "stoploss_pred", "roi_0_pred", "&-sell_rsi", "&-stoploss", "&-roi_0"]:
if dataframe[col].isna().any():
logger.warning(f"{col} 包含 NaN填充为默认值")
dataframe[col] = dataframe[col].fillna(dataframe[col].mean())
# 更保守的止损和止盈设置
dataframe["trailing_stop_positive"] = (dataframe["roi_0_pred"] * 0.3).clip(0.01, 0.2)
dataframe["trailing_stop_positive_offset"] = (dataframe["roi_0_pred"] * 0.5).clip(0.01, 0.3)
# 设置策略级参数
self.buy_rsi.value = float(dataframe["buy_rsi_pred"].iloc[-1])
self.sell_rsi.value = float(dataframe["sell_rsi_pred"].iloc[-1])
# 更保守的止损设置
self.stoploss = -0.15 # 固定止损 15%
self.minimal_roi = {
0: float(self.roi_0.value),
15: float(self.roi_15.value),
30: float(self.roi_30.value),
60: 0
}
# 更保守的追踪止损设置
self.trailing_stop_positive = 0.05 # 追踪止损触发点
self.trailing_stop_positive_offset = 0.1 # 追踪止损偏移量
logger.info(f"动态参数buy_rsi={self.buy_rsi.value}, sell_rsi={self.sell_rsi.value}, "
f"stoploss={self.stoploss}, trailing_stop_positive={self.trailing_stop_positive}")
dataframe.replace([np.inf, -np.inf], 0, inplace=True)
dataframe.ffill(inplace=True)
dataframe.fillna(0, inplace=True)
logger.info(f"up_or_down 值统计:\n{dataframe['up_or_down'].value_counts().to_string()}")
logger.info(f"do_predict 值统计:\n{dataframe['do_predict'].value_counts().to_string()}")
return dataframe
def populate_exit_trend(self, df: DataFrame, metadata: dict) -> DataFrame:
# 改进卖出信号条件
exit_long_conditions = [
(df["rsi"] > df["sell_rsi_pred"]), # RSI 高于卖出阈值
(df["volume"] > df["volume"].rolling(window=10).mean()), # 成交量高于近期均值
(df["close"] < df["bb_middleband"]) # 价格低于布林带中轨
df.loc[reduce(lambda x, y: x & y, conditions), 'exit_long'] = 1
return df
def confirm_trade_entry(
self, pair: str, order_type: str, amount: float, rate: float,
time_in_force: str, current_time, entry_tag, side: str, **kwargs
) -> bool:
df, _ = self.dp.get_analyzed_dataframe(pair, self.timeframe)
last_candle = df.iloc[-1]
if side == "long":
if rate > (last_candle["close"] * 1.0025): # 价格超过最新价 0.25% 则拒绝下单
return False
return True

336
freqtrade/old.py Normal file
View File

@ -0,0 +1,336 @@
import logging
import numpy as np
from functools import reduce
import talib.abstract as ta
from pandas import DataFrame
from technical import qtpylib
from freqtrade.strategy import IStrategy, IntParameter, DecimalParameter
logger = logging.getLogger(__name__)
class FreqaiExampleStrategy(IStrategy):
# 移除硬编码的 minimal_roi 和 stoploss改为动态适配
minimal_roi = {} # 将在 populate_indicators 中动态生成
stoploss = 0.0 # 将在 populate_indicators 中动态设置
trailing_stop = True
process_only_new_candles = True
use_exit_signal = True
startup_candle_count: int = 40
can_short = False
# 参数定义FreqAI 动态适配 buy_rsi 和 sell_rsi禁用 Hyperopt 优化
buy_rsi = IntParameter(low=10, high=50, default=27, space="buy", optimize=False, load=True)
sell_rsi = IntParameter(low=50, high=90, default=59, space="sell", optimize=False, load=True)
# 为 Hyperopt 优化添加 ROI 和 stoploss 参数
roi_0 = DecimalParameter(low=0.01, high=0.2, default=0.038, space="roi", optimize=True, load=True)
roi_15 = DecimalParameter(low=0.005, high=0.1, default=0.027, space="roi", optimize=True, load=True)
roi_30 = DecimalParameter(low=0.001, high=0.05, default=0.009, space="roi", optimize=True, load=True)
stoploss_param = DecimalParameter(low=-0.35, high=-0.1, default=-0.182, space="stoploss", optimize=True, load=True)
# FreqAI 配置
freqai_info = {
"model": "CatboostClassifier", # 与config保持一致
"feature_parameters": {
"include_timeframes": ["3m", "15m", "1h"], # 与config一致
"include_corr_pairlist": ["BTC/USDT", "SOL/USDT"], # 添加相关交易对
"label_period_candles": 20, # 与config一致
"include_shifted_candles": 2, # 与config一致
},
"data_split_parameters": {
"test_size": 0.2,
"shuffle": True, # 启用shuffle
},
"model_training_parameters": {
"n_estimators": 100, # 减少树的数量
"learning_rate": 0.1, # 提高学习率
"max_depth": 6, # 限制树深度
"subsample": 0.8, # 添加子采样
"colsample_bytree": 0.8, # 添加特征采样
"objective": "reg:squarederror",
"eval_metric": "rmse",
"early_stopping_rounds": 20,
"verbose": 0,
},
"data_kitchen": {
"feature_parameters": {
"DI_threshold": 1.5, # 降低异常值过滤阈值
"use_DBSCAN_to_remove_outliers": False # 禁用DBSCAN
}
}
}
plot_config = {
"main_plot": {},
"subplots": {
"&-buy_rsi": {"&-buy_rsi": {"color": "green"}},
"&-sell_rsi": {"&-sell_rsi": {"color": "red"}},
"&-stoploss": {"&-stoploss": {"color": "purple"}},
"&-roi_0": {"&-roi_0": {"color": "orange"}},
"do_predict": {"do_predict": {"color": "brown"}},
},
}
def feature_engineering_expand_all(self, dataframe: DataFrame, period: int, metadata: dict, **kwargs) -> DataFrame:
# 保留关键的技术指标
dataframe["rsi"] = ta.RSI(dataframe, timeperiod=14)
# 确保 MACD 列被正确计算并保留
try:
macd = ta.MACD(dataframe, fastperiod=12, slowperiod=26, signalperiod=9)
dataframe["macd"] = macd["macd"]
dataframe["macdsignal"] = macd["macdsignal"]
except Exception as e:
logger.error(f"计算 MACD 列时出错:{str(e)}")
dataframe["macd"] = np.nan
dataframe["macdsignal"] = np.nan
# 检查 MACD 列是否存在
if "macd" not in dataframe.columns or "macdsignal" not in dataframe.columns:
logger.error("MACD 或 MACD 信号列缺失,无法生成买入信号")
raise ValueError("DataFrame 缺少必要的 MACD 列")
# 确保 MACD 列存在
if "macd" not in dataframe.columns or "macdsignal" not in dataframe.columns:
logger.error("MACD 或 MACD 信号列缺失,无法生成买入信号")
raise ValueError("DataFrame 缺少必要的 MACD 列")
# 保留布林带相关特征
bollinger = qtpylib.bollinger_bands(qtpylib.typical_price(dataframe), window=20, stds=2)
dataframe["bb_lowerband"] = bollinger["lower"]
dataframe["bb_middleband"] = bollinger["mid"]
dataframe["bb_upperband"] = bollinger["upper"]
# 保留成交量相关特征
dataframe["volume_ma"] = dataframe["volume"].rolling(window=20).mean()
# 数据清理
for col in dataframe.columns:
if dataframe[col].dtype in ["float64", "int64"]:
dataframe[col] = dataframe[col].replace([np.inf, -np.inf], np.nan)
dataframe[col] = dataframe[col].ffill().fillna(0)
logger.info(f"特征工程完成,特征数量:{len(dataframe.columns)}")
return dataframe
def feature_engineering_expand_basic(self, dataframe: DataFrame, metadata: dict, **kwargs) -> DataFrame:
dataframe["%-pct-change"] = dataframe["close"].pct_change()
dataframe["%-raw_volume"] = dataframe["volume"]
dataframe["%-raw_price"] = dataframe["close"]
# 数据清理逻辑
for col in dataframe.columns:
if dataframe[col].dtype in ["float64", "int64"]:
dataframe[col] = dataframe[col].replace([np.inf, -np.inf], 0)
dataframe[col] = dataframe[col].ffill()
dataframe[col] = dataframe[col].fillna(0)
# 检查是否仍有无效值
if dataframe[col].isna().any() or np.isinf(dataframe[col]).any():
logger.warning(f"{col} 仍包含无效值,已填充为默认值")
dataframe[col] = dataframe[col].fillna(0)
return dataframe
def feature_engineering_standard(self, dataframe: DataFrame, metadata: dict, **kwargs) -> DataFrame:
dataframe["%-day_of_week"] = dataframe["date"].dt.dayofweek
dataframe["%-hour_of_day"] = dataframe["date"].dt.hour
dataframe.replace([np.inf, -np.inf], 0, inplace=True)
dataframe.ffill(inplace=True)
dataframe.fillna(0, inplace=True)
return dataframe
def set_freqai_targets(self, dataframe: DataFrame, metadata: dict, **kwargs) -> DataFrame:
logger.info(f"设置 FreqAI 目标,交易对:{metadata['pair']}")
if "close" not in dataframe.columns:
logger.error("数据框缺少必要的 'close'")
raise ValueError("数据框缺少必要的 'close'")
try:
label_period = self.freqai_info["feature_parameters"]["label_period_candles"]
# 定义目标变量为未来价格变化百分比(连续值)
dataframe["up_or_down"] = (
dataframe["close"].shift(-label_period) - dataframe["close"]
) / dataframe["close"]
# 数据清理:处理 NaN 和 Inf 值
dataframe["up_or_down"] = dataframe["up_or_down"].replace([np.inf, -np.inf], np.nan)
dataframe["up_or_down"] = dataframe["up_or_down"].ffill().fillna(0)
# 确保目标变量是二维数组
if dataframe["up_or_down"].ndim == 1:
dataframe["up_or_down"] = dataframe["up_or_down"].values.reshape(-1, 1)
# 检查并处理 NaN 或无限值
dataframe["up_or_down"] = dataframe["up_or_down"].replace([np.inf, -np.inf], np.nan)
dataframe["up_or_down"] = dataframe["up_or_down"].ffill().fillna(0)
# 生成 %-volatility 特征
dataframe["%-volatility"] = dataframe["close"].pct_change().rolling(20).std()
# 确保 &-buy_rsi 列的值计算正确
dataframe["&-buy_rsi"] = ta.RSI(dataframe, timeperiod=14)
# 数据清理
for col in ["&-buy_rsi", "up_or_down", "%-volatility"]:
# 使用直接操作避免链式赋值
dataframe[col] = dataframe[col].replace([np.inf, -np.inf], np.nan)
dataframe[col] = dataframe[col].ffill() # 替代 fillna(method='ffill')
dataframe[col] = dataframe[col].fillna(dataframe[col].mean()) # 使用均值填充 NaN 值
if dataframe[col].isna().any():
logger.warning(f"目标列 {col} 仍包含 NaN填充为默认值")
except Exception as e:
logger.error(f"创建 FreqAI 目标失败:{str(e)}")
raise
# Log the shape of the target variable for debugging
logger.info(f"目标列形状:{dataframe['up_or_down'].shape}")
logger.info(f"目标列预览:\n{dataframe[['up_or_down', '&-buy_rsi']].head().to_string()}")
return dataframe
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
logger.info(f"处理交易对:{metadata['pair']}")
dataframe = self.freqai.start(dataframe, metadata, self)
# 计算传统指标
dataframe["rsi"] = ta.RSI(dataframe, timeperiod=14)
bollinger = qtpylib.bollinger_bands(qtpylib.typical_price(dataframe), window=20, stds=2)
dataframe["bb_lowerband"] = bollinger["lower"]
dataframe["bb_middleband"] = bollinger["mid"]
dataframe["bb_upperband"] = bollinger["upper"]
dataframe["tema"] = ta.TEMA(dataframe, timeperiod=9)
# 生成 up_or_down 信号(非 FreqAI 目标)
label_period = self.freqai_info["feature_parameters"]["label_period_candles"]
# 使用未来价格变化方向生成 up_or_down 信号
label_period = self.freqai_info["feature_parameters"]["label_period_candles"]
dataframe["up_or_down"] = np.where(
dataframe["close"].shift(-label_period) > dataframe["close"], 1, 0
)
# 动态设置参数
if "&-buy_rsi" in dataframe.columns:
# 派生其他目标
dataframe["&-sell_rsi"] = dataframe["&-buy_rsi"] + 30
dataframe["%-volatility"] = dataframe["close"].pct_change().rolling(20).std()
# Ensure proper calculation and handle potential NaN values
dataframe["&-stoploss"] = (-0.1 - (dataframe["%-volatility"] * 10).clip(0, 0.25)).fillna(-0.1)
dataframe["&-roi_0"] = ((dataframe["close"] / dataframe["close"].shift(label_period) - 1).clip(0, 0.2)).fillna(0)
# Additional check to ensure no NaN values remain
for col in ["&-stoploss", "&-roi_0"]:
if dataframe[col].isna().any():
logger.warning(f"{col} 仍包含 NaN填充为默认值")
dataframe[col] = dataframe[col].fillna(-0.1 if col == "&-stoploss" else 0)
# 简化动态参数生成逻辑
# 放松 buy_rsi 和 sell_rsi 的生成逻辑
# 计算 buy_rsi_pred 并清理 NaN 值
dataframe["buy_rsi_pred"] = dataframe["rsi"].rolling(window=10).mean().clip(30, 50)
dataframe["buy_rsi_pred"] = dataframe["buy_rsi_pred"].fillna(dataframe["buy_rsi_pred"].median())
# 计算 sell_rsi_pred 并清理 NaN 值
dataframe["sell_rsi_pred"] = dataframe["buy_rsi_pred"] + 20
dataframe["sell_rsi_pred"] = dataframe["sell_rsi_pred"].fillna(dataframe["sell_rsi_pred"].median())
# 计算 stoploss_pred 并清理 NaN 值
dataframe["stoploss_pred"] = -0.1 - (dataframe["%-volatility"] * 10).clip(0, 0.25)
dataframe["stoploss_pred"] = dataframe["stoploss_pred"].fillna(dataframe["stoploss_pred"].mean())
# 计算 roi_0_pred 并清理 NaN 值
dataframe["roi_0_pred"] = dataframe["&-roi_0"].clip(0.01, 0.2)
dataframe["roi_0_pred"] = dataframe["roi_0_pred"].fillna(dataframe["roi_0_pred"].mean())
# 检查预测值
for col in ["buy_rsi_pred", "sell_rsi_pred", "stoploss_pred", "roi_0_pred", "&-sell_rsi", "&-stoploss", "&-roi_0"]:
if dataframe[col].isna().any():
logger.warning(f"{col} 包含 NaN填充为默认值")
dataframe[col] = dataframe[col].fillna(dataframe[col].mean())
# 更保守的止损和止盈设置
dataframe["trailing_stop_positive"] = (dataframe["roi_0_pred"] * 0.3).clip(0.01, 0.2)
dataframe["trailing_stop_positive_offset"] = (dataframe["roi_0_pred"] * 0.5).clip(0.01, 0.3)
# 设置策略级参数
self.buy_rsi.value = float(dataframe["buy_rsi_pred"].iloc[-1])
self.sell_rsi.value = float(dataframe["sell_rsi_pred"].iloc[-1])
# 更保守的止损设置
self.stoploss = -0.15 # 固定止损 15%
self.minimal_roi = {
0: float(self.roi_0.value),
15: float(self.roi_15.value),
30: float(self.roi_30.value),
60: 0
}
# 更保守的追踪止损设置
self.trailing_stop_positive = 0.05 # 追踪止损触发点
self.trailing_stop_positive_offset = 0.1 # 追踪止损偏移量
logger.info(f"动态参数buy_rsi={self.buy_rsi.value}, sell_rsi={self.sell_rsi.value}, "
f"stoploss={self.stoploss}, trailing_stop_positive={self.trailing_stop_positive}")
dataframe.replace([np.inf, -np.inf], 0, inplace=True)
dataframe.ffill(inplace=True)
dataframe.fillna(0, inplace=True)
logger.info(f"up_or_down 值统计:\n{dataframe['up_or_down'].value_counts().to_string()}")
logger.info(f"do_predict 值统计:\n{dataframe['do_predict'].value_counts().to_string()}")
return dataframe
def populate_exit_trend(self, df: DataFrame, metadata: dict) -> DataFrame:
# 改进卖出信号条件
exit_long_conditions = [
(df["rsi"] > df["sell_rsi_pred"]), # RSI 高于卖出阈值
(df["volume"] > df["volume"].rolling(window=10).mean()), # 成交量高于近期均值
(df["close"] < df["bb_middleband"]) # 价格低于布林带中轨
]
if exit_long_conditions:
df.loc[
reduce(lambda x, y: x & y, exit_long_conditions),
"exit_long"
] = 1
return df
def populate_entry_trend(self, df: DataFrame, metadata: dict) -> DataFrame:
# 改进买入信号条件
# 检查 MACD 列是否存在
if "macd" not in df.columns or "macdsignal" not in df.columns:
logger.error("MACD 或 MACD 信号列缺失,无法生成买入信号。尝试重新计算 MACD 列。")
try:
macd = ta.MACD(df, fastperiod=12, slowperiod=26, signalperiod=9)
df["macd"] = macd["macd"]
df["macdsignal"] = macd["macdsignal"]
logger.info("MACD 列已成功重新计算。")
except Exception as e:
logger.error(f"重新计算 MACD 列时出错:{str(e)}")
raise ValueError("DataFrame 缺少必要的 MACD 列且无法重新计算。")
enter_long_conditions = [
(df["rsi"] < df["buy_rsi_pred"]), # RSI 低于买入阈值
(df["volume"] > df["volume"].rolling(window=10).mean() * 1.2), # 成交量高于近期均值20%
(df["close"] > df["bb_middleband"]) # 价格高于布林带中轨
]
# 如果 MACD 列存在,则添加 MACD 金叉条件
if "macd" in df.columns and "macdsignal" in df.columns:
enter_long_conditions.append((df["macd"] > df["macdsignal"]))
# 确保模型预测为买入
enter_long_conditions.append((df["do_predict"] == 1))
if enter_long_conditions:
df.loc[
reduce(lambda x, y: x & y, enter_long_conditions),
["enter_long", "enter_tag"]
] = (1, "long")
return df
def confirm_trade_entry(
self, pair: str, order_type: str, amount: float, rate: float,
time_in_force: str, current_time, entry_tag, side: str, **kwargs
) -> bool:
df, _ = self.dp.get_analyzed_dataframe(pair, self.timeframe)
last_candle = df.iloc[-1].squeeze()
if side == "long":
if rate > (last_candle["close"] * (1 + 0.0025)):
return False
return True

View File

@ -0,0 +1,185 @@
from freqtrade.strategy import IStrategy
import talib.abstract as ta
import pandas as pd
import numpy as np
import logging
from technical import qtpylib
from functools import reduce
from freqtrade.strategy import IStrategy, IntParameter, DecimalParameter
class MyDynamicStrategy(IStrategy):
# --- 参数空间 ---
buy_rsi = IntParameter(10, 50, default=30)
sell_rsi = IntParameter(50, 90, default=70)
roi_0 = DecimalParameter(0.01, 0.2, default=0.03)
roi_1 = DecimalParameter(0.005, 0.1, default=0.015)
stoploss_param = DecimalParameter(-0.3, -0.1, default=-0.15)
trailing_stop = True
trailing_stop_positive = 0.05
trailing_stop_positive_offset = 0.1
can_short = False
process_only_new_candles = True
use_exit_signal = True
stoploss = -0.15
minimal_roi = {"0": 0.03, "30": 0.01, "60": 0}
# --- Plotting config ---
plot_config = {
"main_plot": {},
"subplots": {
"RSI Buy Threshold": {
"&-buy_rsi": {"color": "green"}
},
"ROI and Stoploss": {
"&-roi_0": {"color": "orange"},
"&-stoploss": {"color": "red"}
}
}
}
# --- FreqAI 配置 ---
freqai_info = {
"model": "CatboostClassifier",
"feature_parameters": {
"include_timeframes": ["5m", "1h"],
"indicator_periods_candles": [10, 20, 50],
"include_corr_pairlist": ["BTC/USDT"],
"target_classifier": "value",
"label_period_candles": 20,
},
"training_settings": {
"train_period_days": 30,
"startup_candle_count": 200
}
}
def feature_engineering_expand_all(self, dataframe, period, **kwargs):
df = dataframe.copy()
df[f'rsi_{period}'] = ta.RSI(df, timeperiod=period)
df[f'sma_diff_{period}'] = df['close'] - ta.SMA(df, timeperiod=period)
df[f'macd_{period}'], _, _ = ta.MACD(df, fastperiod=12, slowperiod=26, signalperiod=9)
df[f'stoch_rsi_{period}'] = ta.STOCHRSI(df, timeperiod=period)
df[f'cci_{period}'] = ta.CCI(df, timeperiod=period)
df[f'willr_{period}'] = ta.WILLR(df, timeperiod=period)
df[f'atr_{period}'] = ta.ATR(df, timeperiod=period)
df[f'price_change_rate_{period}'] = df['close'].pct_change(period)
df[f'volatility_{period}'] = df['close'].pct_change().rolling(window=period).std()
return df
def set_freqai_targets(self, dataframe: pd.DataFrame, metadata: dict) -> pd.DataFrame:
# 使用短期和长期均线交叉作为目标标签
short_ma = ta.SMA(dataframe, timeperiod=10)
long_ma = ta.SMA(dataframe, timeperiod=50)
dataframe['target'] = np.where(short_ma > long_ma, 2,
np.where(short_ma < long_ma, 0, 1))
return dataframe
def populate_indicators(self, dataframe: pd.DataFrame, metadata: dict) -> pd.DataFrame:
# 示例使用简单未来N周期涨跌作为目标变量
# 使用短期均线趋势代替未来价格
# 计算短期和长期均线
short_ma = ta.SMA(dataframe, timeperiod=10)
long_ma = ta.SMA(dataframe, timeperiod=50)
dataframe['short_ma'] = short_ma
dataframe['long_ma'] = long_ma
# 计算 RSI 和其他动态参数
dataframe['rsi'] = ta.RSI(dataframe, timeperiod=14)
dataframe['&-buy_rsi'] = self.buy_rsi.value
dataframe['&-sell_rsi'] = self.sell_rsi.value
dataframe['&-roi_0'] = self.roi_0.value
dataframe['&-stoploss'] = self.stoploss_param.value
# 添加调试日志
logging.info(f"Feature columns after feature engineering: {list(dataframe.columns)}")
# 使用短期和长期均线交叉作为目标标签
dataframe['target'] = np.where(short_ma > long_ma, 2,
np.where(short_ma < long_ma, 1, 0))
# 动态设置 minimal_roi
# 平滑处理 ROI 参数
# 基于波动率动态调整 ROI 参数
# 使用指数加权移动平均 (EWMA) 计算波动率
volatility = dataframe['close'].pct_change().ewm(span=20, adjust=False).std().mean()
roi_0_dynamic = max(0.01, min(0.2, self.roi_0.value * (1 + volatility)))
roi_1_dynamic = max(0.005, min(0.1, self.roi_1.value * (1 + volatility)))
self.minimal_roi = {
0: roi_0_dynamic,
30: roi_1_dynamic,
60: 0
}
# 动态调整止损距离
volatility_multiplier = max(1.5, min(3.0, 2.0 + volatility)) # 波动率倍数
self.stoploss = -0.15 * volatility_multiplier
# 计算 Bollinger Bands 并添加到 dataframe
bollinger = qtpylib.bollinger_bands(qtpylib.typical_price(dataframe), window=20, stds=2)
dataframe['bollinger_upper'] = bollinger['upper']
dataframe['bollinger_mid'] = bollinger['mid']
dataframe['bollinger_lower'] = bollinger['lower']
# 计算 MACD 并添加到 dataframe
macd, macdsignal, _ = ta.MACD(dataframe, fastperiod=12, slowperiod=26, signalperiod=9)
dataframe['macd'] = macd
dataframe['macdsignal'] = macdsignal
# 添加调试日志
logging.info(f"RSI condition: {(dataframe['rsi'] < dataframe['&-buy_rsi']).sum()}")
logging.info(f"Volume condition: {(dataframe['volume'] > dataframe['volume'].rolling(window=20).mean() * 1.05).sum()}")
logging.info(f"MACD condition: {((dataframe['close'] <= dataframe['bollinger_lower'] * 1.01) & (dataframe['macd'] > dataframe['macdsignal'])).sum()}")
# 添加 ADX 趋势过滤器
dataframe['adx'] = ta.ADX(dataframe, timeperiod=14)
is_strong_trend = dataframe['adx'].iloc[-1] > 25
# MACD 穿越信号条件
(dataframe["close"] < dataframe['bollinger_lower']) & (dataframe['macd'] > dataframe['macdsignal']),
# 基于趋势强度动态调整追踪止损
trend_strength = (dataframe['short_ma'] - dataframe['long_ma']).mean()
if is_strong_trend:
self.trailing_stop_positive = max(0.01, min(0.1, abs(trend_strength) * 0.3))
self.trailing_stop_positive_offset = max(0.01, min(0.2, abs(trend_strength) * 0.6))
else:
self.trailing_stop_positive = 0.05
self.trailing_stop_positive_offset = 0.1
trend_strength = (dataframe['short_ma'] - dataframe['long_ma']).mean()
self.trailing_stop_positive = max(0.01, min(0.1, abs(trend_strength) * 0.3))
return dataframe
def populate_entry_trend(self, df: pd.DataFrame, metadata: dict) -> pd.DataFrame:
# 增加成交量过滤和 Bollinger Bands 信号
# 计算 MACD
macd, macdsignal, _ = ta.MACD(df, fastperiod=12, slowperiod=26, signalperiod=9)
df['macd'] = macd
df['macdsignal'] = macdsignal
bollinger = qtpylib.bollinger_bands(qtpylib.typical_price(df), window=20, stds=2)
conditions = [
(df["rsi"] < df["&-buy_rsi"]), # RSI 低于买入阈值
(df["volume"] > df["volume"].rolling(window=20).mean() * 1.1), # 成交量增长超过 10%
(df["close"] < df['bollinger_lower']) & (df['macd'] > df['macdsignal']), # MACD 穿越信号
]
df.loc[reduce(lambda x, y: x & y, conditions), 'enter_long'] = 1
return df
def populate_exit_trend(self, df: pd.DataFrame, metadata: dict) -> pd.DataFrame:
# 增加 Bollinger Bands 中轨信号
bollinger = qtpylib.bollinger_bands(qtpylib.typical_price(df), window=20, stds=2)
exit_long_conditions = [
(df["rsi"] > df["&-sell_rsi"]),
(df["close"] > df['bollinger_mid']) # Bollinger Bands 中轨信号
]
df.loc[reduce(lambda x, y: x & y, exit_long_conditions), 'exit_long'] = 1
return df
def confirm_trade_entry(self, pair, order_type, amount, rate, time_in_force, current_time, entry_tag, side, **kwargs):
df, _ = self.dp.get_analyzed_dataframe(pair, self.timeframe)
last_candle = df.iloc[-1]
if rate > last_candle["close"] * 1.0025:
return False
return True

View File

@ -0,0 +1,69 @@
from freqtrade.strategy.interface import IStrategy
import pandas as pd
import numpy as np
import talib as ta
import logging
import datetime
from freqtrade.strategy import IStrategy, IntParameter, DecimalParameter
logger = logging.getLogger(__name__)
class MyOptimizedStrategy(IStrategy):
# --- Hyperoptables ---
buy_rsi = IntParameter(20, 50, default=30, space="buy")
sell_rsi = IntParameter(50, 80, default=70, space="sell")
# --- FreqAI 相关 ---
minimal_roi = {"0": 0.05, "30": 0.02, "60": 0}
stoploss = -0.1
trailing_stop = True
trailing_stop_positive = 0.03
trailing_stop_positive_offset = 0.05
def populate_indicators(self, dataframe: pd.DataFrame, metadata: dict) -> pd.DataFrame:
label_period = self.freqai_info["feature_parameters"]["label_period_candles"]
dataframe["up_or_down"] = np.where(
dataframe["close"].shift(-label_period) > dataframe["close"], 1, 0
)
dataframe["rsi"] = ta.RSI(dataframe, timeperiod=14)
# 添加 volume_ma
dataframe["volume_ma"] = dataframe["volume"].rolling(window=20).mean()
# Bollinger Bands
bollinger = qtpylib.bollinger_bands(qtpylib.typical_price(dataframe), window=20, stds=2)
dataframe["bb_lowerband"] = bollinger["lower"]
dataframe["bb_middleband"] = bollinger["mid"]
dataframe["bb_upperband"] = bollinger["upper"]
dataframe.replace([np.inf, -np.inf], 0, inplace=True)
dataframe.ffill(inplace=True)
dataframe.fillna(0, inplace=True)
return dataframe
def populate_entry_trend(self, dataframe: pd.DataFrame, metadata: dict) -> pd.DataFrame:
conditions = [
(dataframe['do_predict'] == 1),
(dataframe['rsi'] < dataframe['&-buy_rsi_pred']),
(dataframe['close'] < dataframe['bb_lowerband'])
]
dataframe.loc[reduce(np.logical_and, conditions), 'enter_long'] = 1
return dataframe
def populate_exit_trend(self, dataframe: pd.DataFrame, metadata: dict) -> pd.DataFrame:
conditions = [
(dataframe['do_predict'] == 1),
(dataframe['rsi'] > dataframe['&-sell_rsi_pred'])
]
dataframe.loc[reduce(np.logical_and, conditions), 'exit_long'] = 1
return dataframe
def custom_stoploss(self, pair: str, trade: 'Trade', current_time: datetime, current_rate: float,
current_profit: float, **kwargs) -> float:
dataframe, _ = self.dp.get_analyzed_dataframe(pair, self.timeframe)
last_row = dataframe.iloc[-1]
if "&-stoploss" in last_row:
return float(last_row["&-stoploss"])
return self.stoploss

3066
freqtrade_utf8.log Normal file

File diff suppressed because it is too large Load Diff

1232
output.log Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,335 +1,385 @@
Creating freqtrade_freqtrade_run ...
Creating freqtrade_freqtrade_run ... done
2025-04-29 07:44:18,057 - freqtrade - INFO - freqtrade 2025.3
2025-04-29 07:44:18,268 - numexpr.utils - INFO - NumExpr defaulting to 12 threads.
2025-04-29 07:44:19,654 - freqtrade.configuration.load_config - INFO - Using config: /freqtrade/config_examples/config_freqai.okx.json ...
2025-04-29 07:44:19,654 - freqtrade.configuration.load_config - INFO - Using config: /freqtrade/templates/FreqaiExampleStrategy.json ...
2025-04-29 07:44:19,656 - freqtrade.loggers - INFO - Enabling colorized output.
2025-04-29 07:44:19,657 - root - INFO - Logfile configured
2025-04-29 07:44:19,657 - freqtrade.loggers - INFO - Verbosity set to 0
2025-04-29 07:44:19,657 - freqtrade.configuration.configuration - INFO - Using additional Strategy lookup path: /freqtrade/templates
2025-04-29 07:44:19,658 - freqtrade.configuration.configuration - INFO - Using max_open_trades: 4 ...
2025-04-29 07:44:19,658 - freqtrade.configuration.configuration - INFO - Parameter --timerange detected: 20250401-20250420 ...
2025-04-29 07:44:19,698 - freqtrade.configuration.configuration - INFO - Using user-data directory: /freqtrade/user_data ...
2025-04-29 07:44:19,699 - freqtrade.configuration.configuration - INFO - Using data directory: /freqtrade/user_data/data/okx ...
2025-04-29 07:44:19,699 - freqtrade.configuration.configuration - INFO - Parameter --cache=none detected ...
2025-04-29 07:44:19,700 - freqtrade.configuration.configuration - INFO - Filter trades by timerange: 20250401-20250420
2025-04-29 07:44:19,700 - freqtrade.configuration.configuration - INFO - Using freqaimodel class name: XGBoostRegressor
2025-04-29 07:44:19,701 - freqtrade.exchange.check_exchange - INFO - Checking exchange...
2025-04-29 07:44:19,708 - freqtrade.exchange.check_exchange - INFO - Exchange "okx" is officially supported by the Freqtrade development team.
2025-04-29 07:44:19,708 - freqtrade.configuration.configuration - INFO - Using pairlist from configuration.
2025-04-29 07:44:19,708 - freqtrade.configuration.config_validation - INFO - Validating configuration ...
2025-04-29 07:44:19,710 - freqtrade.commands.optimize_commands - INFO - Starting freqtrade in Backtesting mode
2025-04-29 07:44:19,711 - freqtrade.exchange.exchange - INFO - Instance is running with dry_run enabled
2025-04-29 07:44:19,711 - freqtrade.exchange.exchange - INFO - Using CCXT 4.4.69
2025-04-29 07:44:19,712 - freqtrade.exchange.exchange - INFO - Applying additional ccxt config: {'enableRateLimit': True, 'rateLimit': 500, 'options': {'defaultType': 'spot'}}
2025-04-29 07:44:19,717 - freqtrade.exchange.exchange - INFO - Applying additional ccxt config: {'enableRateLimit': True, 'rateLimit': 500, 'options': {'defaultType': 'spot'}, 'timeout': 20000}
2025-04-29 07:44:19,722 - freqtrade.exchange.exchange - INFO - Using Exchange "OKX"
2025-04-29 07:44:22,575 - freqtrade.resolvers.exchange_resolver - INFO - Using resolved exchange 'Okx'...
2025-04-29 07:44:22,595 - freqtrade.resolvers.iresolver - INFO - Using resolved strategy FreqaiExampleStrategy from '/freqtrade/templates/FreqaiExampleStrategy.py'...
2025-04-29 07:44:22,596 - freqtrade.strategy.hyper - INFO - Loading parameters from file /freqtrade/templates/FreqaiExampleStrategy.json
2025-04-29 07:44:22,597 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'timeframe' with value in config file: 3m.
2025-04-29 07:44:22,597 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'stoploss' with value in config file: -0.05.
2025-04-29 07:44:22,598 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'stake_currency' with value in config file: USDT.
2025-04-29 07:44:22,598 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'stake_amount' with value in config file: 150.
2025-04-29 07:44:22,598 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'startup_candle_count' with value in config file: 30.
2025-04-29 07:44:22,599 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'unfilledtimeout' with value in config file: {'entry': 5, 'exit': 15, 'exit_timeout_count': 0, 'unit':
2025-05-01 04:27:17,240 - freqtrade - INFO - freqtrade 2025.3
2025-05-01 04:27:17,468 - numexpr.utils - INFO - NumExpr defaulting to 12 threads.
2025-05-01 04:27:18,889 - freqtrade.configuration.load_config - INFO - Using config: /freqtrade/config_examples/config_freqai.okx.json ...
2025-05-01 04:27:18,891 - freqtrade.loggers - INFO - Enabling colorized output.
2025-05-01 04:27:18,891 - root - INFO - Logfile configured
2025-05-01 04:27:18,892 - freqtrade.loggers - INFO - Verbosity set to 0
2025-05-01 04:27:18,892 - freqtrade.configuration.configuration - INFO - Using additional Strategy lookup path: /freqtrade/templates
2025-05-01 04:27:18,892 - freqtrade.configuration.configuration - INFO - Using max_open_trades: 4 ...
2025-05-01 04:27:18,893 - freqtrade.configuration.configuration - INFO - Parameter --timerange detected: 20250401-20250420 ...
2025-05-01 04:27:18,909 - freqtrade.configuration.configuration - INFO - Using user-data directory: /freqtrade/user_data ...
2025-05-01 04:27:18,910 - freqtrade.configuration.configuration - INFO - Using data directory: /freqtrade/user_data/data/okx ...
2025-05-01 04:27:18,910 - freqtrade.configuration.configuration - INFO - Parameter --cache=none detected ...
2025-05-01 04:27:18,911 - freqtrade.configuration.configuration - INFO - Filter trades by timerange: 20250401-20250420
2025-05-01 04:27:18,911 - freqtrade.configuration.configuration - INFO - Using freqaimodel class name: XGBoostRegressor
2025-05-01 04:27:18,912 - freqtrade.exchange.check_exchange - INFO - Checking exchange...
2025-05-01 04:27:18,918 - freqtrade.exchange.check_exchange - INFO - Exchange "okx" is officially supported by the Freqtrade development team.
2025-05-01 04:27:18,918 - freqtrade.configuration.configuration - INFO - Using pairlist from configuration.
2025-05-01 04:27:18,918 - freqtrade.configuration.config_validation - INFO - Validating configuration ...
2025-05-01 04:27:18,920 - freqtrade.commands.optimize_commands - INFO - Starting freqtrade in Backtesting mode
2025-05-01 04:27:18,921 - freqtrade.exchange.exchange - INFO - Instance is running with dry_run enabled
2025-05-01 04:27:18,921 - freqtrade.exchange.exchange - INFO - Using CCXT 4.4.69
2025-05-01 04:27:18,922 - freqtrade.exchange.exchange - INFO - Applying additional ccxt config: {'enableRateLimit': True, 'rateLimit': 500, 'options': {'defaultType': 'spot'}}
2025-05-01 04:27:18,927 - freqtrade.exchange.exchange - INFO - Applying additional ccxt config: {'enableRateLimit': True, 'rateLimit': 500, 'options': {'defaultType': 'spot'}, 'timeout': 20000}
2025-05-01 04:27:18,933 - freqtrade.exchange.exchange - INFO - Using Exchange "OKX"
2025-05-01 04:27:21,480 - freqtrade.resolvers.exchange_resolver - INFO - Using resolved exchange 'Okx'...
2025-05-01 04:27:21,502 - freqtrade.resolvers.iresolver - INFO - Using resolved strategy FreqaiExampleStrategy from '/freqtrade/templates/FreqaiExampleStrategy.py'...
2025-05-01 04:27:21,503 - freqtrade.strategy.hyper - INFO - Loading parameters from file /freqtrade/templates/FreqaiExampleStrategy.json
2025-05-01 04:27:21,503 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'timeframe' with value in config file: 3m.
2025-05-01 04:27:21,504 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'stoploss' with value in config file: -0.05.
2025-05-01 04:27:21,504 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'stake_currency' with value in config file: USDT.
2025-05-01 04:27:21,504 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'stake_amount' with value in config file: 150.
2025-05-01 04:27:21,505 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'startup_candle_count' with value in config file: 30.
2025-05-01 04:27:21,505 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'unfilledtimeout' with value in config file: {'entry': 5, 'exit': 15, 'exit_timeout_count': 0, 'unit':
'minutes'}.
2025-04-29 07:44:22,599 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'max_open_trades' with value in config file: 4.
2025-04-29 07:44:22,599 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using minimal_roi: {'0': 0.132, '8': 0.047, '14': 0.007, '60': 0}
2025-04-29 07:44:22,600 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using timeframe: 3m
2025-04-29 07:44:22,600 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using stoploss: -0.05
2025-04-29 07:44:22,600 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using trailing_stop: True
2025-04-29 07:44:22,601 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using trailing_stop_positive: 0.01
2025-04-29 07:44:22,601 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using trailing_stop_positive_offset: 0.02
2025-04-29 07:44:22,602 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using trailing_only_offset_is_reached: False
2025-04-29 07:44:22,602 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using use_custom_stoploss: False
2025-04-29 07:44:22,602 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using process_only_new_candles: True
2025-04-29 07:44:22,603 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using order_types: {'entry': 'limit', 'exit': 'limit', 'stoploss': 'limit', 'stoploss_on_exchange': False,
2025-05-01 04:27:21,505 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'max_open_trades' with value in config file: 4.
2025-05-01 04:27:21,506 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using minimal_roi: {'0': 0.132, '8': 0.047, '14': 0.007, '60': 0}
2025-05-01 04:27:21,506 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using timeframe: 3m
2025-05-01 04:27:21,506 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using stoploss: -0.05
2025-05-01 04:27:21,506 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using trailing_stop: True
2025-05-01 04:27:21,507 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using trailing_stop_positive: 0.01
2025-05-01 04:27:21,507 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using trailing_stop_positive_offset: 0.02
2025-05-01 04:27:21,507 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using trailing_only_offset_is_reached: False
2025-05-01 04:27:21,508 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using use_custom_stoploss: False
2025-05-01 04:27:21,508 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using process_only_new_candles: True
2025-05-01 04:27:21,508 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using order_types: {'entry': 'limit', 'exit': 'limit', 'stoploss': 'limit', 'stoploss_on_exchange': False,
'stoploss_on_exchange_interval': 60}
2025-04-29 07:44:22,603 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using order_time_in_force: {'entry': 'GTC', 'exit': 'GTC'}
2025-04-29 07:44:22,603 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using stake_currency: USDT
2025-04-29 07:44:22,604 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using stake_amount: 150
2025-04-29 07:44:22,604 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using startup_candle_count: 30
2025-04-29 07:44:22,604 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using unfilledtimeout: {'entry': 5, 'exit': 15, 'exit_timeout_count': 0, 'unit': 'minutes'}
2025-04-29 07:44:22,605 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using use_exit_signal: True
2025-04-29 07:44:22,605 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using exit_profit_only: False
2025-04-29 07:44:22,605 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using ignore_roi_if_entry_signal: False
2025-04-29 07:44:22,606 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using exit_profit_offset: 0.0
2025-04-29 07:44:22,606 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using disable_dataframe_checks: False
2025-04-29 07:44:22,606 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using ignore_buying_expired_candle_after: 0
2025-04-29 07:44:22,607 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using position_adjustment_enable: False
2025-04-29 07:44:22,607 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using max_entry_position_adjustment: -1
2025-04-29 07:44:22,607 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using max_open_trades: 4
2025-04-29 07:44:22,608 - freqtrade.configuration.config_validation - INFO - Validating configuration ...
2025-04-29 07:44:22,611 - freqtrade.resolvers.iresolver - INFO - Using resolved pairlist StaticPairList from '/freqtrade/freqtrade/plugins/pairlist/StaticPairList.py'...
2025-04-29 07:44:22,618 - freqtrade.optimize.backtesting - INFO - Using fee 0.1500% - worst case fee from exchange (lowest tier).
2025-04-29 07:44:22,619 - freqtrade.data.dataprovider - INFO - Increasing startup_candle_count for freqai on 3m to 14450
2025-04-29 07:44:22,619 - freqtrade.data.history.history_utils - INFO - Using indicator startup period: 14450 ...
2025-04-29 07:44:22,751 - freqtrade.optimize.backtesting - INFO - Loading data from 2025-03-01 21:30:00 up to 2025-04-20 00:00:00 (49 days).
2025-04-29 07:44:22,751 - freqtrade.optimize.backtesting - INFO - Dataload complete. Calculating indicators
2025-04-29 07:44:22,752 - freqtrade.optimize.backtesting - INFO - Running backtesting for Strategy FreqaiExampleStrategy
2025-04-29 07:44:24,335 - matplotlib.font_manager - INFO - generated new fontManager
2025-04-29 07:44:24,532 - freqtrade.resolvers.iresolver - INFO - Using resolved freqaimodel XGBoostRegressor from '/freqtrade/freqtrade/freqai/prediction_models/XGBoostRegressor.py'...
2025-04-29 07:44:24,532 - freqtrade.freqai.data_drawer - INFO - Could not find existing datadrawer, starting from scratch
2025-04-29 07:44:24,533 - freqtrade.freqai.data_drawer - INFO - Could not find existing historic_predictions, starting from scratch
2025-04-29 07:44:24,533 - freqtrade.freqai.freqai_interface - INFO - Set fresh train queue from whitelist. Queue: ['BTC/USDT', 'SOL/USDT']
2025-04-29 07:44:24,534 - freqtrade.strategy.hyper - INFO - Strategy Parameter: buy_rsi = 39.92672300850069
2025-04-29 07:44:24,535 - freqtrade.strategy.hyper - INFO - Strategy Parameter: sell_rsi = 69.92672300850067
2025-04-29 07:44:24,535 - freqtrade.strategy.hyper - INFO - No params for protection found, using default values.
2025-04-29 07:44:24,537 - FreqaiExampleStrategy - INFO - 处理交易对BTC/USDT
2025-04-29 07:44:24,539 - freqtrade.freqai.freqai_interface - INFO - Training 2 timeranges
2025-04-29 07:44:24,540 - freqtrade.freqai.freqai_interface - INFO - Training BTC/USDT, 1/2 pairs from 2025-03-02 00:00:00 to 2025-04-01 00:00:00, 1/2 trains
2025-04-29 07:44:24,540 - freqtrade.freqai.data_kitchen - INFO - Could not find backtesting prediction file at
2025-05-01 04:27:21,508 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using order_time_in_force: {'entry': 'GTC', 'exit': 'GTC'}
2025-05-01 04:27:21,509 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using stake_currency: USDT
2025-05-01 04:27:21,509 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using stake_amount: 150
2025-05-01 04:27:21,509 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using startup_candle_count: 30
2025-05-01 04:27:21,510 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using unfilledtimeout: {'entry': 5, 'exit': 15, 'exit_timeout_count': 0, 'unit': 'minutes'}
2025-05-01 04:27:21,510 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using use_exit_signal: True
2025-05-01 04:27:21,510 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using exit_profit_only: False
2025-05-01 04:27:21,510 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using ignore_roi_if_entry_signal: False
2025-05-01 04:27:21,511 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using exit_profit_offset: 0.0
2025-05-01 04:27:21,511 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using disable_dataframe_checks: False
2025-05-01 04:27:21,511 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using ignore_buying_expired_candle_after: 0
2025-05-01 04:27:21,511 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using position_adjustment_enable: False
2025-05-01 04:27:21,512 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using max_entry_position_adjustment: -1
2025-05-01 04:27:21,512 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using max_open_trades: 4
2025-05-01 04:27:21,512 - freqtrade.configuration.config_validation - INFO - Validating configuration ...
2025-05-01 04:27:21,516 - freqtrade.resolvers.iresolver - INFO - Using resolved pairlist StaticPairList from '/freqtrade/freqtrade/plugins/pairlist/StaticPairList.py'...
2025-05-01 04:27:21,522 - freqtrade.optimize.backtesting - INFO - Using fee 0.1500% - worst case fee from exchange (lowest tier).
2025-05-01 04:27:21,523 - freqtrade.data.dataprovider - INFO - Increasing startup_candle_count for freqai on 3m to 14450
2025-05-01 04:27:21,524 - freqtrade.data.history.history_utils - INFO - Using indicator startup period: 14450 ...
2025-05-01 04:27:21,658 - freqtrade.optimize.backtesting - INFO - Loading data from 2025-03-01 21:30:00 up to 2025-04-20 00:00:00 (49 days).
2025-05-01 04:27:21,658 - freqtrade.optimize.backtesting - INFO - Dataload complete. Calculating indicators
2025-05-01 04:27:21,659 - freqtrade.optimize.backtesting - INFO - Running backtesting for Strategy FreqaiExampleStrategy
2025-05-01 04:27:23,258 - matplotlib.font_manager - INFO - generated new fontManager
2025-05-01 04:27:23,463 - freqtrade.resolvers.iresolver - INFO - Using resolved freqaimodel XGBoostRegressor from '/freqtrade/freqtrade/freqai/prediction_models/XGBoostRegressor.py'...
2025-05-01 04:27:23,463 - freqtrade.freqai.data_drawer - INFO - Could not find existing datadrawer, starting from scratch
2025-05-01 04:27:23,464 - freqtrade.freqai.data_drawer - INFO - Could not find existing historic_predictions, starting from scratch
2025-05-01 04:27:23,464 - freqtrade.freqai.freqai_interface - INFO - Set fresh train queue from whitelist. Queue: ['BTC/USDT', 'SOL/USDT']
2025-05-01 04:27:23,465 - freqtrade.strategy.hyper - INFO - Strategy Parameter: buy_rsi = 39.92672300850069
2025-05-01 04:27:23,465 - freqtrade.strategy.hyper - INFO - Strategy Parameter: sell_rsi = 69.92672300850067
2025-05-01 04:27:23,466 - freqtrade.strategy.hyper - INFO - No params for protection found, using default values.
2025-05-01 04:27:23,468 - FreqaiExampleStrategy - INFO - 处理交易对BTC/USDT
2025-05-01 04:27:23,470 - freqtrade.freqai.freqai_interface - INFO - Training 2 timeranges
2025-05-01 04:27:23,471 - freqtrade.freqai.freqai_interface - INFO - Training BTC/USDT, 1/2 pairs from 2025-03-02 00:00:00 to 2025-04-01 00:00:00, 1/2 trains
2025-05-01 04:27:23,471 - freqtrade.freqai.data_kitchen - INFO - Could not find backtesting prediction file at
/freqtrade/user_data/models/test175/backtesting_predictions/cb_btc_1743465600_prediction.feather
2025-04-29 07:44:24,576 - freqtrade.data.dataprovider - INFO - Increasing startup_candle_count for freqai on 5m to 8690
2025-04-29 07:44:24,577 - freqtrade.data.dataprovider - INFO - Loading data for BTC/USDT 5m from 2025-03-01 19:50:00 to 2025-04-20 00:00:00
2025-04-29 07:44:24,646 - freqtrade.data.dataprovider - INFO - Increasing startup_candle_count for freqai on 1h to 770
2025-04-29 07:44:24,647 - freqtrade.data.dataprovider - INFO - Loading data for BTC/USDT 1h from 2025-02-27 22:00:00 to 2025-04-20 00:00:00
2025-04-29 07:44:24,698 - freqtrade.data.dataprovider - INFO - Increasing startup_candle_count for freqai on 3m to 14450
2025-04-29 07:44:24,698 - freqtrade.data.dataprovider - INFO - Loading data for ETH/USDT 3m from 2025-03-01 21:30:00 to 2025-04-20 00:00:00
2025-04-29 07:44:24,786 - freqtrade.data.dataprovider - INFO - Increasing startup_candle_count for freqai on 5m to 8690
2025-04-29 07:44:24,787 - freqtrade.data.dataprovider - INFO - Loading data for ETH/USDT 5m from 2025-03-01 19:50:00 to 2025-04-20 00:00:00
2025-04-29 07:44:24,858 - freqtrade.data.dataprovider - INFO - Increasing startup_candle_count for freqai on 1h to 770
2025-04-29 07:44:24,859 - freqtrade.data.dataprovider - INFO - Loading data for ETH/USDT 1h from 2025-02-27 22:00:00 to 2025-04-20 00:00:00
2025-04-29 07:44:24,907 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对BTC/USDT
2025-04-29 07:44:24,912 - FreqaiExampleStrategy - INFO - 目标列形状(14450,)
2025-04-29 07:44:24,914 - FreqaiExampleStrategy - INFO - 目标列预览
2025-05-01 04:27:23,486 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:23,502 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:23,519 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:23,570 - freqtrade.data.dataprovider - INFO - Increasing startup_candle_count for freqai on 5m to 8690
2025-05-01 04:27:23,571 - freqtrade.data.dataprovider - INFO - Loading data for BTC/USDT 5m from 2025-03-01 19:50:00 to 2025-04-20 00:00:00
2025-05-01 04:27:23,623 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:23,635 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:23,647 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:23,688 - freqtrade.data.dataprovider - INFO - Increasing startup_candle_count for freqai on 1h to 770
2025-05-01 04:27:23,689 - freqtrade.data.dataprovider - INFO - Loading data for BTC/USDT 1h from 2025-02-27 22:00:00 to 2025-04-20 00:00:00
2025-05-01 04:27:23,711 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:23,721 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:23,729 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:23,803 - freqtrade.data.dataprovider - INFO - Increasing startup_candle_count for freqai on 3m to 14450
2025-05-01 04:27:23,804 - freqtrade.data.dataprovider - INFO - Loading data for ETH/USDT 3m from 2025-03-01 21:30:00 to 2025-04-20 00:00:00
2025-05-01 04:27:23,869 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:23,884 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:23,901 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:23,965 - freqtrade.data.dataprovider - INFO - Increasing startup_candle_count for freqai on 5m to 8690
2025-05-01 04:27:23,965 - freqtrade.data.dataprovider - INFO - Loading data for ETH/USDT 5m from 2025-03-01 19:50:00 to 2025-04-20 00:00:00
2025-05-01 04:27:24,005 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:24,016 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:24,027 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:24,081 - freqtrade.data.dataprovider - INFO - Increasing startup_candle_count for freqai on 1h to 770
2025-05-01 04:27:24,082 - freqtrade.data.dataprovider - INFO - Loading data for ETH/USDT 1h from 2025-02-27 22:00:00 to 2025-04-20 00:00:00
2025-05-01 04:27:24,104 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:24,113 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:24,122 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:24,176 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对BTC/USDT
2025-05-01 04:27:24,182 - FreqaiExampleStrategy - INFO - 目标列形状:(14450,)
2025-05-01 04:27:24,185 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.007116 50.010488
1 0.005291 50.010488
2 0.004416 50.010488
3 0.002082 50.010488
4 0.001904 50.010488
2025-04-29 07:44:24,917 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对BTC/USDT
2025-04-29 07:44:24,922 - FreqaiExampleStrategy - INFO - 目标列形状(19250,)
2025-04-29 07:44:24,924 - FreqaiExampleStrategy - INFO - 目标列预览
2025-05-01 04:27:24,192 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对BTC/USDT
2025-05-01 04:27:24,198 - FreqaiExampleStrategy - INFO - 目标列形状:(19250,)
2025-05-01 04:27:24,200 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.007116 49.846666
1 0.005291 49.846666
2 0.004416 49.846666
3 0.002082 49.846666
4 0.001904 49.846666
2025-04-29 07:44:24,928 - freqtrade.freqai.freqai_interface - INFO - Could not find model at /freqtrade/user_data/models/test175/sub-train-BTC_1743465600/cb_btc_1743465600
2025-04-29 07:44:24,929 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Starting training BTC/USDT --------------------
2025-04-29 07:44:24,947 - freqtrade.freqai.data_kitchen - INFO - BTC/USDT: dropped 0 training points due to NaNs in populated dataset 14400.
2025-04-29 07:44:24,948 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Training on data from 2025-03-02 to 2025-03-31 --------------------
2025-04-29 07:44:24,963 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 75 features
2025-04-29 07:44:24,963 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 11520 data points
/home/ftuser/.local/lib/python3.12/site-packages/xgboost/core.py:158: UserWarning: [07:44:25] WARNING: /workspace/src/learner.cc:740:
2025-05-01 04:27:24,211 - freqtrade.freqai.freqai_interface - INFO - Could not find model at /freqtrade/user_data/models/test175/sub-train-BTC_1743465600/cb_btc_1743465600
2025-05-01 04:27:24,212 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Starting training BTC/USDT --------------------
2025-05-01 04:27:24,234 - freqtrade.freqai.data_kitchen - INFO - BTC/USDT: dropped 0 training points due to NaNs in populated dataset 14400.
2025-05-01 04:27:24,235 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Training on data from 2025-03-02 to 2025-03-31 --------------------
2025-05-01 04:27:24,253 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 75 features
2025-05-01 04:27:24,254 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 11520 data points
/home/ftuser/.local/lib/python3.12/site-packages/xgboost/core.py:158: UserWarning: [04:27:24] WARNING: /workspace/src/learner.cc:740:
Parameters: { "verbose" } are not used.
warnings.warn(smsg, UserWarning)
[99] validation_0-rmse:0.13679 validation_1-rmse:0.11901
2025-04-29 07:44:25,735 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Done training BTC/USDT (0.81 secs) --------------------
2025-05-01 04:27:26,288 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Done training BTC/USDT (2.08 secs) --------------------
/home/ftuser/.local/lib/python3.12/site-packages/xgboost/core.py:158: UserWarning:
[07:44:25] WARNING: /workspace/src/learner.cc:740:
[04:27:26] WARNING: /workspace/src/learner.cc:740:
Parameters: { "verbose" } are not used.
2025-04-29 07:44:25,961 - freqtrade.plot.plotting - INFO - Stored plot as /freqtrade/user_data/models/test175/sub-train-BTC_1743465600/cb_btc_1743465600--buy_rsi.html
2025-04-29 07:44:25,962 - freqtrade.freqai.freqai_interface - INFO - Saving metadata to disk.
2025-04-29 07:44:25,985 - datasieve.pipeline - WARNING - Could not find step di in pipeline, returning None
2025-04-29 07:44:25,993 - freqtrade.freqai.freqai_interface - INFO - Training BTC/USDT, 1/2 pairs from 2025-03-12 00:00:00 to 2025-04-11 00:00:00, 2/2 trains
2025-04-29 07:44:25,993 - freqtrade.freqai.data_kitchen - INFO - Could not find backtesting prediction file at
2025-05-01 04:27:26,516 - freqtrade.plot.plotting - INFO - Stored plot as /freqtrade/user_data/models/test175/sub-train-BTC_1743465600/cb_btc_1743465600--buy_rsi.html
2025-05-01 04:27:26,517 - freqtrade.freqai.freqai_interface - INFO - Saving metadata to disk.
2025-05-01 04:27:26,539 - datasieve.pipeline - WARNING - Could not find step di in pipeline, returning None
2025-05-01 04:27:26,546 - freqtrade.freqai.freqai_interface - INFO - Training BTC/USDT, 1/2 pairs from 2025-03-12 00:00:00 to 2025-04-11 00:00:00, 2/2 trains
2025-05-01 04:27:26,547 - freqtrade.freqai.data_kitchen - INFO - Could not find backtesting prediction file at
/freqtrade/user_data/models/test175/backtesting_predictions/cb_btc_1744329600_prediction.feather
2025-04-29 07:44:25,996 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对BTC/USDT
2025-04-29 07:44:26,001 - FreqaiExampleStrategy - INFO - 目标列形状:(19250,)
2025-04-29 07:44:26,003 - FreqaiExampleStrategy - INFO - 目标列预览:
2025-05-01 04:27:26,553 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对BTC/USDT
2025-05-01 04:27:26,559 - FreqaiExampleStrategy - INFO - 目标列形状:(19250,)
2025-05-01 04:27:26,560 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.007116 49.846666
1 0.005291 49.846666
2 0.004416 49.846666
3 0.002082 49.846666
4 0.001904 49.846666
2025-04-29 07:44:26,007 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对BTC/USDT
2025-04-29 07:44:26,013 - FreqaiExampleStrategy - INFO - 目标列形状:(23570,)
2025-04-29 07:44:26,015 - FreqaiExampleStrategy - INFO - 目标列预览:
2025-05-01 04:27:26,570 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对BTC/USDT
2025-05-01 04:27:26,576 - FreqaiExampleStrategy - INFO - 目标列形状:(23570,)
2025-05-01 04:27:26,577 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.007116 50.074781
1 0.005291 50.074781
2 0.004416 50.074781
3 0.002082 50.074781
4 0.001904 50.074781
2025-04-29 07:44:26,019 - freqtrade.freqai.freqai_interface - INFO - Could not find model at /freqtrade/user_data/models/test175/sub-train-BTC_1744329600/cb_btc_1744329600
2025-04-29 07:44:26,020 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Starting training BTC/USDT --------------------
2025-04-29 07:44:26,040 - freqtrade.freqai.data_kitchen - INFO - BTC/USDT: dropped 0 training points due to NaNs in populated dataset 14400.
2025-04-29 07:44:26,040 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Training on data from 2025-03-12 to 2025-04-10 --------------------
2025-04-29 07:44:26,055 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 75 features
2025-04-29 07:44:26,056 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 11520 data points
2025-05-01 04:27:26,585 - freqtrade.freqai.freqai_interface - INFO - Could not find model at /freqtrade/user_data/models/test175/sub-train-BTC_1744329600/cb_btc_1744329600
2025-05-01 04:27:26,585 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Starting training BTC/USDT --------------------
2025-05-01 04:27:26,603 - freqtrade.freqai.data_kitchen - INFO - BTC/USDT: dropped 0 training points due to NaNs in populated dataset 14400.
2025-05-01 04:27:26,603 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Training on data from 2025-03-12 to 2025-04-10 --------------------
2025-05-01 04:27:26,621 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 75 features
2025-05-01 04:27:26,621 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 11520 data points
/home/ftuser/.local/lib/python3.12/site-packages/xgboost/core.py:158: UserWarning:
[07:44:26] WARNING: /workspace/src/learner.cc:740:
[04:27:26] WARNING: /workspace/src/learner.cc:740:
Parameters: { "verbose" } are not used.
[99] validation_0-rmse:0.13376 validation_1-rmse:0.11638
2025-04-29 07:44:26,827 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Done training BTC/USDT (0.81 secs) --------------------
2025-04-29 07:44:26,867 - freqtrade.plot.plotting - INFO - Stored plot as /freqtrade/user_data/models/test175/sub-train-BTC_1744329600/cb_btc_1744329600--buy_rsi.html
2025-04-29 07:44:26,868 - freqtrade.freqai.freqai_interface - INFO - Saving metadata to disk.
2025-04-29 07:44:26,886 - datasieve.pipeline - WARNING - Could not find step di in pipeline, returning None
2025-04-29 07:44:26,923 - FreqaiExampleStrategy - INFO - 动态参数buy_rsi=39.26145316407591, sell_rsi=59.26145316407591, stoploss=-0.15, trailing_stop_positive=0.05
2025-04-29 07:44:26,930 - FreqaiExampleStrategy - INFO - up_or_down 值统计:
2025-05-01 04:27:28,783 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Done training BTC/USDT (2.20 secs) --------------------
/home/ftuser/.local/lib/python3.12/site-packages/xgboost/core.py:158: UserWarning:
[04:27:28] WARNING: /workspace/src/learner.cc:740:
Parameters: { "verbose" } are not used.
2025-05-01 04:27:28,818 - freqtrade.plot.plotting - INFO - Stored plot as /freqtrade/user_data/models/test175/sub-train-BTC_1744329600/cb_btc_1744329600--buy_rsi.html
2025-05-01 04:27:28,818 - freqtrade.freqai.freqai_interface - INFO - Saving metadata to disk.
2025-05-01 04:27:28,840 - datasieve.pipeline - WARNING - Could not find step di in pipeline, returning None
2025-05-01 04:27:28,899 - FreqaiExampleStrategy - INFO - 动态参数buy_rsi=39.26145316407591, sell_rsi=59.26145316407591, stoploss=-0.15, trailing_stop_positive=0.05
2025-05-01 04:27:28,943 - FreqaiExampleStrategy - INFO - up_or_down 值统计:
up_or_down
1 11845
0 11726
2025-04-29 07:44:26,931 - FreqaiExampleStrategy - INFO - do_predict 值统计:
2025-05-01 04:27:28,944 - FreqaiExampleStrategy - INFO - do_predict 值统计:
do_predict
0.0 14451
1.0 9120
2025-04-29 07:44:26,933 - FreqaiExampleStrategy - INFO - 处理交易对SOL/USDT
2025-04-29 07:44:26,934 - freqtrade.freqai.freqai_interface - INFO - Training 2 timeranges
2025-04-29 07:44:26,935 - freqtrade.freqai.freqai_interface - INFO - Training SOL/USDT, 2/2 pairs from 2025-03-02 00:00:00 to 2025-04-01 00:00:00, 1/2 trains
2025-04-29 07:44:26,935 - freqtrade.freqai.data_kitchen - INFO - Could not find backtesting prediction file at
2025-05-01 04:27:28,947 - FreqaiExampleStrategy - INFO - 处理交易对SOL/USDT
2025-05-01 04:27:28,949 - freqtrade.freqai.freqai_interface - INFO - Training 2 timeranges
2025-05-01 04:27:28,950 - freqtrade.freqai.freqai_interface - INFO - Training SOL/USDT, 2/2 pairs from 2025-03-02 00:00:00 to 2025-04-01 00:00:00, 1/2 trains
2025-05-01 04:27:28,951 - freqtrade.freqai.data_kitchen - INFO - Could not find backtesting prediction file at
/freqtrade/user_data/models/test175/backtesting_predictions/cb_sol_1743465600_prediction.feather
2025-04-29 07:44:26,959 - freqtrade.data.dataprovider - INFO - Increasing startup_candle_count for freqai on 5m to 8690
2025-04-29 07:44:26,959 - freqtrade.data.dataprovider - INFO - Loading data for SOL/USDT 5m from 2025-03-01 19:50:00 to 2025-04-20 00:00:00
2025-04-29 07:44:27,020 - freqtrade.data.dataprovider - INFO - Increasing startup_candle_count for freqai on 1h to 770
2025-04-29 07:44:27,020 - freqtrade.data.dataprovider - INFO - Loading data for SOL/USDT 1h from 2025-02-27 22:00:00 to 2025-04-20 00:00:00
2025-04-29 07:44:27,068 - freqtrade.data.dataprovider - INFO - Increasing startup_candle_count for freqai on 3m to 14450
2025-04-29 07:44:27,068 - freqtrade.data.dataprovider - INFO - Loading data for BTC/USDT 3m from 2025-03-01 21:30:00 to 2025-04-20 00:00:00
2025-04-29 07:44:27,332 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对SOL/USDT
2025-04-29 07:44:27,337 - FreqaiExampleStrategy - INFO - 目标列形状(14450,)
2025-04-29 07:44:27,339 - FreqaiExampleStrategy - INFO - 目标列预览
2025-05-01 04:27:28,962 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:28,974 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:28,988 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:29,022 - freqtrade.data.dataprovider - INFO - Increasing startup_candle_count for freqai on 5m to 8690
2025-05-01 04:27:29,022 - freqtrade.data.dataprovider - INFO - Loading data for SOL/USDT 5m from 2025-03-01 19:50:00 to 2025-04-20 00:00:00
2025-05-01 04:27:29,075 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:29,086 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:29,097 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:29,128 - freqtrade.data.dataprovider - INFO - Increasing startup_candle_count for freqai on 1h to 770
2025-05-01 04:27:29,129 - freqtrade.data.dataprovider - INFO - Loading data for SOL/USDT 1h from 2025-02-27 22:00:00 to 2025-04-20 00:00:00
2025-05-01 04:27:29,151 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:29,159 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:29,168 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:29,228 - freqtrade.data.dataprovider - INFO - Increasing startup_candle_count for freqai on 3m to 14450
2025-05-01 04:27:29,229 - freqtrade.data.dataprovider - INFO - Loading data for BTC/USDT 3m from 2025-03-01 21:30:00 to 2025-04-20 00:00:00
2025-05-01 04:27:29,283 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:29,296 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:29,310 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:29,367 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:29,378 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:29,388 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:29,442 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:29,451 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:29,459 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:29,535 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:29,548 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:29,561 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:29,630 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:29,640 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:29,651 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:29,735 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:29,743 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:29,751 - FreqaiExampleStrategy - INFO - 特征工程完成特征数量13
2025-05-01 04:27:29,827 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对SOL/USDT
2025-05-01 04:27:29,832 - FreqaiExampleStrategy - INFO - 目标列形状:(14450,)
2025-05-01 04:27:29,834 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.016595 49.72136
1 0.012811 49.72136
2 0.010135 49.72136
3 0.008514 49.72136
4 0.006242 49.72136
2025-04-29 07:44:27,342 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对SOL/USDT
2025-04-29 07:44:27,347 - FreqaiExampleStrategy - INFO - 目标列形状(19250,)
2025-04-29 07:44:27,349 - FreqaiExampleStrategy - INFO - 目标列预览
2025-05-01 04:27:29,844 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对SOL/USDT
2025-05-01 04:27:29,850 - FreqaiExampleStrategy - INFO - 目标列形状:(19250,)
2025-05-01 04:27:29,851 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.016595 49.562407
1 0.012811 49.562407
2 0.010135 49.562407
3 0.008514 49.562407
4 0.006242 49.562407
2025-04-29 07:44:27,353 - freqtrade.freqai.freqai_interface - INFO - Could not find model at /freqtrade/user_data/models/test175/sub-train-SOL_1743465600/cb_sol_1743465600
2025-04-29 07:44:27,354 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Starting training SOL/USDT --------------------
2025-04-29 07:44:27,378 - freqtrade.freqai.data_kitchen - INFO - SOL/USDT: dropped 0 training points due to NaNs in populated dataset 14400.
2025-04-29 07:44:27,379 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Training on data from 2025-03-02 to 2025-03-31 --------------------
2025-04-29 07:44:27,402 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 111 features
2025-04-29 07:44:27,402 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 11520 data points
2025-05-01 04:27:29,863 - freqtrade.freqai.freqai_interface - INFO - Could not find model at /freqtrade/user_data/models/test175/sub-train-SOL_1743465600/cb_sol_1743465600
2025-05-01 04:27:29,864 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Starting training SOL/USDT --------------------
2025-05-01 04:27:29,893 - freqtrade.freqai.data_kitchen - INFO - SOL/USDT: dropped 0 training points due to NaNs in populated dataset 14400.
2025-05-01 04:27:29,894 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Training on data from 2025-03-02 to 2025-03-31 --------------------
2025-05-01 04:27:29,919 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 111 features
2025-05-01 04:27:29,919 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 11520 data points
/home/ftuser/.local/lib/python3.12/site-packages/xgboost/core.py:158: UserWarning:
[07:44:27] WARNING: /workspace/src/learner.cc:740:
[04:27:30] WARNING: /workspace/src/learner.cc:740:
Parameters: { "verbose" } are not used.
[99] validation_0-rmse:0.11848 validation_1-rmse:0.10165
2025-04-29 07:44:28,610 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Done training SOL/USDT (1.26 secs) --------------------
2025-05-01 04:27:33,175 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Done training SOL/USDT (3.31 secs) --------------------
/home/ftuser/.local/lib/python3.12/site-packages/xgboost/core.py:158: UserWarning:
[07:44:28] WARNING: /workspace/src/learner.cc:740:
[04:27:33] WARNING: /workspace/src/learner.cc:740:
Parameters: { "verbose" } are not used.
2025-04-29 07:44:28,642 - freqtrade.plot.plotting - INFO - Stored plot as /freqtrade/user_data/models/test175/sub-train-SOL_1743465600/cb_sol_1743465600--buy_rsi.html
2025-04-29 07:44:28,643 - freqtrade.freqai.freqai_interface - INFO - Saving metadata to disk.
2025-04-29 07:44:28,668 - datasieve.pipeline - WARNING - Could not find step di in pipeline, returning None
2025-04-29 07:44:28,675 - freqtrade.freqai.freqai_interface - INFO - Training SOL/USDT, 2/2 pairs from 2025-03-12 00:00:00 to 2025-04-11 00:00:00, 2/2 trains
2025-04-29 07:44:28,675 - freqtrade.freqai.data_kitchen - INFO - Could not find backtesting prediction file at
2025-05-01 04:27:33,208 - freqtrade.plot.plotting - INFO - Stored plot as /freqtrade/user_data/models/test175/sub-train-SOL_1743465600/cb_sol_1743465600--buy_rsi.html
2025-05-01 04:27:33,209 - freqtrade.freqai.freqai_interface - INFO - Saving metadata to disk.
2025-05-01 04:27:33,246 - datasieve.pipeline - WARNING - Could not find step di in pipeline, returning None
2025-05-01 04:27:33,254 - freqtrade.freqai.freqai_interface - INFO - Training SOL/USDT, 2/2 pairs from 2025-03-12 00:00:00 to 2025-04-11 00:00:00, 2/2 trains
2025-05-01 04:27:33,255 - freqtrade.freqai.data_kitchen - INFO - Could not find backtesting prediction file at
/freqtrade/user_data/models/test175/backtesting_predictions/cb_sol_1744329600_prediction.feather
2025-04-29 07:44:28,679 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对SOL/USDT
2025-04-29 07:44:28,684 - FreqaiExampleStrategy - INFO - 目标列形状:(19250,)
2025-04-29 07:44:28,685 - FreqaiExampleStrategy - INFO - 目标列预览:
2025-05-01 04:27:33,265 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对SOL/USDT
2025-05-01 04:27:33,270 - FreqaiExampleStrategy - INFO - 目标列形状:(19250,)
2025-05-01 04:27:33,272 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.016595 49.562407
1 0.012811 49.562407
2 0.010135 49.562407
3 0.008514 49.562407
4 0.006242 49.562407
2025-04-29 07:44:28,690 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对SOL/USDT
2025-04-29 07:44:28,696 - FreqaiExampleStrategy - INFO - 目标列形状:(23570,)
2025-04-29 07:44:28,697 - FreqaiExampleStrategy - INFO - 目标列预览:
2025-05-01 04:27:33,283 - FreqaiExampleStrategy - INFO - 设置 FreqAI 目标交易对SOL/USDT
2025-05-01 04:27:33,289 - FreqaiExampleStrategy - INFO - 目标列形状:(23570,)
2025-05-01 04:27:33,290 - FreqaiExampleStrategy - INFO - 目标列预览:
up_or_down &-buy_rsi
0 0.016595 49.934347
1 0.012811 49.934347
2 0.010135 49.934347
3 0.008514 49.934347
4 0.006242 49.934347
2025-04-29 07:44:28,702 - freqtrade.freqai.freqai_interface - INFO - Could not find model at /freqtrade/user_data/models/test175/sub-train-SOL_1744329600/cb_sol_1744329600
2025-04-29 07:44:28,703 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Starting training SOL/USDT --------------------
2025-04-29 07:44:28,727 - freqtrade.freqai.data_kitchen - INFO - SOL/USDT: dropped 0 training points due to NaNs in populated dataset 14400.
2025-04-29 07:44:28,728 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Training on data from 2025-03-12 to 2025-04-10 --------------------
2025-04-29 07:44:28,750 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 111 features
2025-04-29 07:44:28,751 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 11520 data points
2025-05-01 04:27:33,300 - freqtrade.freqai.freqai_interface - INFO - Could not find model at /freqtrade/user_data/models/test175/sub-train-SOL_1744329600/cb_sol_1744329600
2025-05-01 04:27:33,300 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Starting training SOL/USDT --------------------
2025-05-01 04:27:33,322 - freqtrade.freqai.data_kitchen - INFO - SOL/USDT: dropped 0 training points due to NaNs in populated dataset 14400.
2025-05-01 04:27:33,323 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Training on data from 2025-03-12 to 2025-04-10 --------------------
2025-05-01 04:27:33,349 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 111 features
2025-05-01 04:27:33,349 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - Training model on 11520 data points
/home/ftuser/.local/lib/python3.12/site-packages/xgboost/core.py:158: UserWarning:
[07:44:28] WARNING: /workspace/src/learner.cc:740:
[04:27:33] WARNING: /workspace/src/learner.cc:740:
Parameters: { "verbose" } are not used.
[99] validation_0-rmse:0.12679 validation_1-rmse:0.11178
2025-04-29 07:44:29,926 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Done training SOL/USDT (1.22 secs) --------------------
2025-05-01 04:27:36,303 - freqtrade.freqai.base_models.BaseRegressionModel - INFO - -------------------- Done training SOL/USDT (3.00 secs) --------------------
/home/ftuser/.local/lib/python3.12/site-packages/xgboost/core.py:158: UserWarning:
[07:44:29] WARNING: /workspace/src/learner.cc:740:
[04:27:36] WARNING: /workspace/src/learner.cc:740:
Parameters: { "verbose" } are not used.
2025-04-29 07:44:29,964 - freqtrade.plot.plotting - INFO - Stored plot as /freqtrade/user_data/models/test175/sub-train-SOL_1744329600/cb_sol_1744329600--buy_rsi.html
2025-04-29 07:44:29,964 - freqtrade.freqai.freqai_interface - INFO - Saving metadata to disk.
2025-04-29 07:44:29,989 - datasieve.pipeline - WARNING - Could not find step di in pipeline, returning None
2025-04-29 07:44:30,034 - FreqaiExampleStrategy - INFO - 动态参数buy_rsi=50.0, sell_rsi=70.0, stoploss=-0.15, trailing_stop_positive=0.05
2025-04-29 07:44:30,041 - FreqaiExampleStrategy - INFO - up_or_down 值统计:
2025-05-01 04:27:36,337 - freqtrade.plot.plotting - INFO - Stored plot as /freqtrade/user_data/models/test175/sub-train-SOL_1744329600/cb_sol_1744329600--buy_rsi.html
2025-05-01 04:27:36,338 - freqtrade.freqai.freqai_interface - INFO - Saving metadata to disk.
2025-05-01 04:27:36,372 - datasieve.pipeline - WARNING - Could not find step di in pipeline, returning None
2025-05-01 04:27:36,441 - FreqaiExampleStrategy - INFO - 动态参数buy_rsi=50.0, sell_rsi=70.0, stoploss=-0.15, trailing_stop_positive=0.05
2025-05-01 04:27:36,503 - FreqaiExampleStrategy - INFO - up_or_down 值统计:
up_or_down
0 11865
1 11706
2025-04-29 07:44:30,043 - FreqaiExampleStrategy - INFO - do_predict 值统计:
2025-05-01 04:27:36,504 - FreqaiExampleStrategy - INFO - do_predict 值统计:
do_predict
0.0 14451
1.0 9120
2025-04-29 07:44:30,046 - freqtrade.optimize.backtesting - INFO - Backtesting with data from 2025-04-01 00:00:00 up to 2025-04-20 00:00:00 (19 days).
2025-04-29 07:44:30,047 - FreqaiExampleStrategy - ERROR - MACD 或 MACD 信号列缺失,无法生成买入信号。尝试重新计算 MACD 列。
2025-04-29 07:44:30,049 - FreqaiExampleStrategy - INFO - MACD 列已成功重新计算。
2025-04-29 07:44:30,066 - FreqaiExampleStrategy - ERROR - MACD 或 MACD 信号列缺失,无法生成买入信号。尝试重新计算 MACD 列。
2025-04-29 07:44:30,067 - FreqaiExampleStrategy - INFO - MACD 列已成功重新计算。
2025-04-29 07:44:30,639 - freqtrade.misc - INFO - dumping json to "/freqtrade/user_data/backtest_results/backtest-result-2025-04-29_07-44-30.meta.json"
2025-05-01 04:27:36,512 - freqtrade.optimize.backtesting - INFO - Backtesting with data from 2025-04-01 00:00:00 up to 2025-04-20 00:00:00 (19 days).
2025-05-01 04:27:36,517 - FreqaiExampleStrategy - ERROR - MACD 或 MACD 信号列缺失,无法生成买入信号。尝试重新计算 MACD 列。
2025-05-01 04:27:36,519 - FreqaiExampleStrategy - INFO - MACD 列已成功重新计算。
2025-05-01 04:27:36,549 - FreqaiExampleStrategy - ERROR - MACD 或 MACD 信号列缺失,无法生成买入信号。尝试重新计算 MACD 列。
2025-05-01 04:27:36,551 - FreqaiExampleStrategy - INFO - MACD 列已成功重新计算。
2025-05-01 04:27:37,138 - freqtrade.misc - INFO - dumping json to "/freqtrade/user_data/backtest_results/backtest-result-2025-05-01_04-27-37.meta.json"
Result for strategy FreqaiExampleStrategy
 BACKTESTING REPORT 
BACKTESTING REPORT
┏━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┓
  Pair  Trades  Avg Profit %  Tot Profit USDT  Tot Profit %  Avg Duration   Win Draw Loss Win% 
┃ Pair ┃ Trades ┃ Avg Profit % ┃ Tot Profit USDT ┃ Tot Profit % ┃ Avg Duration ┃ Win Draw Loss Win% ┃
┡━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━┩
│ BTC/USDT │ 17 │ 0.03 │ 0.801 │ 0.08 │ 11:49:00 │ 2 15 0 100 │
│ SOL/USDT │ 13 │ -0.93 │ -18.095 │ -1.81 │ 8:54:00 │ 5 7 1 38.5 │
│ TOTAL │ 30 │ -0.38 │ -17.294 │ -1.73 │ 10:34:00 │ 7 22 1 23.3 │
└──────────┴────────┴──────────────┴─────────────────┴──────────────┴──────────────┴────────────────────────┘
 LEFT OPEN TRADES REPORT 
LEFT OPEN TRADES REPORT
┏━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┓
  Pair  Trades  Avg Profit %  Tot Profit USDT  Tot Profit %  Avg Duration   Win Draw Loss Win% 
┃ Pair ┃ Trades ┃ Avg Profit % ┃ Tot Profit USDT ┃ Tot Profit % ┃ Avg Duration ┃ Win Draw Loss Win% ┃
┡━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━┩
│ TOTAL │ 0 │ 0.0 │ 0.000 │ 0.0 │ 0:00 │ 0 0 0 0 │
└───────┴────────┴──────────────┴─────────────────┴──────────────┴──────────────┴────────────────────────┘
 ENTER TAG STATS 
ENTER TAG STATS
┏━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┓
 Enter Tag  Entries  Avg Profit %  Tot Profit USDT  Tot Profit %  Avg Duration   Win Draw Loss Win% 
┃ Enter Tag ┃ Entries ┃ Avg Profit % ┃ Tot Profit USDT ┃ Tot Profit % ┃ Avg Duration ┃ Win Draw Loss Win% ┃
┡━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━┩
│ long │ 30 │ -0.38 │ -17.294 │ -1.73 │ 10:34:00 │ 7 22 1 23.3 │
│ TOTAL │ 30 │ -0.38 │ -17.294 │ -1.73 │ 10:34:00 │ 7 22 1 23.3 │
└───────────┴─────────┴──────────────┴─────────────────┴──────────────┴──────────────┴────────────────────────┘
 EXIT REASON STATS 
EXIT REASON STATS
┏━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┓
  Exit Reason  Exits  Avg Profit %  Tot Profit USDT  Tot Profit %   Avg Duration   Win Draw Loss Win% 
┃ Exit Reason ┃ Exits ┃ Avg Profit % ┃ Tot Profit USDT ┃ Tot Profit % ┃ Avg Duration ┃ Win Draw Loss Win% ┃
┡━━━━━━━━━━━━━━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━┩
│ roi │ 29 │ 0.12 │ 5.235 │ 0.52 │ 9:21:00 │ 7 22 0 100 │
│ trailing_stop_loss │ 1 │ -15.0 │ -22.529 │ -2.25 │ 1 day, 21:45:00 │ 0 0 1 0 │
│ TOTAL │ 30 │ -0.38 │ -17.294 │ -1.73 │ 10:34:00 │ 7 22 1 23.3 │
└────────────────────┴───────┴──────────────┴─────────────────┴──────────────┴─────────────────┴────────────────────────┘
 MIXED TAG STATS 
MIXED TAG STATS
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┓
  Enter Tag  Exit Reason  Trades  Avg Profit %  Tot Profit USDT  Tot Profit %   Avg Duration   Win Draw Loss Win% 
┃ Enter Tag ┃ Exit Reason ┃ Trades ┃ Avg Profit % ┃ Tot Profit USDT ┃ Tot Profit % ┃ Avg Duration ┃ Win Draw Loss Win% ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━┩
│ ('long', 'roi') │ │ 29 │ 0.12 │ 5.235 │ 0.52 │ 9:21:00 │ 7 22 0 100 │
│ ('long', 'trailing_stop_loss') │ │ 1 │ -15.0 │ -22.529 │ -2.25 │ 1 day, 21:45:00 │ 0 0 1 0 │
│ TOTAL │ │ 30 │ -0.38 │ -17.294 │ -1.73 │ 10:34:00 │ 7 22 1 23.3 │
└────────────────────────────────┴─────────────┴────────┴──────────────┴─────────────────┴──────────────┴─────────────────┴────────────────────────┘
 SUMMARY METRICS 
SUMMARY METRICS
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
 Metric   Value  
┃ Metric ┃ Value ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ Backtesting from │ 2025-04-01 00:00:00 │
│ Backtesting to │ 2025-04-20 00:00:00 │
@ -378,9 +428,9 @@ Result for strategy FreqaiExampleStrategy
└─────────────────────────────┴─────────────────────┘
Backtested 2025-04-01 00:00:00 -> 2025-04-20 00:00:00 | Max open trades : 2
 STRATEGY SUMMARY 
STRATEGY SUMMARY
┏━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┓
  Strategy  Trades  Avg Profit %  Tot Profit USDT  Tot Profit %  Avg Duration   Win Draw Loss Win%   Drawdown 
┃ Strategy ┃ Trades ┃ Avg Profit % ┃ Tot Profit USDT ┃ Tot Profit % ┃ Avg Duration ┃ Win Draw Loss Win% ┃ Drawdown ┃
┡━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━┩
│ FreqaiExampleStrategy │ 30 │ -0.38 │ -17.294 │ -1.73 │ 10:34:00 │ 7 22 1 23.3 │ 22.529 USDT 2.25% │
└───────────────────────┴────────┴──────────────┴─────────────────┴──────────────┴──────────────┴────────────────────────┴────────────────────┘

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
{"FreqaiExampleStrategy":{"run_id":"503e73c282d0ca15563ac9a0a92479d87ab89671","backtest_start_time":1746073641,"timeframe":"3m","timeframe_detail":null,"backtest_start_ts":1743465600,"backtest_end_ts":1745107200}}

Binary file not shown.

View File

@ -0,0 +1,32 @@
{
"strategy_name": "FreqaiExampleStrategy",
"params": {
"trailing": {
"trailing_stop": true,
"trailing_stop_positive": 0.01,
"trailing_stop_positive_offset": 0.02,
"trailing_only_offset_is_reached": false
},
"max_open_trades": {
"max_open_trades": 4
},
"buy": {
"buy_rsi": 39.92672300850069
},
"sell": {
"sell_rsi": 69.92672300850067
},
"protection": {},
"roi": {
"0": 0.132,
"8": 0.047,
"14": 0.007,
"60": 0
},
"stoploss": {
"stoploss": -0.322
}
},
"ft_stratparam_v": 1,
"export_time": "2025-04-23 12:30:05.550433+00:00"
}

View File

@ -0,0 +1,336 @@
import logging
import numpy as np
from functools import reduce
import talib.abstract as ta
from pandas import DataFrame
from technical import qtpylib
from freqtrade.strategy import IStrategy, IntParameter, DecimalParameter
logger = logging.getLogger(__name__)
class FreqaiExampleStrategy(IStrategy):
# 移除硬编码的 minimal_roi 和 stoploss改为动态适配
minimal_roi = {} # 将在 populate_indicators 中动态生成
stoploss = 0.0 # 将在 populate_indicators 中动态设置
trailing_stop = True
process_only_new_candles = True
use_exit_signal = True
startup_candle_count: int = 40
can_short = False
# 参数定义FreqAI 动态适配 buy_rsi 和 sell_rsi禁用 Hyperopt 优化
buy_rsi = IntParameter(low=10, high=50, default=27, space="buy", optimize=False, load=True)
sell_rsi = IntParameter(low=50, high=90, default=59, space="sell", optimize=False, load=True)
# 为 Hyperopt 优化添加 ROI 和 stoploss 参数
roi_0 = DecimalParameter(low=0.01, high=0.2, default=0.038, space="roi", optimize=True, load=True)
roi_15 = DecimalParameter(low=0.005, high=0.1, default=0.027, space="roi", optimize=True, load=True)
roi_30 = DecimalParameter(low=0.001, high=0.05, default=0.009, space="roi", optimize=True, load=True)
stoploss_param = DecimalParameter(low=-0.35, high=-0.1, default=-0.182, space="stoploss", optimize=True, load=True)
# FreqAI 配置
freqai_info = {
"model": "CatboostClassifier", # 与config保持一致
"feature_parameters": {
"include_timeframes": ["3m", "15m", "1h"], # 与config一致
"include_corr_pairlist": ["BTC/USDT", "SOL/USDT"], # 添加相关交易对
"label_period_candles": 20, # 与config一致
"include_shifted_candles": 2, # 与config一致
},
"data_split_parameters": {
"test_size": 0.2,
"shuffle": True, # 启用shuffle
},
"model_training_parameters": {
"n_estimators": 100, # 减少树的数量
"learning_rate": 0.1, # 提高学习率
"max_depth": 6, # 限制树深度
"subsample": 0.8, # 添加子采样
"colsample_bytree": 0.8, # 添加特征采样
"objective": "reg:squarederror",
"eval_metric": "rmse",
"early_stopping_rounds": 20,
"verbose": 0,
},
"data_kitchen": {
"feature_parameters": {
"DI_threshold": 1.5, # 降低异常值过滤阈值
"use_DBSCAN_to_remove_outliers": False # 禁用DBSCAN
}
}
}
plot_config = {
"main_plot": {},
"subplots": {
"&-buy_rsi": {"&-buy_rsi": {"color": "green"}},
"&-sell_rsi": {"&-sell_rsi": {"color": "red"}},
"&-stoploss": {"&-stoploss": {"color": "purple"}},
"&-roi_0": {"&-roi_0": {"color": "orange"}},
"do_predict": {"do_predict": {"color": "brown"}},
},
}
def feature_engineering_expand_all(self, dataframe: DataFrame, period: int, metadata: dict, **kwargs) -> DataFrame:
# 保留关键的技术指标
dataframe["rsi"] = ta.RSI(dataframe, timeperiod=14)
# 确保 MACD 列被正确计算并保留
try:
macd = ta.MACD(dataframe, fastperiod=12, slowperiod=26, signalperiod=9)
dataframe["macd"] = macd["macd"]
dataframe["macdsignal"] = macd["macdsignal"]
except Exception as e:
logger.error(f"计算 MACD 列时出错:{str(e)}")
dataframe["macd"] = np.nan
dataframe["macdsignal"] = np.nan
# 检查 MACD 列是否存在
if "macd" not in dataframe.columns or "macdsignal" not in dataframe.columns:
logger.error("MACD 或 MACD 信号列缺失,无法生成买入信号")
raise ValueError("DataFrame 缺少必要的 MACD 列")
# 确保 MACD 列存在
if "macd" not in dataframe.columns or "macdsignal" not in dataframe.columns:
logger.error("MACD 或 MACD 信号列缺失,无法生成买入信号")
raise ValueError("DataFrame 缺少必要的 MACD 列")
# 保留布林带相关特征
bollinger = qtpylib.bollinger_bands(qtpylib.typical_price(dataframe), window=20, stds=2)
dataframe["bb_lowerband"] = bollinger["lower"]
dataframe["bb_middleband"] = bollinger["mid"]
dataframe["bb_upperband"] = bollinger["upper"]
# 保留成交量相关特征
dataframe["volume_ma"] = dataframe["volume"].rolling(window=20).mean()
# 数据清理
for col in dataframe.columns:
if dataframe[col].dtype in ["float64", "int64"]:
dataframe[col] = dataframe[col].replace([np.inf, -np.inf], np.nan)
dataframe[col] = dataframe[col].ffill().fillna(0)
logger.info(f"特征工程完成,特征数量:{len(dataframe.columns)}")
return dataframe
def feature_engineering_expand_basic(self, dataframe: DataFrame, metadata: dict, **kwargs) -> DataFrame:
dataframe["%-pct-change"] = dataframe["close"].pct_change()
dataframe["%-raw_volume"] = dataframe["volume"]
dataframe["%-raw_price"] = dataframe["close"]
# 数据清理逻辑
for col in dataframe.columns:
if dataframe[col].dtype in ["float64", "int64"]:
dataframe[col] = dataframe[col].replace([np.inf, -np.inf], 0)
dataframe[col] = dataframe[col].ffill()
dataframe[col] = dataframe[col].fillna(0)
# 检查是否仍有无效值
if dataframe[col].isna().any() or np.isinf(dataframe[col]).any():
logger.warning(f"{col} 仍包含无效值,已填充为默认值")
dataframe[col] = dataframe[col].fillna(0)
return dataframe
def feature_engineering_standard(self, dataframe: DataFrame, metadata: dict, **kwargs) -> DataFrame:
dataframe["%-day_of_week"] = dataframe["date"].dt.dayofweek
dataframe["%-hour_of_day"] = dataframe["date"].dt.hour
dataframe.replace([np.inf, -np.inf], 0, inplace=True)
dataframe.ffill(inplace=True)
dataframe.fillna(0, inplace=True)
return dataframe
def set_freqai_targets(self, dataframe: DataFrame, metadata: dict, **kwargs) -> DataFrame:
logger.info(f"设置 FreqAI 目标,交易对:{metadata['pair']}")
if "close" not in dataframe.columns:
logger.error("数据框缺少必要的 'close'")
raise ValueError("数据框缺少必要的 'close'")
try:
label_period = self.freqai_info["feature_parameters"]["label_period_candles"]
# 定义目标变量为未来价格变化百分比(连续值)
dataframe["up_or_down"] = (
dataframe["close"].shift(-label_period) - dataframe["close"]
) / dataframe["close"]
# 数据清理:处理 NaN 和 Inf 值
dataframe["up_or_down"] = dataframe["up_or_down"].replace([np.inf, -np.inf], np.nan)
dataframe["up_or_down"] = dataframe["up_or_down"].ffill().fillna(0)
# 确保目标变量是二维数组
if dataframe["up_or_down"].ndim == 1:
dataframe["up_or_down"] = dataframe["up_or_down"].values.reshape(-1, 1)
# 检查并处理 NaN 或无限值
dataframe["up_or_down"] = dataframe["up_or_down"].replace([np.inf, -np.inf], np.nan)
dataframe["up_or_down"] = dataframe["up_or_down"].ffill().fillna(0)
# 生成 %-volatility 特征
dataframe["%-volatility"] = dataframe["close"].pct_change().rolling(20).std()
# 确保 &-buy_rsi 列的值计算正确
dataframe["&-buy_rsi"] = ta.RSI(dataframe, timeperiod=14)
# 数据清理
for col in ["&-buy_rsi", "up_or_down", "%-volatility"]:
# 使用直接操作避免链式赋值
dataframe[col] = dataframe[col].replace([np.inf, -np.inf], np.nan)
dataframe[col] = dataframe[col].ffill() # 替代 fillna(method='ffill')
dataframe[col] = dataframe[col].fillna(dataframe[col].mean()) # 使用均值填充 NaN 值
if dataframe[col].isna().any():
logger.warning(f"目标列 {col} 仍包含 NaN填充为默认值")
except Exception as e:
logger.error(f"创建 FreqAI 目标失败:{str(e)}")
raise
# Log the shape of the target variable for debugging
logger.info(f"目标列形状:{dataframe['up_or_down'].shape}")
logger.info(f"目标列预览:\n{dataframe[['up_or_down', '&-buy_rsi']].head().to_string()}")
return dataframe
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
logger.info(f"处理交易对:{metadata['pair']}")
dataframe = self.freqai.start(dataframe, metadata, self)
# 计算传统指标
dataframe["rsi"] = ta.RSI(dataframe, timeperiod=14)
bollinger = qtpylib.bollinger_bands(qtpylib.typical_price(dataframe), window=20, stds=2)
dataframe["bb_lowerband"] = bollinger["lower"]
dataframe["bb_middleband"] = bollinger["mid"]
dataframe["bb_upperband"] = bollinger["upper"]
dataframe["tema"] = ta.TEMA(dataframe, timeperiod=9)
# 生成 up_or_down 信号(非 FreqAI 目标)
label_period = self.freqai_info["feature_parameters"]["label_period_candles"]
# 使用未来价格变化方向生成 up_or_down 信号
label_period = self.freqai_info["feature_parameters"]["label_period_candles"]
dataframe["up_or_down"] = np.where(
dataframe["close"].shift(-label_period) > dataframe["close"], 1, 0
)
# 动态设置参数
if "&-buy_rsi" in dataframe.columns:
# 派生其他目标
dataframe["&-sell_rsi"] = dataframe["&-buy_rsi"] + 30
dataframe["%-volatility"] = dataframe["close"].pct_change().rolling(20).std()
# Ensure proper calculation and handle potential NaN values
dataframe["&-stoploss"] = (-0.1 - (dataframe["%-volatility"] * 10).clip(0, 0.25)).fillna(-0.1)
dataframe["&-roi_0"] = ((dataframe["close"] / dataframe["close"].shift(label_period) - 1).clip(0, 0.2)).fillna(0)
# Additional check to ensure no NaN values remain
for col in ["&-stoploss", "&-roi_0"]:
if dataframe[col].isna().any():
logger.warning(f"{col} 仍包含 NaN填充为默认值")
dataframe[col] = dataframe[col].fillna(-0.1 if col == "&-stoploss" else 0)
# 简化动态参数生成逻辑
# 放松 buy_rsi 和 sell_rsi 的生成逻辑
# 计算 buy_rsi_pred 并清理 NaN 值
dataframe["buy_rsi_pred"] = dataframe["rsi"].rolling(window=10).mean().clip(30, 50)
dataframe["buy_rsi_pred"] = dataframe["buy_rsi_pred"].fillna(dataframe["buy_rsi_pred"].median())
# 计算 sell_rsi_pred 并清理 NaN 值
dataframe["sell_rsi_pred"] = dataframe["buy_rsi_pred"] + 20
dataframe["sell_rsi_pred"] = dataframe["sell_rsi_pred"].fillna(dataframe["sell_rsi_pred"].median())
# 计算 stoploss_pred 并清理 NaN 值
dataframe["stoploss_pred"] = -0.1 - (dataframe["%-volatility"] * 10).clip(0, 0.25)
dataframe["stoploss_pred"] = dataframe["stoploss_pred"].fillna(dataframe["stoploss_pred"].mean())
# 计算 roi_0_pred 并清理 NaN 值
dataframe["roi_0_pred"] = dataframe["&-roi_0"].clip(0.01, 0.2)
dataframe["roi_0_pred"] = dataframe["roi_0_pred"].fillna(dataframe["roi_0_pred"].mean())
# 检查预测值
for col in ["buy_rsi_pred", "sell_rsi_pred", "stoploss_pred", "roi_0_pred", "&-sell_rsi", "&-stoploss", "&-roi_0"]:
if dataframe[col].isna().any():
logger.warning(f"{col} 包含 NaN填充为默认值")
dataframe[col] = dataframe[col].fillna(dataframe[col].mean())
# 更保守的止损和止盈设置
dataframe["trailing_stop_positive"] = (dataframe["roi_0_pred"] * 0.3).clip(0.01, 0.2)
dataframe["trailing_stop_positive_offset"] = (dataframe["roi_0_pred"] * 0.5).clip(0.01, 0.3)
# 设置策略级参数
self.buy_rsi.value = float(dataframe["buy_rsi_pred"].iloc[-1])
self.sell_rsi.value = float(dataframe["sell_rsi_pred"].iloc[-1])
# 更保守的止损设置
self.stoploss = -0.15 # 固定止损 15%
self.minimal_roi = {
0: float(self.roi_0.value),
15: float(self.roi_15.value),
30: float(self.roi_30.value),
60: 0
}
# 更保守的追踪止损设置
self.trailing_stop_positive = 0.05 # 追踪止损触发点
self.trailing_stop_positive_offset = 0.1 # 追踪止损偏移量
logger.info(f"动态参数buy_rsi={self.buy_rsi.value}, sell_rsi={self.sell_rsi.value}, "
f"stoploss={self.stoploss}, trailing_stop_positive={self.trailing_stop_positive}")
dataframe.replace([np.inf, -np.inf], 0, inplace=True)
dataframe.ffill(inplace=True)
dataframe.fillna(0, inplace=True)
logger.info(f"up_or_down 值统计:\n{dataframe['up_or_down'].value_counts().to_string()}")
logger.info(f"do_predict 值统计:\n{dataframe['do_predict'].value_counts().to_string()}")
return dataframe
def populate_exit_trend(self, df: DataFrame, metadata: dict) -> DataFrame:
# 改进卖出信号条件
exit_long_conditions = [
(df["rsi"] > df["sell_rsi_pred"]), # RSI 高于卖出阈值
(df["volume"] > df["volume"].rolling(window=10).mean()), # 成交量高于近期均值
(df["close"] < df["bb_middleband"]) # 价格低于布林带中轨
]
if exit_long_conditions:
df.loc[
reduce(lambda x, y: x & y, exit_long_conditions),
"exit_long"
] = 1
return df
def populate_entry_trend(self, df: DataFrame, metadata: dict) -> DataFrame:
# 改进买入信号条件
# 检查 MACD 列是否存在
if "macd" not in df.columns or "macdsignal" not in df.columns:
logger.error("MACD 或 MACD 信号列缺失,无法生成买入信号。尝试重新计算 MACD 列。")
try:
macd = ta.MACD(df, fastperiod=12, slowperiod=26, signalperiod=9)
df["macd"] = macd["macd"]
df["macdsignal"] = macd["macdsignal"]
logger.info("MACD 列已成功重新计算。")
except Exception as e:
logger.error(f"重新计算 MACD 列时出错:{str(e)}")
raise ValueError("DataFrame 缺少必要的 MACD 列且无法重新计算。")
enter_long_conditions = [
(df["rsi"] < df["buy_rsi_pred"]), # RSI 低于买入阈值
(df["volume"] > df["volume"].rolling(window=10).mean() * 1.2), # 成交量高于近期均值20%
(df["close"] > df["bb_middleband"]) # 价格高于布林带中轨
]
# 如果 MACD 列存在,则添加 MACD 金叉条件
if "macd" in df.columns and "macdsignal" in df.columns:
enter_long_conditions.append((df["macd"] > df["macdsignal"]))
# 确保模型预测为买入
enter_long_conditions.append((df["do_predict"] == 1))
if enter_long_conditions:
df.loc[
reduce(lambda x, y: x & y, enter_long_conditions),
["enter_long", "enter_tag"]
] = (1, "long")
return df
def confirm_trade_entry(
self, pair: str, order_type: str, amount: float, rate: float,
time_in_force: str, current_time, entry_tag, side: str, **kwargs
) -> bool:
df, _ = self.dp.get_analyzed_dataframe(pair, self.timeframe)
last_candle = df.iloc[-1].squeeze()
if side == "long":
if rate > (last_candle["close"] * (1 + 0.0025)):
return False
return True

View File

@ -0,0 +1 @@
{"$schema":"https://schema.freqtrade.io/schema.json","trading_mode":"spot","margin_mode":"isolated","max_open_trades":4,"stake_currency":"USDT","stake_amount":150,"startup_candle_count":30,"tradable_balance_ratio":1,"fiat_display_currency":"USD","dry_run":true,"timeframe":"3m","dry_run_wallet":1000,"cancel_open_orders_on_exit":true,"stoploss":-0.05,"unfilledtimeout":{"entry":5,"exit":15},"exchange":{"name":"okx","key":"REDACTED","secret":"REDACTED","enable_ws":false,"ccxt_config":{"enableRateLimit":true,"rateLimit":500,"options":{"defaultType":"spot"}},"ccxt_async_config":{"enableRateLimit":true,"rateLimit":500,"timeout":20000},"pair_whitelist":["BTC/USDT","SOL/USDT"],"pair_blacklist":[]},"entry_pricing":{"price_side":"same","use_order_book":true,"order_book_top":1,"price_last_balance":0.0,"check_depth_of_market":{"enabled":false,"bids_to_ask_delta":1}},"exit_pricing":{"price_side":"other","use_order_book":true,"order_book_top":1},"pairlists":[{"method":"StaticPairList"}],"freqai":{"enabled":true,"data_kitchen":{"fillna":"ffill","feature_parameters":{"DI_threshold":0.9,"weight_factor":0.9}},"freqaimodel":"XGBoostRegressor","purge_old_models":2,"identifier":"test175","train_period_days":30,"backtest_period_days":10,"live_retrain_hours":0,"feature_selection":{"method":"recursive_elimination","threshold":0.01},"feature_parameters":{"include_timeframes":["3m","5m","1h"],"include_corr_pairlist":["BTC/USDT","ETH/USDT"],"label_period_candles":12,"include_shifted_candles":3,"indicator_periods_candles":[10,20,50],"plot_feature_importances":1},"data_split_parameters":{"test_size":0.2,"shuffle":true,"random_state":42},"model_training_parameters":{"n_estimators":200,"learning_rate":0.05,"max_depth":5,"subsample":0.8,"colsample_bytree":0.8,"objective":"reg:squarederror","eval_metric":"rmse","early_stopping_rounds":50,"verbose":0}},"api_server":{"enabled":true,"listen_ip_address":"0.0.0.0","listen_port":8080,"verbosity":"error","enable_openapi":false,"jwt_secret_key":"6a599ab046dbb419014807dffd7b8823bfa7e5df56b17d545485deb87331b4ca","ws_token":"6O5pBDiRigiZrmIsofaE2rkKMJtf9h8zVQ","CORS_origins":[],"username":"freqAdmin","password":"REDACTED"},"bot_name":"freqtrade","initial_state":"running","force_entry_enable":false,"internals":{"process_throttle_secs":5,"heartbeat_interval":20,"loglevel":"DEBUG"},"config_files":["/freqtrade/config_examples/config_freqai.okx.json"]}

23
run.sh Executable file
View File

@ -0,0 +1,23 @@
#!/bin/bash
rm -rf user_data/models/*
rm -rf ./freqtrade/user_data/data/backtest_results/*
docker-compose run --rm freqtrade >output.log 2>&1
sed -i 's/\x1B\[[0-9;]*m//g' output.log
python3 filter.py
rm ./result/* -fr
mv ./user_data/backtest_results/* ./result/
cd ./result
# 查找当前目录下的所有 zip 文件
zip_files=(*.zip)
# 检查是否只有一个 zip 文件
if [ ${#zip_files[@]} -eq 1 ]; then
# 解压缩该 zip 文件到当前目录
unzip "${zip_files[0]}"
else
echo "当前目录下没有 zip 文件或者有多个 zip 文件,无法操作。"
fi

2202
temp_validation.log Normal file

File diff suppressed because it is too large Load Diff

3066
your_output_file.log Normal file

File diff suppressed because it is too large Load Diff