from jqdatasdk import * auth('18616891214','Ea?*7f68nD.dafcW34d!') from sqlalchemy import create_engine import pandas as pd import datetime engine = create_engine('mysql+pymysql://root:r6kEwqWU9!v3@localhost:3307/hlfx_pool?charset=utf8') fre = '1d' pool =pd.read_sql_table('%s' % fre, con=engine).iloc[-1,2] stock_pool = pool.split(",") print(type(pool),pool) print(item for item in pool) print(type(stock_pool),stock_pool) print(item for item in stock_pool) # 22 # 11 # 1234 # 33 # futures = ['IF9999.CCFX', 'IC9999.CCFX','IH9999.CCFX', 'IM9999.CCFX', 'FU9999.XSGE', 'RB9999.XSGE', 'MA9999.XZCE', 'TA9999.XZCE', 'SA9999.XZCE', 'M9999.XDCE', 'LH9999.XDCE'] # # for fre in ['30m','1d','5m']: # for future in futures: # df_future = get_price(future, start_date='2015-01-01', end_date='2022-09-25', frequency=fre, fields=None, skip_paused=False, fq='pre' ,panel=True) # # # 去除无数据日 # df_future = df_future.dropna(axis=0) # # 重置index # df_future.reset_index(inplace=True) # # 保留日期数据 # df_future.rename(columns={'index': 'date'}, inplace=True) # print(df_future) # # 写入数据库 # df_future.to_sql('%s_%s' % (future, fre), con=engine, if_exists='append') # with engine.connect() as con: # con.execute("ALTER TABLE `%s_%s` ADD PRIMARY KEY (`date`);" % (future, fre))