PRO TIP: Download historical Crypto price data on ANY coin

in #bitcoin6 years ago (edited)

Hey Steemit!

One of the most annoying things I find about the Crypto-verse is that it's really hard to get any basic data like historic price and volume data.

Getting this kind of information is important if you want to carry out some basic analysis to determine volatility of a coin, chart your own graphs to look at how prices vary over certain time frames all within excel OR (as I needed to do) study the arbitrage opportunities our bot was identifying, (click here to read about the case study I did on this.)

The way I pull the data is using the CryptoCompare API, you can read the documentation here


4 Steps to get the coin data

1. Download Python

Unfortunately it's time to get your coding hats on (but dont stress this isn't toooooo tricky).

If you already have Python make sure you have Jupyter Notebook installed and go to Step 2. It's not necessary as you could just copy my code into a script and run it - but its quicker to use Jupyter.

If you don't have Python I recommend following this tutorial to download it for Windows and this for Mac.

Anaconda is basically a simple way to install Python + all the necessary add-on packages (including Jupyter Notebook)


2. Open Jupyter Notebook

Once you have installed Python and made sure everything works (including Jupyter Notebook) this is what you want to do.

a. Go to your desktop and make a folder (or make a folder anywhere you want your price data to be stored).
b. Copy paste this file into the folder
c. In the address bar type "cmd" without the quotes (refer to Picture 1).
d. This will launch a command prompt which points to your folders directory and then type in Jupyter Notebook. (See Picture 2 circled in red).
e. Some lines of code will appear - then your internet browser should open with Jupyter Notebook.

Picture 1: Click on the address bar (highlighted yellow) and type "cmd" (without the quotes)

Picture 2: in the command prompt type "Jupyter Notebook" (circled in red above) to launch Jupyter


3. Let's CODE!

Click on the the file called "Price Collector" (see Picture 3 below) - this is the code which will let you download the price data.

Picture 3: Click on the file to open the code


Picture 4 below is what you should now see

Picture 4: Complete Code

Lets break down what each part does;

a. The first cell just imports a bunch of add-ins - nothing ground breaking

b. The second block is a function which is coded to download daily data and the function name is daily_price_historical

c. The third block is a function coded to download hourly data and the function name is hourly_price_historical

d. The fourth block is a function coded to download minute data (however it can only download the last 7 days worth of data). The function is minute_price_historical

e. The fifth block contains the parameters for which you want to pull the data from.

For example if you want NEO/BTC data from Bittrex. You would put base= 'BTC' , coin = 'NEO' and then exchange = 'bittrex '.

f. the file_name parameter is just the name of of the csv file that you will download containing the data you want

After this you will see some 'commented' out lines which means the code isn't read. We will go over this next.

4. Getting the data

Now to actually get a download of the price & volume data by exchange into a CSV file which can be opened in Excel.

a. Start from the top and run each 'cell' all the way till the parameters section
b. Then this is where you need to input your parameters and then run that line of code in the notebook
c. Now un-comment out the function which you would like based on whether you want daily, hourly or minute data. You can do this simply by removing the hash from one of the three functions.
d. Once you run the function you want (leave the other two functions commented out) you need to run the final line which then exports the data into a CSV file that can be opened in Excel.

Et voila! You now have yourself all the historical data possible of a coin by exchange as a CSV saved in the folder you created.


The reason I built this python code was to download data as I wanted to study the arbitrage opportunities the bot we built was identifying (namely the liquidity).

If you're interested in reading the Case Study I did on the arbitrage opportunity our bot spotted which lasted 2 days and which earned an average profit of 5.6% in two days then click here

Hope you found this useful!

Hit me up on telelgram @Crypto_Dino if you have any issues with the code or want to find out more about the arbitrage bot that has been built!

Have a good evening

Crypto Dino

Sort:  

For future viewers: price of bitcoin at the moment of posting is 7500.00USD

Coin Marketplace

STEEM 0.20
TRX 0.13
JST 0.030
BTC 65359.95
ETH 3492.90
USDT 1.00
SBD 2.51