In this chapter, we will continue to develop the cryptocurrency application by retrieving a number of top coins by their total volume across all markets in the last 24 hours.

We will perform these steps:

  1. Create a button which will call the search coin function to retrieve the above mentioned data.
  2. Create the search coin function to retrieve and to display the market data.
# get top 100 coins by their total volume across all markets in the last 24 hours
action_coin_volume = tk.Button(selectorFrame, text="Trade Volume", command=search_coin, state=DISABLED) # button used to get the top currency/cryptocurrency pair data
def search_coin():  # display all market data of the currency/cryptocurrency pair

    sell_buy = ''
        currency_symbol = based.get()  # get the currency symbol
        url = ""
        data = {'tsym': currency_symbol, 'limit': 100}
        r = requests.get(url, params=data)
        exchange_rate_s = json.loads(json.dumps(r.json()))

        print("An exception occurred")
    count = 0  # used to control new line for each symbol
    for value in exchange_rate_s['Data']:  # populate exchange rate string and the currency tuple
        for key, value1 in value.items():
            for key2, value2 in value1.items():
                if (type(value2) == dict):
                    for key3, value3 in value2.items():
                        if (key3 == "IMAGEURL"):
                        sell_buy += str(key3) + " : " + str(value3) + "\n"
                    count += 1
                    if count == 2:
                        sell_buy += "\n"
                        count = 0

    text_widget.delete('1.0', END)  # clear all those previous text first
    text_widget.insert(INSERT, s.get())  # populate the text widget with new exchange rate data

The above function will retrieve the market data of the top 100 cryptocurrencies vs the selected currency within a period of 24 hours.

EUR vs top 100 cryptocurrency

Below are the steps to display those data:

  1. Click on the Load data button to load the top currencies data to the currency’s combo box.
  2. Select the currency which you wish to compare from the combo box, in this example we select EURO.
  3. Click on the trade volume button to display the top 100 cryptocurrency market data vs the selected currency which is EUR0.

If you have missed out the previous chapter don’t forget to read them because the code in this chapter is interrelated with the previous one.

Please follow and like us:

Leave a Reply

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