def OnRspUserLogin(self, pRspUserLogin, pRspInfo, nRequestID, bIsLast): if pRspInfo.ErrorID == 0: log.info('登录成功,开始订阅合约 {}'.format(self.instrument_ids)) self.SubscribeMarketData(self.instrument_ids) else: log.error('登录失败 ErrorID: {} ErrorMsg: {}'.format( pRspInfo.ErrorID, pRspInfo.ErrorMsg))
def OnRspUserLogin(self, pRspUserLogin, pRspInfo, nRequestID, bIsLast): assert isinstance(pRspInfo, ApiStruct.RspInfo) if pRspInfo.ErrorID == 0: log.info('登录成功') self.login_success = True else: log.error('登录失败 ErrorID: {}, ErrorMsg: {}'.format( pRspInfo.ErrorID, pRspInfo.ErrorMsg.decode('gbk')))
def flush_points(self, points): try: self.client.write_points(points) except Exception as e: log.error( 'influxdb client write points error: {}, points: {}'.format( e, points)) del points[:]
def batch_insert_worker(self, batch_size): points = [] while True: try: try: item = self.batch_queue.get(timeout=0.5) except Empty: if len(points) > 0: self.client.write_points(points) continue point = self.convert_to_point(item) points.append(point) if len(points) < batch_size: continue self.flush_points(points) except Exception as e: log.error('batch insert unexpected error: {}'.format(e))
def OnRspError(self, pRspInfo, nRequestID, bIsLast): log.error('发生错误 ErrorID: {} ErrorMsg: {}'.format( pRspInfo.ErrorID, pRspInfo.ErrorMsg.decode('gbk')))
def OnFrontDisconnected(self, nReason): log.error('客户端无法注册服务器地址, ErrorID: {}'.format(nReason))
def OnFrontDisconnected(self, nReason): log.error('客户端无法注册服务器地址: ', nReason)