I am trying to get all historical data from coinbase for bitcoin from the start
of 2016 to present day. I know there are many approaches like using an API ,
scraping tables but I am trying to read the page as an HTML and still I am
getting the encoding the error.
import pandas as pd
import time
import seaborn as sns
import matplotlib.pyplot as plt
import datetime
import numpy as np
# get market info for bitcoin from the start of 2016 to the current day
bitcoin_market_info = pd.read_html("https://coinmarketcap.com/currencies/bitcoin/historical-data/?start=20130428&end="+time.strftime("%Y%m%d"))[0]
I get the error as TypeError: __init__() got an unexpected keyword argument 'encoding'
I have done other steps to prevent this error like checking
pd_version as it is greater than 0.15 and even using different encoding such as
encoding = 'utf-8', encoding='big5hkscs'
I also checked htlm5lib and its already installed so can anyone tell me how to get data from this method only as it is used here in this article.
crypto price prediction
Related
I am following a tutorial online to use Python to determine financial returns. I am getting an error "TypeError: line() got an unexpected keyword argument 'reuse_plot'" when I am following the video content. I am very new to Python and I really do not understand why.
Here is the total code:
import datetime as dt
import pandas as pd
import numpy as np
import pylab
import seaborn as sns
import scipy.stats as stats
from pandas_datareader import data as pdr
import plotly.offline as pyo
pyo.init_notebook_mode(connected=True)
pd.options.plotting.backend = 'plotly'
end = dt.datetime.now()
start = dt.datetime(2018,1,1)
df = pdr.get_data_yahoo('CBA.AX', start, end)
df.Close.plot()
This error occurs due to conflicts between pandas and plotly packages. I could solve it by upgrading the pandas to the latest version (I can confirm that for pandas==1.3.5 and plotly==5.7.0, the error is not generated anymore).
I`m trying to access the TSLA stock data but the data doesn't seem to have accounted for the split earlier this year. The Alpha_Vantage website claims that it will be set to adjust=true as default but this doesn't seem to be the case, I tried to specify adjust=true but this returned an unexpected keyword error.
from alpha_vantage.timeseries import TimeSeries
import pandas as pd
ts = TimeSeries(key= api_key, output_format='pandas'
data, meta_data = ts.get_daily(self.symbol, outputsize='full')
#tried ts.get_daily(self.symbol, outputsize='full') but still no luck. The image ive added shows the data in a graph. the crash, i believe is a split
from alpha_vantage.timeseries import TimeSeries
import pandas as pd
ts = TimeSeries(key= api_key, output_format='pandas')
data, meta_data = ts.get_daily_adjusted(self.symbol, outputsize='full')
Here's the method to get split adjusted closings.
I am trying to import stock data using Yahoo API as a source. I have tried it many times and I always get the same error, the start and end date are different from what I have passed. For example I pass the start and end date as '2015-1-1' & '2017-1-1' but the stock data I get start and ends at '2014-12-31' & '2016-12-30'. I dont know what I am doing wrong. I even tried using google but got a error as "data_sorce='google' not implemented."
Is there some other free data source I can use or correct the dates while using Yahoo? Jupyter notebook
You can import as yfinance and just enter a start and end when importing the data. Yahoo decommissioned their historical data API check out the Ran Aroussi the developer's of fix-yahoo-finance which is now yfinance blog where he details everything nicely https://aroussi.com/post/python-yahoo-finance
To install/upgrade yfinance using pip, run:
$ pip install yfinance
instead of this method
facebook = web.DateReader("FB", "yahoo", start, end)
can be in a format like this instead
override method from pandas_datareader by importing data as pdr
import yfinance as yf
yf.pdr_override() # <== the override :-)
# download dataframe using pandas_datareader
facebook = pdr.get_data_yahoo("FB", start="2015-1-1", end="2017-1-1")
or you can just use yfinance instead
import yfinance as yf
facebook = yf.download("FB", start="2015-1-1", end="2017-1-1")
I was trying to get stock information as follows:
from pandas.io.data import DataReader
import datetime
data = DataReader("F", "yahoo", datetime.datetime(1990, 1, 1),datetime.datetime(2002, 1, 1))
which fails with
IOError: after 3 tries, Yahoo! did not return a 200 for url 'http://ichart.finance.yahoo.com/table.csv?s=C001.F&a=0&b=1&c=2014&d=11&e=1&f=2017&g=d&ignore=.csv'
Up to now, I could not find a fix for this issue or a suitable work-around. Do you guys have any suggestions?
It seems 'yahoo'is no longer supported. Try "morningstar" or "google".
The simple yahoo financial link,that worked for years, is no longer supported.
I've heard of a work around that involves browser spoofing (wget from command line) requires browser aliasing to obtain time sensitive cookies that are then required for each request -- but I've never tried it myself since "morningstar" currently still works (but I miss yahoo's adjusted close).
#(Pascal 3.6)
import pandas as pd
import pandas_datareader.data as web
...
df = web.DataReader('MSFT','morningstar')
for idx, row in df.iterrows():
print(idx[1],row[0],row[1],row[2],row[3],row[4])
Running this canonical example:
from pandas.io.data import Options
aapl = Options('aapl', 'yahoo')
data = aapl.get_all_data()
gives
RemoteDataError: Data not available
I know this used to be an issue in v0.14 or so, but it was supposedly fixed with v0.15. I'm on 0.18.1
It's Yahoo - they've changed their options site, so old parsers aren't working properly
Suggestion: first of all consider using pandas_datareader instead of deprecated pandas.io.data and monitor this issue so you'll know when this issue is fixed