Super simple not complex and don't need it to be. Just wanted to add the current prices of crypto and my equity of these prices as well as a total to display on screen. I want these values to refresh in place so they don't create new lines every time it refreshes.
Here is what I have:
import requests
import math
from datetime import datetime
URL = "https://min-api.cryptocompare.com/data/price?fsym={}&tsyms={}"
def get_price(coin, currency):
try:
response = requests.get(URL.format(coin, currency)).json()
return response
except:
return False
while True:
date_time = datetime.now()
date_time = date_time.strftime("%m/%d/%Y %H:%M:%S")
currentPrice = get_price("ETH", "USD")
totalPrice = currentPrice["USD"]*2
currentPrice0 = get_price("DOGE", "USD")
totalPrice0 = currentPrice0["USD"]*100
currentPrice1 = get_price("ADA", "USD")
totalPrice1 = currentPrice1["USD"]*20
currentPrice2 = get_price("SOL", "USD")
totalPrice2 = currentPrice2["USD"]*4
currentPrice3 = (totalPrice + totalPrice0 + totalPrice1 + totalPrice2)
print("ETH | PRICE: $", currentPrice["USD"], " EQUITY: $", totalPrice)
print("DOGE | PRICE: $", currentPrice0["USD"], " EQUITY: $", totalPrice0)
print("ADA | PRICE: $", currentPrice1["USD"], " EQUITY: $", totalPrice1)
print("SOL | PRICE: $", currentPrice2["USD"], " EQUITY: $", totalPrice2)
print(" ")
print("TOTAL: ", currentPrice3)