def get_cn_furture_day(self, file_path, update=False):
        for future in self.future_list:

            url_str = (
                'http://stock2.finance.sina.com.cn/futures/api/json.php/IndexService.getInnerFuturesDailyKLine?symbol='
                + future)
            r = requests.get(url_str)
            r_json = r.json()
            r_lists = list(r_json)
            if update:  #更新
                r_lists = r_lists[-1]
            result = pd.DataFrame(
                data=r_lists,
                columns=['date', 'open', 'high', 'low', 'close', 'vol'])

            result = result.rename(columns={'vol': 'volume'})
            if update:
                result = cut_day_repeated_row(file_path + future + '.csv',
                                              result)
                result.to_csv(china_furture_day_file_path + future + '.csv',
                              index=False,
                              mode='a',
                              header=False)
            else:
                result.to_csv(china_furture_day_file_path + future + '.csv',
                              index=False)

            print('期货日线保存成功:', future)
        print('-------------------期货日线完成------------------------')
    def get_china_stock_day_data(self,
                                 stock_list,
                                 start_date,
                                 end_date,
                                 file_path,
                                 update=False,
                                 frequency="d"):  #获取国内日线
        if isinstance(stock_list, str):
            stock_list = [stock_list]
        for stock in stock_list:
            stock_code_ = ".".join(stock.lower().split('.')[::-1])
            rs = bs.query_history_k_data_plus(
                stock_code_,
                "date,code,open,high,low,close,volume,amount,turn,tradestatus,pctChg,isST,peTTM,pbMRQ,psTTM,pcfNcfTTM",
                start_date=start_date,
                end_date=end_date,
                frequency=frequency,
                adjustflag="2")
            data_list = []
            while (rs.error_code == '0') & rs.next():
                data_list.append(rs.get_row_data())
            result = pd.DataFrame(data_list, columns=rs.fields)
            if update:
                # with open(file_path+stock_code_+'.csv','a') as f:
                # f.write('\n')

                result = cut_day_repeated_row(file_path + stock_code_ + '.csv',
                                              result)

                result.to_csv(
                    file_path + stock_code_ + '.csv',
                    index=False,
                    mode='a',
                    header=False,
                )
            else:
                result.to_csv(file_path + stock_code_ + '.csv', index=False)
            print(" 国内日线完成:", stock_code_)
            # print( '进度:  %4.2f'% ((self.stock_list.index(stock)+1)/len(self.stock_list)))
        print('------------------国内日线成功---------------------------')
 def get_us_stock_day(self,
                      file_path,
                      update=False,
                      period='5y',
                      interval="1d"):
     stock_dir = {}
     for s in self.stock_list:
         stock_dir[s] = yf.Ticker(s)
     for key, values in stock_dir.items():
         if update:
             period = '5d'
             interval = '1d'
         result = values.history(period=period,
                                 interval=interval,
                                 start=None,
                                 end=None,
                                 prepost=False,
                                 actions=True,
                                 auto_adjust=True,
                                 back_adjust=False)
         result.columns = result.columns.map(str.lower)
         result.drop(['dividends', 'stock splits'], inplace=True, axis=1)
         result['date'] = result.index
         result['date'] = result['date'].apply(
             lambda x: x.strftime("%Y-%m-%d"))
         if update:
             result = cut_day_repeated_row(file_path + key + '.csv', result)
             result.to_csv(
                 us_stock_day_file_path + key + '.csv',
                 index=False,
                 mode='a',
                 header=False,
             )
         else:
             result.to_csv(us_stock_day_file_path + key + '.csv',
                           index=False)
         print('美股日线保存成功:', key)
     print('-------------------美股日线完成----------------------')