diff --git a/docker-compose.yml b/docker-compose.yml index 9a3386bc..9cc01a8b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,6 +17,9 @@ services: # context: . # dockerfile: "./docker/Dockerfile.custom" restart: always + extra_hosts: + - "www.okx.com:104.18.43.174" # 域名:IP 格式 + - "api.okx.com:104.18.43.174" # 域名:IP 格式 container_name: freqtrade volumes: - "./user_data:/freqtrade/user_data" diff --git a/freqtrade/templates/freqaiprimer.json b/freqtrade/templates/freqaiprimer.json index cdeaed28..63b52c48 100644 --- a/freqtrade/templates/freqaiprimer.json +++ b/freqtrade/templates/freqaiprimer.json @@ -5,65 +5,35 @@ "stoploss": { "stoploss": -0.14 }, - "max_open_trades": { - "max_open_trades": 5 - }, - "buy": { - "ADD_POSITION_THRESHOLD": -0.021, - "BUY_THRESHOLD_MAX": -0.001, - "BUY_THRESHOLD_MIN": -0.035, - "COOLDOWN_PERIOD_MINUTES": 9, - "MAX_ENTRY_POSITION_ADJUSTMENT": 3 - }, - "sell": { - "EXIT_POSITION_RATIO": 0.472, - "SELL_THRESHOLD_MAX": 0.065, - "SELL_THRESHOLD_MIN": 0.002, - "TRAILING_STOP_DISTANCE": 0.0125, - "TRAILING_STOP_START": 0.045 - }, - "protection": {}, - "model_training_parameters": { - "price_value_divergence": { - "model": "LightGBMRegressor", - "model_params": { - "n_estimators": 200, - "learning_rate": 0.05, - "num_leaves": 31, - "verbose": -1 - } - }, - "optimal_first_length": { - "model": "LightGBMClassifier", - "model_params": { - "n_estimators": 150, - "learning_rate": 0.1, - "num_leaves": 15, - "max_depth": 8, - "min_child_samples": 10, - "class_weight": "balanced", - "verbose": -1 - } - }, - "volatility_forecast": { - "model": "LightGBMRegressor", - "model_params": { - "n_estimators": 180, - "learning_rate": 0.08, - "num_leaves": 25, - "max_depth": 6, - "verbose": -1 - } - } - }, "trailing": { "trailing_stop": true, "trailing_stop_positive": 0.0125, "trailing_stop_positive_offset": 0.045, "trailing_only_offset_is_reached": false - } - + }, + "max_open_trades": { + "max_open_trades": 5 + }, + "buy": { + "bb_length": 17, + "bb_lower_deviation": 1.04, + "bb_std": 1.8, + "bb_width_threshold": 0.012, + "h1_max_candles": 108, + "h1_max_consecutive_candles": 2, + "h1_rapid_rise_threshold": 0.109, + "min_condition_count": 2, + "rsi_bull_threshold": 46, + "rsi_length": 19, + "rsi_overbought": 60, + "rsi_oversold": 49, + "stochrsi_bull_threshold": 37, + "stochrsi_neutral_threshold": 23, + "volume_multiplier": 1.5 + }, + "sell": {}, + "protection": {} }, "ft_stratparam_v": 1, - "export_time": "2025-08-14 06:30:51.352733+00:00" -} + "export_time": "2025-09-08 03:00:52.051003+00:00" +} \ No newline at end of file diff --git a/freqtrade/templates/freqaiprimer.py b/freqtrade/templates/freqaiprimer.py index a922b780..3e01a4d0 100644 --- a/freqtrade/templates/freqaiprimer.py +++ b/freqtrade/templates/freqaiprimer.py @@ -604,6 +604,9 @@ class FreqaiPrimer(IStrategy): # 获取初始入场价格和当前价格的差值百分比 initial_price = trade.open_rate + # 防止除零错误:如果initial_price为0,则返回不加仓 + if initial_price == 0: + return 0.0 price_diff_pct = (current_rate - initial_price) / initial_price # 检查价格回调是否达到加仓间隔(0.047) diff --git a/tools/hyperopt.sh b/tools/hyperopt.sh index 446017ce..0aebc9f4 100755 --- a/tools/hyperopt.sh +++ b/tools/hyperopt.sh @@ -244,7 +244,7 @@ docker-compose run --rm freqtrade hyperopt $PAIRS_FLAG \ --strategy-path /freqtrade/templates \ --timerange ${START_DATE}-${END_DATE} \ -e 100 \ - -j 4 \ - --hyperopt-loss SharpeHyperOptLoss \ - --spaces buy sell trailing \ + -j 2 \ + --hyperopt-loss SharpeHyperOptLossDaily \ + --spaces buy \ --fee 0.0016