交作业
来源:3-8 【作业】:比较3只股票的累计收益率,并进行可视化

逆天而行Gavin
2022-01-05
stocks = [
{'name': '平安银行', 'code': '000001.XSHE'},
{'name': '宏华数科', 'code': '688789.XSHG'},
{'name': '苑东生物', 'code': '688513.XSHG'}
]
df_cum_profit = pd.DataFrame()
for stock in stocks:
df = week_period_strategy(stock['code'], 'daily', '2021-07-12', datetime.date.today())
df_cum_profit[stock['name']] = df['cum_profit']
print(df_cum_profit)
print(df_cum_profit.describe())
df_cum_profit.plot()
plt.rcParams['font.family'] = ['SimHei'] #需要安装配置中文字体
plt.rcParams['axes.unicode_minus'] = False
plt.title('周期策略下(周四买入周一卖出)三支股票的累计收益率')
plt.show()
写回答
1回答
-
DeltaF
2022-01-05
棒棒哒,祝你学习愉快
00