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()
|