update hyperopt_org.sh
This commit is contained in:
parent
a21aa0bad2
commit
5a5de17cd5
@ -83,28 +83,28 @@ class FreqaiPrimer(IStrategy):
|
||||
|
||||
# [propertiesGrp_List]--------------------------------------------------------------------------------------------------------------------------------------
|
||||
# [propertiesGrp id="1" name="第一轮优化" space="buy" description="入场基础条件优化"]
|
||||
bb_std = DecimalParameter(1.5, 3.0, decimals=1, default=2.9, optimize=False, load=True, space='buy')
|
||||
rsi_length = IntParameter(7, 21, default=18, optimize=False, load=True, space='buy')
|
||||
bb_lower_deviation = DecimalParameter(1.01, 1.05, decimals=2, default=1.03, optimize=False, load=True, space='buy')
|
||||
stochrsi_bull_threshold = IntParameter(30, 40, default=33, optimize=False, load=True, space='buy')
|
||||
volume_multiplier = DecimalParameter(1.2, 2.0, decimals=1, default=1.5, optimize=False, load=True, space='buy')
|
||||
min_condition_count = IntParameter(2, 4, default=2, optimize=False, load=True, space='buy')
|
||||
bb_std = DecimalParameter(1.5, 3.0, decimals=1, default=2.9, optimize=True, load=True, space='buy')
|
||||
rsi_length = IntParameter(7, 21, default=18, optimize=True, load=True, space='buy')
|
||||
bb_lower_deviation = DecimalParameter(1.01, 1.05, decimals=2, default=1.03, optimize=True, load=True, space='buy')
|
||||
stochrsi_bull_threshold = IntParameter(30, 40, default=33, optimize=True, load=True, space='buy')
|
||||
volume_multiplier = DecimalParameter(1.2, 2.0, decimals=1, default=1.5, optimize=True, load=True, space='buy')
|
||||
min_condition_count = IntParameter(2, 4, default=2, optimize=True, load=True, space='buy')
|
||||
|
||||
# [propertiesGrp id="2" name="第二轮优化" space="buy" description="入场确认条件优化"]
|
||||
bb_length = IntParameter(10, 30, default=28, optimize=False, load=True, space='buy')
|
||||
rsi_oversold = IntParameter(30, 50, default=40, optimize=False, load=True, space='buy')
|
||||
rsi_bull_threshold = IntParameter(45, 55, default=53, optimize=False, load=True, space='buy')
|
||||
stochrsi_neutral_threshold = IntParameter(20, 30, default=26, optimize=False, load=True, space='buy')
|
||||
bb_width_threshold = DecimalParameter(0.01, 0.03, decimals=3, default=0.013, optimize=False, load=True, space='buy')
|
||||
bb_length = IntParameter(10, 30, default=28, optimize=True, load=True, space='buy')
|
||||
rsi_oversold = IntParameter(30, 50, default=40, optimize=True, load=True, space='buy')
|
||||
rsi_bull_threshold = IntParameter(45, 55, default=53, optimize=True, load=True, space='buy')
|
||||
stochrsi_neutral_threshold = IntParameter(20, 30, default=26, optimize=True, load=True, space='buy')
|
||||
bb_width_threshold = DecimalParameter(0.01, 0.03, decimals=3, default=0.013, optimize=True, load=True, space='buy')
|
||||
# [/propertiesGrp]
|
||||
|
||||
# [propertiesGrp id="3" name="第三轮优化" space="buy" description="剧烈拉升检测与加仓策略优化"]
|
||||
h1_max_candles = IntParameter(100, 300, default=260, optimize=False, load=True, space='buy')
|
||||
h1_rapid_rise_threshold = DecimalParameter(0.05, 0.15, decimals=3, default=0.148, optimize=False, load=True, space='buy')
|
||||
h1_max_consecutive_candles = IntParameter(1, 4, default=2, optimize=False, load=True, space='buy')
|
||||
max_entry_adjustments = IntParameter(2, 5, default=4, optimize=False, load=True, space='buy') # 最大加仓次数
|
||||
add_position_callback = DecimalParameter(0.03, 0.06, decimals=3, default=0.03, optimize=False, load=True, space='buy') # 加仓回调百分比
|
||||
adjust_multiplier = DecimalParameter(0.05, 0.6, decimals=2, default=0.59, optimize=False, load=True, space='buy') # 加仓金额分母
|
||||
h1_max_candles = IntParameter(100, 300, default=260, optimize=True, load=True, space='buy')
|
||||
h1_rapid_rise_threshold = DecimalParameter(0.05, 0.15, decimals=3, default=0.148, optimize=True, load=True, space='buy')
|
||||
h1_max_consecutive_candles = IntParameter(1, 4, default=2, optimize=True, load=True, space='buy')
|
||||
max_entry_adjustments = IntParameter(2, 5, default=4, optimize=True, load=True, space='buy') # 最大加仓次数
|
||||
add_position_callback = DecimalParameter(0.03, 0.06, decimals=3, default=0.03, optimize=True, load=True, space='buy') # 加仓回调百分比
|
||||
adjust_multiplier = DecimalParameter(0.05, 0.6, decimals=2, default=0.59, optimize=True, load=True, space='buy') # 加仓金额分母
|
||||
# [/propertiesGrp]
|
||||
|
||||
# [propertiesGrp id="4" name="第四轮优化" space="sell" description="出场与减仓策略优化"]
|
||||
|
||||
@ -60,21 +60,35 @@ fi
|
||||
STRATEGY_NAME=${STRATEGY_NAME:-TheForceV7}
|
||||
CONFIG_FILE=${CONFIG_FILE:-basic.json}
|
||||
TEST_BRANCH=${TEST_BRANCH:-develop}
|
||||
# --- 新增:解析 --spaces 或 --space 参数 ---
|
||||
SPACES_ARG=$(get_param_value "--spaces" "$@")
|
||||
# 如果没有提供 --spaces,尝试获取 --space 参数
|
||||
if [ -z "$SPACES_ARG" ]; then
|
||||
SPACES_ARG=$(get_param_value "--space" "$@")
|
||||
|
||||
# --- 新增:解析多个 --spaces 参数 ---
|
||||
# 提取所有 --spaces 后的值(支持多个 --spaces 参数)
|
||||
SPACES_VALUES=()
|
||||
for arg in "$@"; do
|
||||
if [[ "$prev_arg" == "--spaces" ]] || [[ "$prev_arg" == "--space" ]]; then
|
||||
if [[ ! "$arg" =~ ^-- ]]; then
|
||||
SPACES_VALUES+=("$arg")
|
||||
fi
|
||||
fi
|
||||
prev_arg="$arg"
|
||||
done
|
||||
|
||||
# 如果有多个 --spaces 值,合并为空格分隔的字符串
|
||||
if [ ${#SPACES_VALUES[@]} -gt 0 ]; then
|
||||
SPACES="${SPACES_VALUES[@]}"
|
||||
else
|
||||
# 使用get_param_value作为备选方案(兼容旧格式)
|
||||
SPACES_ARG=$(get_param_value "--spaces" "$@")
|
||||
if [ -z "$SPACES_ARG" ]; then
|
||||
# 如果没有提供任何参数,则默认为 "buy"
|
||||
SPACES="buy"
|
||||
SPACES_ARG=$(get_param_value "--space" "$@")
|
||||
if [ -z "$SPACES_ARG" ]; then
|
||||
SPACES="buy"
|
||||
else
|
||||
SPACES="$SPACES_ARG"
|
||||
fi
|
||||
else
|
||||
# 使用 --space 参数提供的值
|
||||
SPACES="$SPACES_ARG"
|
||||
fi
|
||||
else
|
||||
# 使用 --spaces 参数提供的值
|
||||
SPACES="$SPACES_ARG"
|
||||
fi
|
||||
echo "Using hyperopt spaces: $SPACES"
|
||||
EPOCHS_ARG=$(get_param_value "--epochs" "$@")
|
||||
@ -92,9 +106,15 @@ else
|
||||
fi
|
||||
echo "Using random-state: $RANDOM_STATE"
|
||||
|
||||
# --- 新增:解析 --jobs 或 -j 参数 ---
|
||||
JOBS_ARG=$(get_param_value "--jobs" "$@")
|
||||
if [ -z "$JOBS_ARG" ]; then
|
||||
JOBS=4
|
||||
JOBS_ARG=$(get_param_value "-j" "$@")
|
||||
if [ -z "$JOBS_ARG" ]; then
|
||||
JOBS=4
|
||||
else
|
||||
JOBS="$JOBS_ARG"
|
||||
fi
|
||||
else
|
||||
JOBS="$JOBS_ARG"
|
||||
fi
|
||||
@ -173,9 +193,12 @@ while [ $# -gt 0 ]; do
|
||||
shift
|
||||
fi
|
||||
;;
|
||||
--spaces | --space | --epochs | --random-state)
|
||||
# 这些参数已经在前面处理过了,直接跳过
|
||||
shift 2
|
||||
--spaces | --space | --epochs | --random-state | --jobs | -j)
|
||||
# 这些参数已经在前面处理过了,跳过参数及其值
|
||||
shift
|
||||
if [[ $# -gt 0 ]] && [[ ! "$1" =~ ^-- ]]; then
|
||||
shift
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
shift
|
||||
@ -443,6 +466,10 @@ find ./user_data/dryrun_results -type f -delete 2>/dev/null
|
||||
touch ./user_data/dryrun_results/.gitkeep
|
||||
find result -type f -delete 2>/dev/null
|
||||
touch result/.gitkeep
|
||||
# 🔧 新增:清空 hyperopt_results 目录中的所有结果文件(执行 hyperopt 前清理旧结果)
|
||||
echo "清空旧的 hyperopt 结果文件..."
|
||||
find user_data/hyperopt_results -type f \( -name "*.fthypt" -o -name "*.pkl" -o -name ".last_result.json" \) -delete 2>/dev/null
|
||||
echo "✓ hyperopt_results 目录已清空"
|
||||
|
||||
PARAMS_NAME=freqaiprimer
|
||||
echo "docker-compose run --rm freqtrade hyperopt $PAIRS_FLAG \
|
||||
@ -456,7 +483,7 @@ echo "docker-compose run --rm freqtrade hyperopt $PAIRS_FLAG \
|
||||
--timerange ${START_DATE}-${END_DATE} \
|
||||
--random-state $RANDOM_STATE \
|
||||
--epochs $EPOCHS \
|
||||
-j 4 \
|
||||
-j $JOBS \
|
||||
--hyperopt-loss CalmarHyperOptLoss \
|
||||
--spaces $SPACES \
|
||||
--fee 0.001"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user