Analyze Cryptocurrency Price data with Robinhood, Jupyter Notebooks, and MatPlotLib
Cryptocurrency market capitalization is on the rise. This tutorial explains how to access access and plot historical cryptocurrency pricing data for free. To access the data, you will need to create a Robinhood account.
Authenticating
To log in to your Robinhood account, use the python package robin_stocks:
If you have not installed robin_stocks, instruction to do so are here. This will pickle your authentication information automatically and allow us to fetch data from Robinhood URLs.
Fetching Data
Although Robinhood doesn’t officially support an API for consumers, they have ‘hidden’ API endpoints that can be accessed directly. We can find the endpoints by inspecting the network requests from our browsers. We’ll use the robin_stocks.helper.request_get() method to authenticate our GET requests.
Create a getYearHistoricals method as outlined below.
symbol_dict mapps cryptocurrency tickers to their Robinhood forex id. When called, getYearHistoricals returns a dictionary of price points. Now, we can call the method and filter the data. In the following example, I’ve fetched BTC data and kept the daily low prices.
btc_data is now a list. It contains a time-series of pricing data. Let’s make a simple plot of btc_data:
With any luck, the output should look like this:
Additional tooling can be used for further analysis. For example, we may be able to spot trends by plotting a simple moving average along with the price.
This yields a new graphic:
Different data sets can be obtained by modifying the URL parameters in the API call we created. Furthermore, Robinhood offers pricing data for over a dozen different cryptocurrencies (Although they may not all be available for trading).
The notebook used in this tutorial can be found here: https://github.com/henryrossiter/crypto-trading/blob/master/tutorials/CyptoTutorial.ipynb
Published at Tue, 04 Feb 2020 23:37:51 +0000
{flickr|100|campaign}
