Hello and welcome back, in this article we will continue to develop the cryptocurrency application. In the previous few chapters, we had only used the cryptocompare API to make the REST call but in this chapter, we will add in the blockchain package which has the exchangerates module that we can use to retrieve the 15 minutes period of the time of the Bitcoin / major world currencies pair exchange rate. Since we will load the data from blockchain once the user has pressed the load button, we can now safely ignore the data from the previous cryptocompare rest call.

At the beginning of the program we will import the exchangerates module as well as get the ticker object from blockchain (rest call).

from blockchain import exchangerates
    ticker = exchangerates.get_ticker() # get the ticker object from blockchain
    print("An exception occurred")

Next, we will comment out the line to use the cryptocampare data under the get_exchange_rate method and add in a few lines of code to use the blockchain market data.

    for key, value in exchange_rate_s.items():  # populate exchange rate string and the currency tuple
        #sell_buy += base_crypto + ":" + key + "  " + str(value) + "\n"
        curr1 += (key,)
sell_buy += "Bitcoin : Currency price every 15 minute:" + "\n\n"
    # print the 15 min price for every bitcoin/currency
    for k in ticker:
        sell_buy += "BTC:" + str(k) + " " + str(ticker[k].p15min) + "\n"

If we load the data we will see the below outcome.


If you want to see the entire source code then please go back to the previous chapter to read them.

Are you a developer or a python programmer? Join mine private chat room through this link to see what am I working on right now.

Please follow and like us:

Leave a Reply

Your email address will not be published. Required fields are marked *