def updating_stock_tick_data(root_path, exception_df, symbol, date_list):
file_path = root_path + "/Data/CSV/tick/" + symbol + "/"
exception_file = root_path + "/Data/CSV/exception/" + symbol + ".csv"
if os.path.exists(file_path) == False:
os.mkdir(file_path)
now_date = (datetime.datetime.now()).strftime("%Y-%m-%d")
need_update_exception = False
need_update_data = False
#pbar = trange(len(date_list), leave=False)
#for i in pbar:
temp_list = []
for date in date_list:
#start = time.time()
#date = date_list[i]
new_file_name = file_path + symbol + "_" + date + ".csv"
if os.path.exists(new_file_name):
continue
try:
temp_list.append(date)
data = ts.get_tick_data(symbol ,date=date, src ='tt')
except:
print("stock:", symbol, " date:", date, "get data failed")
if data is not None:
need_update_data = True
data.to_csv(new_file_name)
else:
need_update_exception = True
exception_df.loc[len(exception_df)] = [date, 1, now_date]
# print("tick data", symbol, date, "is None")
#outMessage = '%s processed in: %.4s seconds' % (date, (time.time() - start))
#pbar.set_description(outMessage)
if need_update_exception:
exception_df = exception_df.groupby(["date"]).agg({'retry':'sum', 'last_update':'max'}).reset_index()
exception_df.to_csv(exception_file)
if len(temp_list) > 0: print(symbol, temp_list)
return need_update_data
Filter_Stock_Cashflow_CHN.py 文件源码
python
阅读 30
收藏 0
点赞 0
评论 0
评论列表
文章目录