-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_BTC.py
More file actions
31 lines (25 loc) · 873 Bytes
/
Copy pathmain_BTC.py
File metadata and controls
31 lines (25 loc) · 873 Bytes
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
29
30
31
import requests
import time
url = "https://api.exchange.coinbase.com/products/BTC-USD/ticker"
timer_minutes = 5
timer_length = timer_minutes * 60
start_time = time.time()
print("App is running...")
time.sleep(1)
print("There is a 5 minute timer that will need to be reset. You will be prompted to enter wether you would like to continue or not.")
time.sleep(1)
while True:
response = requests.get(url, timeout=10)
data = response.json()
price = float(data["price"])
print(f"BTC: ${price:,.2f}")
time.sleep(2.5)
elapsed_time = time.time() - start_time
if elapsed_time >= timer_length:
choice = input("Do you want to continue tracker the price?(y/n): ")
if choice == "y":
start_time = time.time()
print("Timer reset!")
elif choice == "n":
print("App closing...")
break