def parseSelectedFoundData(self, code): """ :param code: 选定的基金代码 :return: None """ parser = parseFoundsJsFile() parser.openFoundHistoryDataFile(code) # 根据下载到的基金js文件解析基金相信信息 self.foundHistoryData = parser.parsedFoundsData # 获得解析到的基金数据信息 # self.foudDataToShow = self.foundHistoryData self.showSelectedFoundData(self.foundHistoryData)
def __init__(self): self.fig = Figure() self.ax = self.fig.add_subplot(111) FigureCanvas.__init__(self, self.fig) # self.setParent(parent) FigureCanvas.setSizePolicy(self, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) FigureCanvas.updateGeometry(self) self.fig.autofmt_xdate() self.ax.set_title("Pure value trend") self.ax.set_xlabel("time of data generator") self.ax.set_ylabel('value') # self.ax.set_ylim(Y_MIN, Y_MAX) self.ax.xaxis.set_major_formatter( dates.DateFormatter('%Y/%m/%d')) # tick label formatter self.ax.xaxis.set_minor_locator(dates.MonthLocator()) self.parser = parseFoundsJsFile('001186.js') self.parser.openFile() times, values = self.parser.getRealTimeAndValue() self.plot(times, values, 'r') # self.gcf().autofmt_xdate() # 自动旋转日期标记 # 计算众数 mass = mode(values) print("Mass is: ") print(mass) index = 0 massTimes = [] massValues = [] for each in values: index += 1 if each == mass[0].tolist()[0]: massTimes.append(times[index]) massValues.append(each) print(index) self.plot(massTimes, massValues, 'b') self.ax.legend()
def parseAllFoundsDataToCsv(self, list): parser = parseFoundsJsFile() for each in list: try: parser.openFoundHistoryDataFile(each) parser.getNatualTimeAndValue(True, each, 'csvFile\\') except Exception as e: print(e) print('解析:%s 基金文件失败,请检查' % each) continue print('解析所有基金完毕...') self.analyseAllFoudsDataFromCsv(list)
def showFoundTrendData(self, foundCode='001186'): self.ax.set_title("Pure value trend") self.ax.set_xlabel("time of data generator") self.ax.set_ylabel('value') # self.ax.set_ylim(Y_MIN, Y_MAX) self.ax.xaxis.set_major_formatter( dates.DateFormatter('%Y/%m/%d')) # tick label formatter self.ax.xaxis.set_minor_locator(dates.MonthLocator()) self.parser = parseFoundsJsFile() self.parser.openFoundHistoryDataFile(foundCode) times, values = self.parser.getNatualTimeAndValue() self.plot(times, values, 'r') # self.gcf().autofmt_xdate() # 自动旋转日期标记 # 计算众数 mass = mode(values) print("Mass is: ") print(mass) index = 0 massTimes = [] massValues = [] for each in values: index += 1 if each == mass[0].tolist()[0]: massTimes.append(times[index]) massValues.append(each) print(index) self.plot(massTimes, massValues, 'b') self.ax.legend()
daily_data = pd.concat([index_data, temp[['总基金份额', '总理财份额', '累计定投资金']]], axis=1, join='inner') daily_data['基金定投资金'] = daily_data['value'] * daily_data['总基金份额'] # daily_data['基金定投资金'] = daily_data['value'] / 1000 * daily_data['总基金份额'] daily_data['理财定投资金'] = daily_data['无风险收益_净值'] * daily_data['总理财份额'] return daily_data def custom_resampler(array_like): return np.sum(array_like) + 5 if __name__ == '__main__': parser = parseFoundsJsFile() foundCode = '110022' aa = parser.parseFoundsCompanyListData( saveFlag=True, fileDir='../AnalyseFounds/foundJsFile/') parser.parseFoundRealTimeData(foundCode, fileDir='../AnalyseFounds/foundJsFile/') parser.openFoundHistoryDataFile(foundCode, fileDir='../AnalyseFounds/foundJsFile/') parser.getNatualTimeAndValue(True, foundCode) # 运行程序 # df = automatic_investment_plan('sh000001', '2013-01-04', '2014-12-31') foundNum = '110022' investDays = ['first', 'median', 'last', 'min', 'max'] roiList = []