QTrade/check_precision.py

54 lines
1.4 KiB
Python
Raw Normal View History

"""验证159915.SZ的数据精度"""
import pymysql
conn = pymysql.connect(
host="localhost", user="root", password="1234", database="qtrade_backtest"
)
cursor = conn.cursor()
# 查看159915.SZ的1m数据样例
print("159915.SZ的1m数据样例(最近10条):")
cursor.execute("""
SELECT timestamp, open, high, low, close
FROM klines_1m
WHERE symbol='159915.SZ'
ORDER BY timestamp DESC
LIMIT 10
""")
rows = cursor.fetchall()
for row in rows:
print(f"时间: {row[0]}, 开: {row[1]}, 高: {row[2]}, 低: {row[3]}, 收: {row[4]}")
# 查看159915.SZ的1d数据样例
print("\n159915.SZ的1d数据样例(最近10条):")
cursor.execute("""
SELECT timestamp, open, high, low, close
FROM klines_1d
WHERE symbol='159915.SZ'
ORDER BY timestamp DESC
LIMIT 10
""")
rows = cursor.fetchall()
for row in rows:
print(f"时间: {row[0]}, 开: {row[1]}, 高: {row[2]}, 低: {row[3]}, 收: {row[4]}")
# 检查是否有3位小数的价格
print("\n检查是否有3位小数的价格(例如 x.xx5, x.xx1 等):")
cursor.execute("""
SELECT timestamp, close
FROM klines_1m
WHERE symbol='159915.SZ'
AND (close * 1000) % 10 != 0
LIMIT 5
""")
rows = cursor.fetchall()
if rows:
print("找到3位小数的价格:")
for row in rows:
print(f" 时间: {row[0]}, 收盘: {row[1]}")
else:
print("未找到3位小数的价格,可能数据被截断了")
conn.close()