Last active
May 21, 2018 13:31
-
-
Save JonathanVeg/21ff182f78c1c505626cad5bb0ffffec to your computer and use it in GitHub Desktop.
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 os | |
# for running it hourly | |
# in the terminal: crontab -e | |
# add this line, putting your path in the place of mine | |
# 0 * * * * /usr/bin/python /Users/jonathan/htmlcoin/htmlcoin.py | |
osCommand = "curl https://bleutrade.com/api/v2/public/getticker?market=HTML_BTC 2>/dev/null" | |
result = os.popen(osCommand).read() | |
result = eval(result) | |
if result["success"]: | |
result = result["result"][0] | |
print " BID: %s" % result["Bid"] | |
print " ASK: %s" % result["Ask"] | |
print "LAST: %s" % result["Last"] | |
osCommand = "curl https://bleutrade.com/api/v2/public/getorderbook?market=HTML_BTC 2>/dev/null" | |
result = os.popen(osCommand).read() | |
result = eval(result) | |
if result["success"]: | |
result = result["result"] | |
print " Buy: %s - %s"%(str(float(result["buy"][0]["Quantity"]) * float(result["buy"][0]["Rate"])), result["buy"][0]["Rate"]) | |
print "Sell: %s - %s"%(str(float(result["sell"][0]["Quantity"]) * float(result["sell"][0]["Rate"])), result["sell"][0]["Rate"]) | |
__location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__))) | |
file = open(os.path.join(__location__, "bidask.txt"), "r+") | |
content = file.read() | |
file.close() | |
newContent = "Bid: %s - Ask: %s"%(result["buy"][0]["Rate"], result["sell"][0]["Rate"]) | |
if content.strip() != newContent.strip(): | |
command = "osascript -e 'display notification \"%s\" with title \"%s\"'" %( newContent, "HTMLCoin changed" ) | |
os.system(command) | |
file = open(os.path.join(__location__, "bidask.txt"), "w") | |
file.write(newContent) | |
file.close() | |
else: | |
print "ERRO" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment