trend_score98分以上不卖
This commit is contained in:
parent
b02ac0ea97
commit
ccc02672c2
@ -614,7 +614,7 @@ class FreqaiPrimer(IStrategy):
|
||||
|
||||
else: # ranging
|
||||
# 震荡趋势:使用原策略
|
||||
if trend_score > 92:
|
||||
if trend_score > 98:
|
||||
logger.info(f"[{pair}] ⚖️ 震荡趋势但得分较高,拒绝卖出")
|
||||
return dataframe
|
||||
|
||||
|
||||
105
tools/dryrun.sh
105
tools/dryrun.sh
@ -1,7 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e # 出错立即停止
|
||||
|
||||
# 检查 .env 文件
|
||||
if [ ! -f ".env" ]; then
|
||||
echo "⚠️ 本地缺少 .env 文件,请创建并配置。示例内容如下:"
|
||||
@ -13,7 +12,6 @@ if [ ! -f ".env" ]; then
|
||||
echo ""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 加载 .env 文件中的变量(位于项目根目录)
|
||||
if [ -f ".env" ]; then
|
||||
export $(grep -v '^#' .env | xargs)
|
||||
@ -37,8 +35,8 @@ else
|
||||
fi
|
||||
|
||||
# 如果当前分支名称包含 "dryrun",执行 git reset --hard
|
||||
if [[ "$current_branch" == *"dryrun"* ]]; then
|
||||
echo "当前分支为 '$current_branch',正在执行 git reset --hard 以确保代码干净..."
|
||||
if [[ "$CURRENT_BRANCH" == *"dryrun"* ]]; then
|
||||
echo "当前分支为 '$CURRENT_BRANCH',正在执行 git reset --hard 以确保代码干净..."
|
||||
git reset --hard
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "⚠️ 执行 git reset --hard 失败,请检查 Git 状态。"
|
||||
@ -47,98 +45,20 @@ if [[ "$current_branch" == *"dryrun"* ]]; then
|
||||
echo "Git 工作区已清理。"
|
||||
fi
|
||||
|
||||
# Function to extract the value of a parameter
|
||||
get_param_value() {
|
||||
local param="$1"
|
||||
shift
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
$param=*)
|
||||
echo "${1#*=}"
|
||||
return
|
||||
;;
|
||||
$param)
|
||||
# Check if the next argument exists and does not start with a dash
|
||||
if [[ -n "$2" && "$2" != -* ]]; then
|
||||
echo "$2"
|
||||
return
|
||||
else
|
||||
echo "Error: Missing value for parameter $param" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
echo ""
|
||||
return
|
||||
}
|
||||
|
||||
# Parse command line arguments
|
||||
PAIRS_ARG=$(get_param_value "--pairs" "$@")
|
||||
PAIR_REMOTE_LIST_URL=$(get_param_value "--pairRemoteList" "$@")
|
||||
|
||||
# 加载 .env 文件中的变量
|
||||
export $(grep -v '^#' .env | xargs)
|
||||
# 设置默认值
|
||||
STRATEGY_NAME=${STRATEGY_NAME:-TheForceV7}
|
||||
CONFIG_FILE=${CONFIG_FILE:-basic.json}
|
||||
# 设置 PARAMS_NAME 为 STRATEGY_NAME 的小写形式
|
||||
PARAMS_NAME=$(echo "$STRATEGY_NAME" | tr '[:upper:]' '[:lower:]')
|
||||
|
||||
echo "Using strategy: $STRATEGY_NAME"
|
||||
echo "Using config: $CONFIG_FILE"
|
||||
echo "Using testBranch: $TEST_BRANCH"
|
||||
|
||||
# 处理交易对参数:优先级为 --pairRemoteList > --pairs > 默认值
|
||||
if [ -n "$PAIR_REMOTE_LIST_URL" ]; then
|
||||
# 从远程API获取交易对列表
|
||||
echo "Fetching pairs from remote URL: $PAIR_REMOTE_LIST_URL"
|
||||
pairs_json=$(curl -s "$PAIR_REMOTE_LIST_URL")
|
||||
|
||||
# 检查API响应是否成功
|
||||
if [[ $? -ne 0 || -z "$pairs_json" ]]; then
|
||||
echo "Error: Failed to fetch pairs from remote URL, using --pairs parameter or default"
|
||||
if [ -n "$PAIRS_ARG" ]; then
|
||||
PAIRS_FLAG="--pairs $PAIRS_ARG"
|
||||
echo "Using pairs from --pairs parameter: $PAIRS_ARG"
|
||||
else
|
||||
PAIRS_FLAG=""
|
||||
echo "No pairs parameter provided, using freqtrade default"
|
||||
fi
|
||||
else
|
||||
# 解析JSON并提取交易对,将连字符替换为斜杠
|
||||
remote_pairs=$(echo "$pairs_json" | python3 -c "
|
||||
import sys, json
|
||||
data = json.load(sys.stdin)
|
||||
pairs = [pair.replace('-', '/') for pair in data.get('pairlist', [])]
|
||||
print(' '.join(pairs) if pairs else '')
|
||||
")
|
||||
|
||||
# 如果解析成功且有交易对
|
||||
if [[ -n "$remote_pairs" ]]; then
|
||||
PAIRS_FLAG="--pairs $remote_pairs"
|
||||
echo "Successfully fetched $(echo "$remote_pairs" | wc -w) pairs from remote URL"
|
||||
echo "Pairs: $remote_pairs"
|
||||
else
|
||||
echo "Error: Failed to parse or empty pairlist from remote URL, using --pairs parameter or default"
|
||||
if [ -n "$PAIRS_ARG" ]; then
|
||||
PAIRS_FLAG="--pairs $PAIRS_ARG"
|
||||
echo "Using pairs from --pairs parameter: $PAIRS_ARG"
|
||||
else
|
||||
PAIRS_FLAG=""
|
||||
echo "No pairs parameter provided, using freqtrade default"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
elif [ -n "$PAIRS_ARG" ]; then
|
||||
# 使用 --pairs 参数提供的交易对
|
||||
PAIRS_FLAG="--pairs $PAIRS_ARG"
|
||||
echo "Using pairs from --pairs parameter: $PAIRS_ARG"
|
||||
else
|
||||
# 没有提供任何交易对参数
|
||||
PAIRS_FLAG=""
|
||||
echo "No pairs parameter provided, using freqtrade default"
|
||||
fi
|
||||
# Parse command line arguments
|
||||
START_DATE=${1:-$(date -d "2 days ago" +"%Y%m%d")}
|
||||
END_DATE=${2:-$(date -d "tomorrow" +"%Y%m%d")}
|
||||
|
||||
cd ../
|
||||
source .venv/bin/activate
|
||||
@ -152,29 +72,26 @@ docker rm $(docker ps -aq) -f || true
|
||||
|
||||
# 获取当前 Git Commit 的前 8 位
|
||||
GIT_COMMIT_SHORT=$(git rev-parse HEAD | cut -c 1-8)
|
||||
|
||||
echo "docker-compose run -d --rm --name freqtrade-dryrun-${GIT_COMMIT_SHORT} -p 8080:8080 freqtrade trade \
|
||||
--logfile /freqtrade/user_data/logs/freqtrade.log \
|
||||
--db-url sqlite:////freqtrade/user_data/tradesv3.sqlite \
|
||||
--dry-run \
|
||||
--freqaimodel LightGBMRegressorMultiTarget \
|
||||
--dry-run \
|
||||
--fee 0.0008
|
||||
--config /freqtrade/config_examples/$CONFIG_FILE \
|
||||
--config /freqtrade/templates/${PARAMS_NAME}.json \
|
||||
--config /freqtrade/config_examples/live.json \
|
||||
--strategy $STRATEGY_NAME \
|
||||
--config /freqtrade/freqtrade/templates/${STRATEGY_NAME}.json \
|
||||
--fee 0.0008 \
|
||||
--strategy-path /freqtrade/templates"
|
||||
|
||||
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 \
|
||||
--fee 0.0008 \
|
||||
--config /freqtrade/config_examples/$CONFIG_FILE \
|
||||
--config /freqtrade/templates/${PARAMS_NAME}.json \
|
||||
--enable-protections \
|
||||
--config /freqtrade/config_examples/live.json \
|
||||
--strategy $STRATEGY_NAME \
|
||||
--config /freqtrade/freqtrade/templates/${STRATEGY_NAME}.json \
|
||||
--fee 0.0008 \
|
||||
--strategy-path /freqtrade/templates
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user