加载启动

进入VN Trader后,首先登陆接口,如连接CTP;然后在菜单栏中点击“功能”->”行情记录“后,会弹出行情记录窗口,如图。https://vnpy-community.oss-cn-shanghai.aliyuncs.com/forum_experience/yazhang/data_recoder/datarecoder.png

此时行情记录模块的启动状态为True,会启动while循环,可以添加任务实现实时行情记录。

  1. def start(self):
  2. """"""
  3. self.active = True
  4. self.thread.start()
  5.  
  6. def run(self):
  7. """"""
  8. while self.active:
  9. try:
  10. task = self.queue.get(timeout=1)
  11. task_type, data = task
  12.  
  13. if task_type == "tick":
  14. database_manager.save_tick_data([data])
  15. elif task_type == "bar":
  16. database_manager.save_bar_data([data])
  17.  
  18. except Empty:
  19. continue