def load_klines_from_cache(self, kline_names: list=[]):
    '\n        从缓存加载K线数据\n        :param kline_names:\n        :return:\n        '
    if (len(kline_names) == 0):
        kline_names = list(self.klines.keys())
    save_path = self.cta_engine.get_data_path()
    file_name = os.path.abspath(os.path.join(save_path, f'{self.strategy_name}_klines.pkb2'))
    try:
        last_bar_dt = None
        with bz2.BZ2File(file_name, 'rb') as f:
            klines = pickle.load(f)
            for kline_name in kline_names:
                cache_kline = klines.get(kline_name, None)
                strategy_kline = self.klines.get(kline_name, None)
                if (cache_kline and strategy_kline):
                    cb_on_bar = strategy_kline.cb_on_bar
                    strategy_kline.__dict__.update(cache_kline.__dict__)
                    kline_first_bar_dt = None
                    kline_last_bar_dt = None
                    if (len(strategy_kline.line_bar) > 0):
                        kline_first_bar_dt = strategy_kline.line_bar[0].datetime
                        kline_last_bar_dt = strategy_kline.line_bar[(- 1)].datetime
                    if (last_bar_dt and strategy_kline.cur_datetime):
                        last_bar_dt = max(last_bar_dt, strategy_kline.cur_datetime)
                    else:
                        last_bar_dt = strategy_kline.cur_datetime
                    strategy_kline.strategy = self
                    strategy_kline.cb_on_bar = cb_on_bar
                    self.write_log(f'恢复{kline_name}缓存数据:[{kline_first_bar_dt}] => [{kline_last_bar_dt}], bar结束时间:{last_bar_dt}')
            self.write_log(u'加载缓存k线数据完毕')
            return last_bar_dt
    except Exception as ex:
        self.write_error(f'加载缓存K线数据失败:{str(ex)}')
    return None
从缓存加载K线数据
:param kline_names:
:return:
def load_klines_from_cache(self, kline_names: list=[]):
    '\n        从缓存加载K线数据\n        :param kline_names:\n        :return:\n        '
    if (len(kline_names) == 0):
        kline_names = list(self.klines.keys())
    save_path = self.cta_engine.get_data_path()
    file_name = os.path.abspath(os.path.join(save_path, f'{self.strategy_name}_klines.pkb2'))
    try:
        last_bar_dt = None
        with bz2.BZ2File(file_name, 'rb') as f:
            klines = pickle.load(f)
            for kline_name in kline_names:
                cache_kline = klines.get(kline_name, None)
                strategy_kline = self.klines.get(kline_name, None)
                if (cache_kline and strategy_kline):
                    cb_on_bar = strategy_kline.cb_on_bar
                    strategy_kline.__dict__.update(cache_kline.__dict__)
                    kline_first_bar_dt = None
                    kline_last_bar_dt = None
                    if (len(strategy_kline.line_bar) > 0):
                        kline_first_bar_dt = strategy_kline.line_bar[0].datetime
                        kline_last_bar_dt = strategy_kline.line_bar[(- 1)].datetime
                    if (last_bar_dt and strategy_kline.cur_datetime):
                        last_bar_dt = max(last_bar_dt, strategy_kline.cur_datetime)
                    else:
                        last_bar_dt = strategy_kline.cur_datetime
                    strategy_kline.strategy = self
                    strategy_kline.cb_on_bar = cb_on_bar
                    self.write_log(f'恢复{kline_name}缓存数据:[{kline_first_bar_dt}] => [{kline_last_bar_dt}], bar结束时间:{last_bar_dt}')
            self.write_log(u'加载缓存k线数据完毕')
            return last_bar_dt
    except Exception as ex:
        self.write_error(f'加载缓存K线数据失败:{str(ex)}')
    return None