from datetime Import datetime, DATE, timedelta Import matplotlib.pyplot AS PLT Import tushare AS TS plt.rcParams [ ' font.sans serif- ' ] = [ ' SimHei ' ] # Display Chinese plt.rcParams [ ' axes.unicode_minus ' ] = false # for normal display negative DEF get_riqi (): COUNT = 30 I = 0 today = date.today () # today's date riqi_list = [] riqi_list.append (STR (today)) while(i<=count): i+=1 riqi_list.append(str((today + timedelta(days=-i)))) return riqi_list def count(Data): data_list = [] sum_list = [] for data in Data: sum = 0 list = [] for jiage in data: sum+=jiage list.append(jiage) sum_list.append(round(sum,2)) data_list.append (List) return sum_list, DATA_LIST DEF get_juedui (the Data): SUM = 0 Data = [] for I in the Data [:: -. 1 ]: SUM + = I data.append (SUM) return Data Technology = { ' Hikvision ' : ' 002415 ' , ' ZTE ' : ' 000063 ' , ' iFLYTEK ' : '002 230 ' , ' sophisticated telecommunications legislation ' : ' 002475 ' , ' Blue Synopsys ' : ' 300433 ' , ' GoerTek stock ' : ' 002 241 ' } Store = [Technology] Technology = [] DEF get_Data (Store, riqi_list): COUNT = 0 for Stock_pool in Store: COUNT + =. 1 for Stock in Stock_pool.values(): data = ts.get_hist_data(stock,start=riqi_list[-1]) if (count == 1): technology.append(data.loc[:, 'p_change']) riqi_list = get_riqi() get_data(store,riqi_list) riqi_list = technology[0].index rili = [] for riqi in riqi_list: rili.append(riqi[5:]) sum2,data2 = count(technology) riqi_list = [datetime.strptime(d, '%m-%d' ) .Date () for D in Rili] COUNT = 0 for I in DATA2: COUNT +. 1 = Data = get_juedui (I) IF (COUNT ==. 1 ): plt.plot (Rili [:: -1], Data , label = ' hikvision ' ) IF (COUNT == 2 ): plt.plot (Rili [:: -1], Data, label = ' ZTE ' ) IF (COUNT ==. 3 ): plt.plot (Rili [:: -1], Data, label = ' iFLYTEK ') IF (COUNT ==. 4 ): plt.plot (Rili [:: -1], Data, label = ' Luxshare ' ) IF (COUNT ==. 5 ): plt.plot (Rili [:: -1] , the Data, = label ' blue Synopsys ' ) IF (COUNT == 6 ): plt.plot (Rili [:: -1], the Data, label = ' song of Seoul shares ' ) plt.legend () plt.show ( )