revert to 8ba203f2

This commit is contained in:
zhangkun9038@dingtalk.com 2025-06-21 12:41:45 +00:00
parent 8ba203f2b1
commit 9c57aea106
4 changed files with 60 additions and 21 deletions

View File

@ -8,33 +8,33 @@
"max_open_trades": 5
},
"buy": {
"ADD_POSITION_THRESHOLD": -0.015,
"BUY_THRESHOLD_MAX": -0.005,
"BUY_THRESHOLD_MIN": -0.061,
"COOLDOWN_PERIOD_MINUTES": 10,
"MAX_ENTRY_POSITION_ADJUSTMENT": 2
"ADD_POSITION_THRESHOLD": -0.013,
"BUY_THRESHOLD_MAX": -0.009,
"BUY_THRESHOLD_MIN": -0.069,
"COOLDOWN_PERIOD_MINUTES": 2,
"MAX_ENTRY_POSITION_ADJUSTMENT": 1
},
"sell": {
"EXIT_POSITION_RATIO": 0.547,
"SELL_THRESHOLD_MAX": 0.043,
"SELL_THRESHOLD_MIN": 0.012,
"TRAILING_STOP_DISTANCE": 0.005,
"TRAILING_STOP_START": 0.013
"EXIT_POSITION_RATIO": 0.696,
"SELL_THRESHOLD_MAX": 0.036,
"SELL_THRESHOLD_MIN": 0.011,
"TRAILING_STOP_DISTANCE": 0.019,
"TRAILING_STOP_START": 0.01
},
"protection": {},
"roi": {
"0": 0.186,
"7": 0.049,
"15": 0.008,
"79": 0
"0": 0.155,
"20": 0.063,
"40": 0.024,
"72": 0
},
"trailing": {
"trailing_stop": true,
"trailing_stop_positive": 0.094,
"trailing_stop_positive_offset": 0.181,
"trailing_stop_positive": 0.326,
"trailing_stop_positive_offset": 0.383,
"trailing_only_offset_is_reached": false
}
},
"ft_stratparam_v": 1,
"export_time": "2025-06-11 17:45:35.898655+00:00"
"export_time": "2025-06-21 12:36:57.143681+00:00"
}

View File

@ -531,3 +531,4 @@ class FreqaiPrimer(IStrategy):
logger.error(f"获取市场趋势失败:{e}", exc_info=True)
return "sideways"

View File

@ -26,6 +26,24 @@ START_DATE=${1:-$(date -d "2 days ago" +"%Y%m%d")}
END_DATE=${2:-$(date -d "tomorrow" +"%Y%m%d")}
PARAMS_NAME=$(echo "$STRATEGY_NAME" | tr '[:upper:]' '[:lower:]')
# Parse command line arguments
START_DATE_RAW=${1:-$(date -d "2 days ago" +"%Y-%m-%d %H:%M:%S")}
END_DATE_RAW=${2:-$(date -d "tomorrow" +"%Y-%m-%d %H:%M:%S")}
# 判断是否包含空格,如果是,则按完整时间解析并转为时间戳
if [[ "$START_DATE_RAW" == *" "* ]]; then
START_DATE=$(date -d "$START_DATE_RAW" +"%s")
else
# 兼容旧格式20250616 -> 转换为 2025-06-16 00:00:00 再转为时间戳
START_DATE=$(date -d "${START_DATE_RAW:0:4}-${START_DATE_RAW:4:2}-${START_DATE_RAW:6:2} 00:00:00" +"%s")
fi
if [[ "$END_DATE_RAW" == *" "* ]]; then
END_DATE=$(date -d "$END_DATE_RAW" +"%s")
else
END_DATE=$(date -d "${END_DATE_RAW:0:4}-${END_DATE_RAW:4:2}-${END_DATE_RAW:6:2} 00:00:00" +"%s")
fi
cd ../
source .venv/bin/activate
rm -rf user_data/models/*
@ -41,7 +59,6 @@ echo "docker-compose run --rm freqtrade backtesting \
--freqaimodel LightGBMRegressorMultiTarget \
--config /freqtrade/config_examples/$CONFIG_FILE \
--strategy-path /freqtrade/templates \
--config /freqtrade/templates/${PARAMS_NAME}.json \
--strategy $STRATEGY_NAME \
--timerange $START_DATE-$END_DATE \
--fee 0.0008 \
@ -52,7 +69,6 @@ docker-compose run --rm freqtrade backtesting \
--freqaimodel LightGBMRegressorMultiTarget \
--config /freqtrade/config_examples/$CONFIG_FILE \
--strategy-path /freqtrade/templates \
--config /freqtrade/templates/${PARAMS_NAME}.json \
--strategy $STRATEGY_NAME \
--timerange $START_DATE-$END_DATE \
--fee 0.0008 \

View File

@ -25,7 +25,29 @@ echo "Using testBranch: $TEST_BRANCH"
# Parse command line arguments
START_DATE=${1:-$(date -d "2 days ago" +"%Y%m%d")}
END_DATE=${2:-$(date -d "tomorrow" +"%Y%m%d")}
# Parse command line arguments
START_DATE_RAW=${1:-$(date -d "2 days ago" +"%Y-%m-%d %H:%M:%S")}
END_DATE_RAW=${2:-$(date -d "tomorrow" +"%Y-%m-%d %H:%M:%S")}
# Parse command line arguments
START_DATE_RAW=${1:-$(date -d "2 days ago" +"%Y-%m-%d 00:00")}
END_DATE_RAW=${2:-$(date -d "today" +"%Y-%m-%d 00:00")}
# Convert raw date strings to timestamps
if [[ "$START_DATE_RAW" == *" "* ]]; then
START_DATE=$(date -d "$START_DATE_RAW" +"%s")
else
START_DATE=$(date -d "${START_DATE_RAW} 00:00:00" +"%s")
fi
if [[ "$END_DATE_RAW" == *" "* ]]; then
END_DATE=$(date -d "$END_DATE_RAW" +"%s")
else
END_DATE=$(date -d "${END_DATE_RAW} 00:00:00" +"%s")
fi
echo "Start timestamp: $START_TIMESTAMP"
echo "End timestamp: $END_TIMESTAMP"
cd ../
source .venv/bin/activate
rm -rf user_data/models/*
@ -41,7 +63,7 @@ echo "docker-compose run --rm freqtrade hyperopt \
--config /freqtrade/templates/${PARAMS_NAME}.json \
--strategy-path /freqtrade/templates \
--timerange ${START_DATE}-${END_DATE} \
-e 200 \
-e 100 \
--hyperopt-loss ShortTradeDurHyperOptLoss \
--spaces buy sell roi trailing \
--fee 0.0016"
@ -53,7 +75,7 @@ docker-compose run --rm freqtrade hyperopt \
--config /freqtrade/templates/${PARAMS_NAME}.json \
--strategy-path /freqtrade/templates \
--timerange ${START_DATE}-${END_DATE} \
-e 200 \
-e 100 \
--hyperopt-loss SharpeHyperOptLoss \
--spaces buy sell roi trailing \
--fee 0.0016