import os import datetime import pandas as pd import matplotlib.pyplot as plt import util.sheep as sheep import util.basic as basic tool = basic.basic() labels = ['low_ma5', 'low', 'ma1', 'ma5'] # labels = ['low_ma5'] path = 'D:\\workgit\\stock\\util\\stockdata\\' today = datetime.datetime.today().date() while (not os.path.isfile(path + str(today) + '\data.csv')) or ( not os.path.isfile(path + str(today) + '\daily-basic.csv')) or ( not os.path.isfile(path + str(today) + '\stock-label.csv')): today = today - datetime.timedelta(1) print(today) stock_label = pd.read_csv(path + str(today) + '\stock-label.csv', index_col=0, dtype={'trade_date': object}) data = pd.read_csv(path + str(today) + '\data.csv', index_col=0, dtype={'trade_date': object}) print(data.shape[0], data.shape[0] / 3600) stock_baisc = pd.read_csv( path + str(today) + '\daily-basic.csv',
import util.basic as basic t=basic.basic() all=t.trade_daily(cal=240) pre_n=t.pre_date(all[["trade_date"]]) all=all.merge(pre_n,on="trade_date") df=all[["ts_code","trade_date","low"]].rename({"trade_date":"p1","low":"pre_low"}) # all["up_avg"] = all.apply(lambda x: 1 if x["avg"] - x["pre_avg"] > 0 else 0, axis=1) # all["up_ma"] = all.apply(lambda x: 1 if x["ma"] - x["pre_ma"] > 0 else 0, axis=1) all["low>pre"] = all.apply(lambda x: 1 if x["low"] > x["pre_low"] else 0, axis=1)