-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCryptoPriceX.py
28 lines (22 loc) · 1.11 KB
/
CryptoPriceX.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import requests # https://docs.python-requests.org/en/master/ | $ sudo pip install requests
import json # https://docs.python.org/3/library/json.html
import time # https://docs.python.org/3/library/time.html
import os # https://docs.python.org/3/library/os.html
url ="https://api.binance.com/api/v3/ticker/price?symbol="
# ~~~~~~~~~~~ CryptoPriceX ~~~~~~~~~~~ #
# request the API with the url and the currency pair
# return the price of the crypto
def request(url):
cours = requests.Session()
response = cours.get(url)
data = json.loads(response.text)
return data["price"]
# list of crypto and their name
cryptos = {" BTC": "Bitcoin", " ETH": "Et hereum", " LTC": "Litecoin", " BCH": "Bitcoin Cash", " ADA": "Cardano", " XLM": "Stellar", " EOS": "EOS", " DOGE": "Dogecoin",}
# list of fiduciary currencies and their name
fiduciaires = {" USDT": "Dollar américain", " EUR": "Euro", " GBP": "Livre sterling", " AUD": "Dollar australien", " BRL": "Real brésilien"}
def clear():
if os.name == 'nt':
os.system('cls')
else:
os.system('clear')