소스 검색

修改数据库起始时间

daniel-ali 2 년 전
부모
커밋
774fd34b06
1개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 2
      update_data_tosql.py

+ 2 - 2
update_data_tosql.py

@@ -8,7 +8,7 @@ auth('18616891214', 'Ea?*7f68nD.dafcW34d!')
 stocks = list(get_all_securities(['stock'], date=dt.today().strftime('%Y-%m-%d')).index)
 engine = create_engine('mysql+pymysql://root:r6kEwqWU9!v3@localhost:3307/stocks?charset=utf8')
 
-for fre in ['30m', '1d']:
+for fre in ['1d', '30m']:
     print('ready to write to mysql %s' % fre)
     for stock in stocks:
         print(stock)
@@ -31,7 +31,7 @@ for fre in ['30m', '1d']:
             df_stock.index = df_stock.index + index_len + 1
             df_stock.to_sql('stk%s_%s' % (stock, fre), con=engine, index=True, if_exists='append')
         except BaseException:
-            df_stock = get_price(stock, start_date='2022-01-01 00:00:00', end_date=dt.today().strftime('%Y-%m-%d %H:%M:%S'),
+            df_stock = get_price(stock, start_date='2008-01-01 00:00:00', end_date=dt.today().strftime('%Y-%m-%d %H:%M:%S'),
                                  frequency=fre, fields=['open', 'close', 'high', 'low', 'volume', 'money'],
                                  skip_paused=False,
                                  fq='pre', count=None, panel=False)