auto_trade_sys/scripts/apply_steady_lift_tier1.sh
薇薇安 b9b9a32762 1
2026-05-05 22:35:08 +08:00

50 lines
1.8 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
# 稳妥增效一档:写入 global_strategy_config + Redis 缓存(与前端「保存配置」同路径)
#
# 变更内容(见 config/my_batch_steady_lift_tier1.json
# MIN_CHANGE_PERCENT 2% → 1% 24h 涨跌绝对值门槛)
# MIN_SIGNAL_STRENGTH 8 → 7
# ENTRY_SYMBOL_COOLDOWN_SEC 1800 → 1200
#
# 用法(在项目根目录):
# chmod +x scripts/apply_steady_lift_tier1.sh
# ./scripts/apply_steady_lift_tier1.sh
# ./scripts/apply_steady_lift_tier1.sh --dry-run
#
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "$ROOT"
# 优先使用项目虚拟环境里的 Python与 backend/start_recommendations.sh 一致),避免系统 python3 缺依赖报 ModuleNotFoundError
PYTHON_BIN=""
for _py in \
"${ROOT}/.venv/bin/python" \
"${ROOT}/trading_system/.venv/bin/python" \
"${ROOT}/backend/.venv/bin/python"; do
if [ -x "$_py" ]; then
PYTHON_BIN="$_py"
break
fi
done
if [ -z "$PYTHON_BIN" ]; then
if command -v python3 >/dev/null 2>&1; then
PYTHON_BIN="$(command -v python3)"
echo "警告: 未找到 .venv / trading_system/.venv / backend/.venv改用: $PYTHON_BIN" >&2
echo " 若出现 ModuleNotFoundError请在项目根创建 venv 并安装依赖后再运行本脚本。" >&2
else
echo "错误: 未找到 python3且不存在 ${ROOT}/.venv或 trading_system/.venv、backend/.venv" >&2
exit 1
fi
fi
DRY_RUN=()
if [[ "${1:-}" == "--dry-run" ]]; then
DRY_RUN=(--dry-run)
fi
# 使用 apply_config_patch_only只写本 JSON 中的键,不合并 apply_recommended_config 内置批量默认
exec "$PYTHON_BIN" "$ROOT/scripts/apply_config_patch_only.py" \
--from "$ROOT/config/my_batch_steady_lift_tier1.json" \
--updated-by "steady_lift_tier1" \
"${DRY_RUN[@]}"