Created
December 5, 2019 12:03
-
-
Save PegasisForever/a26bcf7de2ffe877b3ac32d03aaa4955 to your computer and use it in GitHub Desktop.
Create a beep sound when bitcoin price drops
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import winsound | |
def get_latest_crypto_price(): | |
response = requests.get('https://api.coinmarketcap.com/v1/ticker/bitcoin') | |
response_json = response.json() | |
return float(response_json[0]['price_usd']) | |
last_price = 100000 | |
while True: | |
price = get_latest_crypto_price() | |
if price < last_price: | |
print('Bitcoin price: ',price) | |
last_price = price | |
winsound.Beep(2500, 500) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment