myTestFreqAI/apply_dataframe_fix.sh
2025-08-18 03:10:39 +08:00

84 lines
2.5 KiB
Bash
Executable File
Raw 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
# DataFrame长度修复脚本
# 这个脚本会应用DataFrame长度验证修复解决"Dataframe returned from strategy has mismatching length"问题
echo "🚀 开始应用DataFrame长度修复..."
# 检查是否提供了配置文件路径
CONFIG_FILE="${1:-config.json}"
# 停止freqtrade服务
echo "📍 停止freqtrade服务..."
pkill -f freqtrade 2>/dev/null || true
sleep 3
# 备份当前策略文件
echo "📁 备份当前策略文件..."
cp /Users/zhangkun/myTestFreqAI/freqtrade/templates/freqaiprimer.py /Users/zhangkun/myTestFreqAI/freqtrade/templates/freqaiprimer.py.backup.$(date +%Y%m%d_%H%M%S)
# 清理缓存数据
echo "🧹 清理缓存数据..."
rm -rf /Users/zhangkun/myTestFreqAI/user_data/data/*
rm -rf /Users/zhangkun/myTestFreqAI/user_data/cache/*
# 验证配置文件
echo "⚙️ 验证配置文件..."
if [ -f "$CONFIG_FILE" ]; then
echo "✅ 配置文件存在: $CONFIG_FILE"
# 检查配置文件语法
python3 -c "import json; json.load(open('$CONFIG_FILE'))" && echo "✅ 配置文件语法正确" || {
echo "❌ 配置文件语法错误"
exit 1
}
else
echo "❌ 配置文件不存在: $CONFIG_FILE"
exit 1
fi
# 验证策略文件语法
echo "🔍 验证策略文件语法..."
cd /Users/zhangkun/myTestFreqAI
python3 -c "
import sys
sys.path.append('.')
from freqtrade.templates.freqaiprimer import FreqaiExampleStrategy
print('✅ 策略文件语法验证通过')
" || {
echo "❌ 策略文件语法错误"
exit 1
}
# 启动freqtrade服务
echo "🚀 启动freqtrade服务..."
nohup python3 -m freqtrade trade -c "$CONFIG_FILE" > freqtrade.log 2>&1 &
PID=$!
echo "✅ freqtrade已启动PID: $PID"
echo "📊 日志文件: freqtrade.log"
# 等待服务启动
echo "⏳ 等待服务启动..."
sleep 5
# 检查服务状态
if ps -p $PID > /dev/null; then
echo "✅ 服务启动成功!"
echo "📝 监控日志: tail -f freqtrade.log"
else
echo "❌ 服务启动失败,请检查日志"
exit 1
fi
echo ""
echo "🎯 修复完成!"
echo "修复内容:"
echo " • 添加了DataFrame长度验证和修复机制"
echo " • 修复了populate_indicators方法的长度问题"
echo " • 修复了populate_entry_trend方法的长度问题"
echo " • 修复了populate_exit_trend方法的长度问题"
echo " • 清理了缓存数据"
echo ""
echo "📋 使用说明:"
echo " 1. 运行: ./apply_dataframe_fix.sh [配置文件]"
echo " 2. 监控: tail -f freqtrade.log"
echo " 3. 停止: pkill -f freqtrade"