update dryrun.sh
This commit is contained in:
parent
1827fa7a81
commit
d2829f505a
@ -212,6 +212,19 @@ while [[ $# -gt 0 ]]; do
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
--pairs=*)
|
||||
PAIRS_ARG="${1#*=}"
|
||||
shift
|
||||
;;
|
||||
--pairs)
|
||||
if [[ -n "$2" && "$2" != -* ]]; then
|
||||
PAIRS_ARG="$2"
|
||||
shift 2
|
||||
else
|
||||
echo "错误:--pairs需要指定值" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
--pairRemoteList=*)
|
||||
PAIR_REMOTE_LIST_URL="${1#*=}"
|
||||
shift
|
||||
@ -235,11 +248,14 @@ done
|
||||
if [ -n "$STRATEGY_NAME" ]; then
|
||||
STRATEGY_CONFIG_LOWER="$(echo "$STRATEGY_NAME" | tr '[:upper:]' '[:lower:]').json"
|
||||
|
||||
# 如果没有明确指定配置文件,且找不到自动匹配的配置,才用默认值
|
||||
if [ -f "../freqtrade/templates/$STRATEGY_CONFIG_LOWER" ]; then
|
||||
# 优先使用策略同名的配置文件
|
||||
# 如果没有明确指定配置文件,先在 config_examples 中查找
|
||||
if [ -f "../config_examples/$STRATEGY_CONFIG_LOWER" ]; then
|
||||
CONFIG_FILE="$STRATEGY_CONFIG_LOWER"
|
||||
echo "✅ 自动匹配配置文件: $CONFIG_FILE" >&2
|
||||
echo "✅ 自动匹配配置文件 (config_examples): $CONFIG_FILE" >&2
|
||||
elif [ -f "../freqtrade/templates/$STRATEGY_CONFIG_LOWER" ]; then
|
||||
# 其次在 templates 中查找(仅罢材材)
|
||||
CONFIG_FILE="$STRATEGY_CONFIG_LOWER"
|
||||
echo "✅ 自动匹配配置文件 (templates): $CONFIG_FILE" >&2
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -252,18 +268,32 @@ echo "✅ 远程币对列表URL: $PAIR_REMOTE_LIST_URL" >&2
|
||||
|
||||
### 核心:处理币对列表 ###
|
||||
|
||||
# 1. 获取数据库币对(使用绝对路径)
|
||||
db_path="/home/ubuntu/freqtrade/user_data/tradesv3.sqlite"
|
||||
db_pairs=$(get_open_trades_pairs "$db_path")
|
||||
# 0. 判断是否使用 --pairs 传入的币对列表
|
||||
if [ -n "$PAIRS_ARG" ]; then
|
||||
echo "✅ 使用命令行 --pairs 参数:$PAIRS_ARG" >&2
|
||||
# 简化处理:直接使用提供的币对,是否更新配置文件取决于是否有配置文件
|
||||
if [ -f "../config_examples/live.json" ]; then
|
||||
update_live_json_pair_whitelist "../config_examples/live.json" "$PAIRS_ARG"
|
||||
else
|
||||
echo "⚠️ 找不到 ../config_examples/live.json,跳过配置更新" >&2
|
||||
fi
|
||||
else
|
||||
# 使用旧的逻辑:数据库 + 遥程 API
|
||||
echo "✅ 使用旧逻辑(数据库 + 遥程 API)" >&2
|
||||
|
||||
# 1. 获取数据库币对(使用绝对路径)
|
||||
db_path="/home/ubuntu/freqtrade/user_data/tradesv3.sqlite"
|
||||
db_pairs=$(get_open_trades_pairs "$db_path")
|
||||
|
||||
# 2. 获取远程币对
|
||||
remote_pairs=$(get_remote_pairs "$PAIR_REMOTE_LIST_URL")
|
||||
# 2. 获取遥程币对
|
||||
remote_pairs=$(get_remote_pairs "$PAIR_REMOTE_LIST_URL")
|
||||
|
||||
# 3. 合并去重
|
||||
merged_pairs=$(merge_and_deduplicate_pairs "$db_pairs" "$remote_pairs")
|
||||
# 3. 合并去重
|
||||
merged_pairs=$(merge_and_deduplicate_pairs "$db_pairs" "$remote_pairs")
|
||||
|
||||
# 4. 更新配置文件
|
||||
update_live_json_pair_whitelist "../config_examples/live.json" "$merged_pairs"
|
||||
# 4. 更新配置文件
|
||||
update_live_json_pair_whitelist "../config_examples/live.json" "$merged_pairs"
|
||||
fi
|
||||
|
||||
### 启动容器 ###
|
||||
|
||||
@ -277,13 +307,10 @@ remove_existing_container "$CONTAINER_NAME"
|
||||
|
||||
# 启动新容器
|
||||
docker-compose run -d --rm --name freqtrade-dryrun-${GIT_COMMIT_SHORT} -p 8080:8080 freqtrade trade \
|
||||
$PAIRS_FLAG \
|
||||
--logfile /freqtrade/user_data/logs/freqtrade.log \
|
||||
--db-url sqlite:////freqtrade/user_data/tradesv3.sqlite \
|
||||
--dry-run \
|
||||
--freqaimodel LightGBMRegressorMultiTarget \
|
||||
--config /freqtrade/config_examples/$CONFIG_FILE \
|
||||
--config /freqtrade/templates/$CONFIG_FILE \
|
||||
--strategy $STRATEGY_NAME \
|
||||
--fee 0.0008 \
|
||||
--strategy-path /freqtrade/templates
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user