myTestFreqAI/REPAIR_GUIDE.md
2025-08-18 03:10:39 +08:00

108 lines
2.3 KiB
Markdown
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.

# 🚀 时间戳问题修复指南
## 📋 问题描述
当前出现大量交易对的错误:
```
WARNING - Unable to get latest candle (OHLCV) data for pair XXX/USDT - '>=' not supported between instances of 'Timestamp' and 'int'
```
## 🔍 根本原因
这个错误发生在**Freqtrade框架层面**,而不是策略代码,主要原因是:
1. 交易所API返回的时间戳格式不匹配
2. 缓存数据损坏
3. 时间配置问题
## ✅ 已完成的策略修复
我已经修复了策略中的以下问题:
- ✅ NaN值处理将默认值从`np.nan`改为`0.0`
- ✅ 时间戳转换:确保所有时间戳都是整数类型
- ✅ 数据验证:添加了长度一致性检查
- ✅ 数据清理处理无穷值和NaN值
## 🎯 系统级修复步骤
### 方法1快速重启推荐
```bash
# 1. 停止当前服务
pkill -f "freqtrade trade"
# 2. 清理缓存数据
cd /Users/zhangkun/myTestFreqAI
rm -rf user_data/data/*
# 3. 重启服务
freqtrade trade -c config.json
```
### 方法2使用修复脚本
```bash
# 运行修复脚本
cd /Users/zhangkun/myTestFreqAI
./system_restart.sh
```
### 方法3手动修复
1. **检查配置文件**
```bash
# 检查config.json是否存在时间配置问题
cat config.json | grep -E "timeframe|timezone"
```
2. **验证策略文件**
```bash
cd /Users/zhangkun/myTestFreqAI/freqtrade/templates
python3 -m py_compile freqaiprimer.py
```
3. **清理并重启**
```bash
# 清理缓存
rm -rf user_data/data/*
rm -rf user_data/cache/*
# 重启
freqtrade trade -c config.json
```
## 📊 验证修复效果
重启后观察日志:
```bash
# 实时查看日志
tail -f freqtrade.log | grep -E "Timestamp|get_latest"
```
修复成功的标志:
- ✅ 不再出现时间戳错误
- ✅ 交易对能够正常获取数据
- ✅ 策略正常运行
## 🚨 如果问题仍然存在
1. **检查交易所配置**
- 确认API密钥有效
- 检查网络连接
- 验证交易所状态
2. **更新Freqtrade**
```bash
git pull origin develop
pip install -e .
```
3. **联系支持**
- 检查Freqtrade GitHub issues
- 查看官方文档
## 🎉 预期结果
执行修复后,应该看到:
- 时间戳错误消失
- 所有交易对正常获取OHLCV数据
- 策略正常执行交易逻辑