Skip to content

Instantly share code, notes, and snippets.

@sc0tt
Created November 13, 2013 15:31
Show Gist options
  • Save sc0tt/7450959 to your computer and use it in GitHub Desktop.
Save sc0tt/7450959 to your computer and use it in GitHub Desktop.
BTC Price Watch
import requests
import time
import decimal
lastPrice = decimal.Decimal("0")
while True:
ret = requests.get("https://coinbase.com/api/v1/prices/spot_rate").json()
price = decimal.Decimal(ret['amount'])
diff = price - lastPrice
if diff > 0:
print("$%s (+%s)" % (price, diff))
elif diff < 0:
print("$%s (%s)" % (price, diff))
lastPrice = price
time.sleep(5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment