We're going to use Bittrex, one of the biggest exchanges, based in Las Vegas. When we use Chrome to surf to, for instance https://bittrex.com/Market/Index?MarketName=BTC-VIA, and press F12, we find that one of the URLs loaded is:
https://bittrex.com/Api/v2.0/pub/market/GetTicks?marketName=BTC-RLC&tickInterval=fiveMinAha! Let's curl it. Go do the command line (download MSYS if you use Windows).
The curl command outputs a whole bunch of data in JSON format. This shows us that we don't need any special HTTP requests, we can just fetch the data directly from Bittrex. Great! Over to coding then.
First we need a couple of nice utility libraries for Python. You install them using the pip command, which is included in the Python installation:
The first is used to neatly download data from the web, the second to plot graphs, the third is used to manipulate data matrices.
We're going to start out in Python's interactive mode, so just start Python from the command line.
Enter the URL and the code to download it:
Now the coin data from Bittrex (as shown when you ran the curl command above) is stored in the variable called "data." We drag this data into Pandas, which is riddled with powerful functions for us to make good use of later on.
And let's plot the close price over time (C over T in the data given to us by Bittrex):
Step one is complete -- I'm your father! Clean it up and put it in a file together with a shebang (first line below) and you've got yourself the start of a bot. Call the script bot1.py.
(Note that I added a line to type convert the time from a string into a datetime object, so the plotting will show time stamps on the X-axis.) Next time we'll structure a bit and implement some analysis code. It's going to be dandy!