I am having an error related to web.datareader. For some reason I can't figure out what is causing it. Any ideas?
!pip install mplfinance
!pip install seaborn
!pip install matplotlib
import numpy as np
import pandas as pd
import mplfinance as mpf
import datetime as dt
import matplotlib.pyplot as plt
import seaborn as sns
currency = "USD"
metric = "Close"
start = dt.datetime(2018,1,1)
end = dt.datetime.now()
crypto = ['BTC', 'ETH', 'LTC', 'XRP', 'DASH', 'SC']
colnames = []
first = True
for ticker in crypto:
data = web.DataReader(f"{ticker}-{currency}", "yahoo", start, end)
if first:
combined = data[[metric]].copy()
colnames.append(ticker)
combined.columns = colnames
first = False
else:
combined = combined.join(data[metric])
colnames.append(ticker)
combined.columns = colnames
plt.yscale('log') # first show linear
for ticker in crypto:
plt.plot(combined[ticker], label=ticker)
plt.legend(loc="upper right")
plt.show()
# # Correlation Heat Map
print(combined)
combined = combined.pct_change().corr(method='pearson')
sns.heatmap(combined, annot=True, cmap="coolwarm")
plt.show()
You are missing two lines:
!pip install pandas-datareader
import pandas_datareader as web
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.