Skip to content

Instantly share code, notes, and snippets.

@PegasisForever
Created December 5, 2019 12:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PegasisForever/a26bcf7de2ffe877b3ac32d03aaa4955 to your computer and use it in GitHub Desktop.
Save PegasisForever/a26bcf7de2ffe877b3ac32d03aaa4955 to your computer and use it in GitHub Desktop.
Create a beep sound when bitcoin price drops
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