def __init__(self, symbol, *args):
super().__init__()
self.data = pd.read_csv(open(r"Stock_Data/{}.csv".format(symbol)))
self.data = self.data.apply(pd.to_numeric, errors="ignore")
self.data.index = self.data["Quarter end"]
self.name = symbol
if self.data["Price"].dtype in (int, float) and self.data["Cumulative dividends per share"].dtype in (int, float):
self.data["Value"] = self.data["Price"] + self.data["Cumulative dividends per share"]
# Calculation of the estimated return
self.data["Estimated Return"] = self.data["Value"].pct_change()
# Calculation of the standard deviation
self.data["Standard Deviation"] = self.data["Value"].std()
else:
self.complete_pricelist = False
评论列表
文章目录