TurtleTrade/pretest/get_data.py
2025-04-02 22:55:29 +08:00

28 lines
649 B
Python
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.

from data2sqlite import StockDataSystem
import time
# 收集数据
stock_system = StockDataSystem()
# 启动数据收集5分钟间隔
stock_system.start_collection(interval_minutes=5)
try:
# 保持主线程运行
while True:
time.sleep(1)
except KeyboardInterrupt:
# 当按下 Ctrl+C 时优雅地停止
stock_system.stop_collection()
print("数据收集已停止")
# 测试查找功能
# 查询示例
# code = "000001" # 平安银行
# df = stock_system.query_stock_data(
# code,
# start_time="2024-01-06 21:26:49",
# end_time="2024-01-06 21:33:40"
# )
# print(f"\n{code} 的数据:")
# print(df)