def _init_callback(self):
    self._ticker_queues = {}
    self._price_queues = {}
    self._trigger_queue = Queue()
    self._resample_thread = {}

    @on_login_reply
    def login_reply(user_id, ret_code, ret_msg):
        if (ret_code == 0):
            api_logger.info(f'@{user_id.decode()}登录成功')
            self._init_subscribe()
        else:
            api_logger.error(f'@{user_id.decode()}登录失败--errcode:{ret_code}--errmsg:{ret_msg.decode()}')

    @on_instrument_list_reply
    def inst_list_reply(req_id, is_ready, ret_msg):
        if is_ready:
            api_logger.info(('<产品>' + f'信息加载成功      req_id:{req_id}-msg:{ret_msg.decode()}'))
        else:
            api_logger.error(('<产品>' + f'信息正在加载......req_id{req_id}-msg:{ret_msg.decode()}'))

    @on_product_list_by_code_reply
    def product_list_by_code_reply(req_id, inst_code, is_ready, ret_msg):
        if is_ready:
            if (inst_code == ''):
                api_logger.info(('<合约>' + f'该产品系列没有合约信息      req_id:{req_id}-msg:{ret_msg.decode()}'))
            else:
                api_logger.info(('<合约>' + f'产品:{inst_code.decode()}合约信息加载成功      req_id:{req_id}-msg:{ret_msg.decode()}'))
        else:
            api_logger.error(('<合约>' + f'产品:{inst_code.decode()}合约信息正在加载......req_id:{req_id}-msg:{ret_msg.decode()}'))

    @on_business_date_reply
    def business_date_reply(business_date):
        self.trade_date = dt.datetime.fromtimestamp(business_date)
        api_logger.info(('<日期>' + f'当前交易日--{self.trade_date}'))

    @on_ticker_update
    def ticker_update(ticker: SPApiTicker):
        ticker_dict = _convert_from_ctype(ticker)
        self._ticker_queues[ticker_dict['ProdCode']].put(ticker_dict)
        api_logger.info(f'{ticker_dict}')

    @on_api_price_update
    def price_update(price: SPApiPrice):
        price_dict = _convert_from_ctype(price)
        self._price_queues[price_dict['ProdCode']].append(price_dict)
        api_logger.info(f'{price_dict}')

    @on_connecting_reply
    def connecting_reply(host_id, con_status):
        api_logger.info(f'<连接>{HOST_TYPE[host_id]}状态改变--{HOST_CON_STATUS[con_status]}')
    self.on_login_reply = login_reply
    self.inst_list_reply = inst_list_reply
    self.product_list_by_code_reply = product_list_by_code_reply
    self.business_date_reply = business_date_reply
    self.ticker_update = ticker_update
    self.price_update = price_update
    self.connecting_reply = connecting_reply
def _init_callback(self):
    self._ticker_queues = {}
    self._price_queues = {}
    self._trigger_queue = Queue()
    self._resample_thread = {}

    @on_login_reply
    def login_reply(user_id, ret_code, ret_msg):
        if (ret_code == 0):
            api_logger.info(f'@{user_id.decode()}登录成功')
            self._init_subscribe()
        else:
            api_logger.error(f'@{user_id.decode()}登录失败--errcode:{ret_code}--errmsg:{ret_msg.decode()}')

    @on_instrument_list_reply
    def inst_list_reply(req_id, is_ready, ret_msg):
        if is_ready:
            api_logger.info(('<产品>' + f'信息加载成功      req_id:{req_id}-msg:{ret_msg.decode()}'))
        else:
            api_logger.error(('<产品>' + f'信息正在加载......req_id{req_id}-msg:{ret_msg.decode()}'))

    @on_product_list_by_code_reply
    def product_list_by_code_reply(req_id, inst_code, is_ready, ret_msg):
        if is_ready:
            if (inst_code == ):
                api_logger.info(('<合约>' + f'该产品系列没有合约信息      req_id:{req_id}-msg:{ret_msg.decode()}'))
            else:
                api_logger.info(('<合约>' + f'产品:{inst_code.decode()}合约信息加载成功      req_id:{req_id}-msg:{ret_msg.decode()}'))
        else:
            api_logger.error(('<合约>' + f'产品:{inst_code.decode()}合约信息正在加载......req_id:{req_id}-msg:{ret_msg.decode()}'))

    @on_business_date_reply
    def business_date_reply(business_date):
        self.trade_date = dt.datetime.fromtimestamp(business_date)
        api_logger.info(('<日期>' + f'当前交易日--{self.trade_date}'))

    @on_ticker_update
    def ticker_update(ticker: SPApiTicker):
        ticker_dict = _convert_from_ctype(ticker)
        self._ticker_queues[ticker_dict['ProdCode']].put(ticker_dict)
        api_logger.info(f'{ticker_dict}')

    @on_api_price_update
    def price_update(price: SPApiPrice):
        price_dict = _convert_from_ctype(price)
        self._price_queues[price_dict['ProdCode']].append(price_dict)
        api_logger.info(f'{price_dict}')

    @on_connecting_reply
    def connecting_reply(host_id, con_status):
        api_logger.info(f'<连接>{HOST_TYPE[host_id]}状态改变--{HOST_CON_STATUS[con_status]}')
    self.on_login_reply = login_reply
    self.inst_list_reply = inst_list_reply
    self.product_list_by_code_reply = product_list_by_code_reply
    self.business_date_reply = business_date_reply
    self.ticker_update = ticker_update
    self.price_update = price_update
    self.connecting_reply = connecting_reply