Hello and welcome back to this latest cryptocurrency application project, before we proceed to more complicated user interface design for our new cryptocurrency application I would like to retrieve market data from Coinbase for a few more BTC/World Currency pairs with our new application. We have set up all parts that need for retrieving the market data from Coinbase in the last chapter and in this chapter we will try to retrieve those market data again for different currency/btc pairs.
First of all, we will try to retrieve market data for btc/euro pairs with this statement: “BTC-EUR” and this is what we will get.
Next, we will try to retrieve market data for btc/pound pairs with this statement: “BTC- GBP” and this is what we will get.
Here is the entire program again.
from coinbase.wallet.client import Client import json from tkinter import * from tkinter import filedialog import tkinter.ttk as tk from tkinter import messagebox win = Tk() # Create tk instance win.title("Real CryptoGeek") # Add a title win.resizable(0, 0) # Disable resizing the GUI win.configure(background='white') # change background color s = StringVar() # change text currencyFrame = Frame(win) # create currency frame currencyFrame.pack(side = TOP, fill=X) currency = Label(currencyFrame, textvariable=s) currency.pack() s.set("Click the below button to find out the bitcoin exchange rate") buttonFrame = Frame(win) # create a button frame buttonFrame.pack(side = BOTTOM, fill=X, pady = 6) def get_exchange_rate(): f = open("coin.txt", "r") api_key = f.readline() api_secret = f.readline() f.close() api_key = api_key.replace('\n', '') api_secret = api_secret.replace('\n', '') try: client = Client(api_key, api_secret) market_currencies_o = client.get_sell_price(currency_pair='BTC-GBP') market_currencies_s = json.dumps(market_currencies_o) exchange = json.loads(market_currencies_s) coin_type = exchange['base'] currency_type = exchange['currency'] currency_sell_price = exchange['amount'] market_currencies_o = client.get_buy_price(currency_pair='BTC-GBP') market_currencies_s = json.dumps(market_currencies_o) exchange = json.loads(market_currencies_s) currency_buy_price = exchange['amount'] market_currencies_o = client.get_spot_price(currency_pair='BTC-GBP') market_currencies_s = json.dumps(market_currencies_o) exchange = json.loads(market_currencies_s) currency_spot_price = exchange['amount'] except: print("An exception occurred") sell_buy = " Pair : " + coin_type + "/" + currency_type + " Sell : " + currency_sell_price + " Buy : " + currency_buy_price + " Spot : " + currency_spot_price s.set(sell_buy) action_vid = tk.Button(buttonFrame, text="Find", command=get_exchange_rate) # find out the exchange rate of bitcoin action_vid.pack(fill=X) win.mainloop()
It seems like the BTC/USD exchange rate is up again today till 3,930.47 United States Dollar as compared to yesterday but before we all happy about this outcome we need to be very cautious because the USD exchange rate vs other major world currencies is slightly down again so we need to compare the exchange rate of BTC vs other major world currencies as well before we said that BTC is up again. In the next chapter we will retrieve the market data for bitcoin vs other cryptocurrencies and then we will improve the user interface of this application so it can display all the exchange rates at once.
Hello people, if you like to read about some other internet stuffs like social networking and online earning then come and read this latest article of mine: A Social Network for Photographer!
If you like this website then do consider to donate cryptocurrency to this website through below address.
- Bitcoin
- Bitcoin cash
- Litecoin
- Stellar
Donate Bitcoin to this address
Scan the QR code or copy the address below into your wallet to send some Bitcoin
Donate Bitcoin cash to this address
Scan the QR code or copy the address below into your wallet to send some Bitcoin cash
Donate Litecoin to this address
Scan the QR code or copy the address below into your wallet to send some Litecoin
Donate Stellar to this address
Scan the QR code or copy the address below into your wallet to send some Stellar
from Planet Python
via read more
No comments:
Post a Comment