Skip to content

Instantly share code, notes, and snippets.

@jujum4n
Created July 15, 2014 03:04
Show Gist options
  • Select an option

  • Save jujum4n/f8bb5b4dcda56d323b03 to your computer and use it in GitHub Desktop.

Select an option

Save jujum4n/f8bb5b4dcda56d323b03 to your computer and use it in GitHub Desktop.
Gets the coinbase price in USD every 5 minutes, if the price is below a certain value it will beep then check again every 10 seconds and beep.
import json
import urllib2
import datetime
import time
import winsound
PRICE=610
def getprice():
data=json.load(urllib2.urlopen("https://coinbase.com/api/v1/prices/spot_rate?currency=USD"))
return data
def main():
data=getprice()
print str(datetime.datetime.now())+ " : " +data["amount"] + data["currency"]
if(data["amount"]<=PRICE):
while(getprice() <=PRICE):
winsound.Beep(440, 250)
winsound.Beep(440, 250)
winsound.Beep(440, 250)
time.sleep(10)
else:
time.sleep(60*5)
main()
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment