Created
July 15, 2014 03:04
-
-
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.
This file contains hidden or 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 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