新增: - README.md: 完整的项目说明文档 - 系统简介和核心特性 - 技术栈和目录结构 - 快速开始和配置说明 - 使用示例和开发文档 - 数据表设计和扩展指南 - 更新日志和常见问题 整理: - 移动临时测试脚本到 tests/temp/ 目录 - check_1m_data.py - check_indicators.py - check_precision.py - check_tables.py - check_table_structure.py - test_calc_indicators.py
45 lines
1.1 KiB
Python
45 lines
1.1 KiB
Python
"""检查指标数据"""
|
||
|
||
import pymysql
|
||
|
||
conn = pymysql.connect(
|
||
host="localhost", user="root", password="1234", database="qtrade_backtest"
|
||
)
|
||
cursor = conn.cursor()
|
||
|
||
# 检查各个指标表的数据
|
||
indicators = ["macd", "kdj", "boll", "rsi"]
|
||
periods = ["1m", "1d"]
|
||
symbol = "159915.SZ"
|
||
|
||
print(f"检查 {symbol} 的指标数据:\n")
|
||
|
||
for period in periods:
|
||
print(f"=== {period} 周期 ===")
|
||
for indicator in indicators:
|
||
table_name = f"indicators_{period}_{indicator}"
|
||
cursor.execute(f"SELECT COUNT(*) FROM {table_name} WHERE symbol='{symbol}'")
|
||
count = cursor.fetchone()[0]
|
||
print(f" {indicator}: {count} 条")
|
||
print()
|
||
|
||
# 查看MACD 1m的样例数据
|
||
print("MACD 1m 样例数据(最近5条):")
|
||
cursor.execute("""
|
||
SELECT timestamp, symbol, macd_dif, macd_dea, macd_histogram
|
||
FROM indicators_1m_macd
|
||
WHERE symbol='159915.SZ'
|
||
ORDER BY timestamp DESC
|
||
LIMIT 5
|
||
""")
|
||
rows = cursor.fetchall()
|
||
if rows:
|
||
for row in rows:
|
||
print(
|
||
f" {row[0]} | {row[1]} | DIF:{row[2]:.6f} | DEA:{row[3]:.6f} | MACD:{row[4]:.6f}"
|
||
)
|
||
else:
|
||
print(" 无数据")
|
||
|
||
conn.close()
|