My bot is named Steempy, and "he" will monitor the steem price 6 times a minute and if the price changes he will print out the difference in the console.
Steempy is still in version 0.0.2 and has a few bugs, like the change in price not displaying in a "pretty" way but, the logic behind Steempy is correct. That bug is the only one I could find so far! So give it a test and let me know what you think!
If you have any experience with displaying floats/decimals in Python in a pretty way, please comment your suggestions bellow. I tried the decimal module but, it didn't seem to help a whole lot.
Now for the code: Steempy.py:
# Steempy: a bot that monitors a CryptoCompare API v0.0.2
# Bugs: having trouble with like 19 & line 24 displaying the change
# correctly. Example: displays 2.0E-7 as a change.
from decimal import Decimal
import requests
import time
url = "https://min-api.cryptocompare.com/data/histominute?fsym=STEEM&tsym=BTC&limit=1&aggregate=0&e=CCCAGG"
coin_price = [0.0000001]
while True:
minutechart = requests.get(url).json()
print("Sleeping...")
time.sleep(5)
# list indexing from multiple nested lists/dicts
a = minutechart['Data'][-1]['close']
coin_price.append(a)
b = coin_price[0]
if a > b:
diff = Decimal(a) - Decimal(b)
print("a higher difference of {} BTC since last price".format(
round(Decimal(diff),8)))
coin_price.pop(0)
print(a)
elif a < b:
diff = Decimal(b) - Decimal(a)
print("a lower difference of {} BTC since last price".format(
round(Decimal(diff),8)))
coin_price.pop(0)
else:
coin_price.pop(0)
print("Current Price: {} ".format(coin_price))