5

I am wanting to ask if Pandas DataReader may be used to extract Bitcoin information from blockchain.com ?

I am aware we may use it together with Alpha Vantage API Key to extract stocks through:

import pandas as pd
import pandas_datareader as dr
reader = dr.DataReader('AAPL', 'av-daily', start = '2020-08-01', end = '2020-08-05', api_key = '')
print(reader)

But may this same style of function/code be used to extract Bitcoin data? I know of one method but am not a big fan of it:

cc = CryptoCurrencies(key='', output_format='pandas')
btc, meta_data = cc.get_digital_currency_daily(symbol='BTC', market='CNY')
print(btc)

I am pretty new to coding and BTC so would appreciate something straightforward if possible, thank you !

funkymickey
  • 111
  • 3
  • 8

2 Answers2

6

Querying Bitcoin prices with pandas_datareader should be straightforward:

import pandas_datareader as pdr
btc_data = pdr.get_data_yahoo(['BTC-USD'], 
                          start=datetime.datetime(2018, 1, 1), 
                          end=datetime.datetime(2020, 12, 2))['Close']

Results:

Symbols     BTC-USD
Date    
2018-01-01  13657.200195
2018-01-02  14982.099609
2018-01-03  15201.000000
2018-01-04  15599.200195
2018-01-05  17429.500000
...     ...
2020-11-29  18177.484375
2020-11-30  19625.835938
2020-12-01  18802.998047
2020-12-02  19201.091797
2020-12-03  19445.398438
Willian Fuks
  • 11,259
  • 10
  • 50
  • 74
  • 3
    As of Aug 2021, Pandas DataReader 0.9.0, this apparently doesn't work anymore. I'm looking for new ways to use DataReader to get BTC daily prices. – avibrazil Aug 07 '21 at 15:25
4
from pandas_datareader import data
start_date = '2021-01-01'
end_date = '2021-05-01'

btc_price= data.DataReader('BTC-USD','yahoo',start_date,end_date);
MoFoLuWaSo
  • 1,289
  • 1
  • 5
  • 6