myTestFreqAI/tools/export_hyperopt.sh
zhangkun9038@dingtalk.com d812319450 log info
2025-12-27 01:26:00 +08:00

38 lines
1.0 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.

#!/bin/bash
# 导出所有 hyperopt 结果到 JSON 文件
OUTPUT_DIR="hyperopt_exports"
TIMESTAMP=$(date '+%Y%m%d_%H%M%S')
OUTPUT_FILE="${OUTPUT_DIR}/hyperopt_results_${TIMESTAMP}.json"
# 创建导出目录
mkdir -p ${OUTPUT_DIR}
echo "=== 导出 Hyperopt 结果 ==="
echo "输出文件: ${OUTPUT_FILE}"
echo ""
# 导出所有结果
docker-compose run --rm freqtrade hyperopt-list --print-json --no-color > ${OUTPUT_FILE}
# 统计结果数量
RESULT_COUNT=$(grep -c '"params"' ${OUTPUT_FILE})
echo ""
echo "=== 导出完成 ==="
echo "总计 ${RESULT_COUNT} 个结果"
echo "文件路径: ${OUTPUT_FILE}"
echo ""
# 显示前 5 个最佳结果的摘要
echo "=== 前 5 个最佳结果摘要 ==="
docker-compose run --rm freqtrade hyperopt-list --best -n 5 --no-color
# 可选:使用 jq 美化 JSON如果安装了 jq
if command -v jq &> /dev/null; then
echo ""
echo "=== 使用 jq 美化 JSON ==="
jq '.' ${OUTPUT_FILE} > ${OUTPUT_FILE}.pretty.json
echo "美化后的文件: ${OUTPUT_FILE}.pretty.json"
fi