def data_to_csv(self, path_input):
"""
Output the data of your asset portfolio with the format '.csv' to the place you want.
"""
try:
for i in range(len(self.stocklist)):
self.stockdata[self.stocklist[i]]
except:
hs300_data = ts.get_hist_data('hs300', self.start, self.end)
self.stockdata['hs300'] = hs300_data['close']
for stock_single in self.stocklist:
self.stockdata[stock_single] = ts.get_hist_data(stock_single, self.start, self.end)['close']
data = self.stockdata
data.to_csv(path_input+'data.csv')
print("The file has been generated at ", path_input, ".")
评论列表
文章目录