def query_bar_history(self, req: HistoryRequest) -> Optional[List[BarData]]: """查询k线数据""" # 初始化API try: api: TqApi = TqApi(auth=TqAuth(self.username, self.password)) except Exception: traceback.print_exc() return None # 查询数据 # 888 主力:m # 000 指数:i if req.symbol.find("888") > 0 : req.symbol = req.symbol.rstrip("888") tq_symbol: str = f"KQ.m@{req.exchange.value}.{req.symbol}" elif req.symbol.find("000") > 0: req.symbol = req.symbol.rstrip("000") tq_symbol: str = f"KQ.i@{req.exchange.value}.{req.symbol}" else: tq_symbol: str = f"{req.exchange.value}.{req.symbol}"
标签:vnpy,req,tqsdk,exchange,symbol,888,tq,合约,self From: https://www.cnblogs.com/kingkaixuan/p/17035406.html