Reputation: 57
I am having a problem executing this code.
import datetime as dt
import matplotlib.pyplot as plt from matplotlib
import style import pandas as pd
import pandas_datareader.data as web
style.use('ggplot')
start=dt.datetime(2000,1,1)
end=dt.datetime(2016,12,31)
df= web.DataReader('TSLA', 'yahoo', start, end)
print(df.head())
I am facing this error:
ConnectionError(e, request=request) requests.exceptions.
ConnectionError:
HTTPConnectionPool(host='ichart.finance.yahoo.com', port=80):
Max retries exceeded with url: /table.csv?>s=TSLA&f=2016&g=d&b=1&d=11&e=31&ignore=.csv&c=2000&a=0
(Caused by NewConnectionError(': Failed to establish a new connection: [Errno 11001] getaddrinfo failed',))
Upvotes: 0
Views: 674
Reputation: 57
It was so simple!
replace yahoo with google in code.
running code:
import datetime as dt
import matplotlib.pyplot as plt
from matplotlib import style
import pandas as pd
import pandas_datareader.data as web
import numpy as np
style.use('ggplot')
start=dt.datetime(2000,1,1)
end=dt.datetime(2016,12,31)
df= web.DataReader('ERIE', 'google', start, end)
print(df.head())
But still, this code has a drawback.
KUSHAL
Upvotes: 1
Reputation: 360
The financial API provided by Yahoo was discontinued. This feature won't be provided anymore :
https://forums.yahoo.net/t5/Yahoo-Finance-help/Is-Yahoo-Finance-API-broken/td-p/250503
Upvotes: 2