[Steempy v0.0.3] Steem price bot written in Python!steemCreated with Sketch.

in #python7 years ago

Steempy is now displaying price change values correctly!

In the previous version Steempy v0.0.2 there was a bug in the code that basically displayed the the change in price in an exponent format i.e. 2.07E-7 . It was a easy fix once I did some research and asked for a little help on reddit. I had to add :.8f inside of the {} curly brackets when I was formatting the change within my print functions.  I learned something new! Those are the best type of bugs, the kind that teach you something.

Some new features are coming!

Enjoy the meme? It took me about 10 minutes to come up with that. Yeah. 10 minutes. So, like the nice bold medium sized heading above states, i'll be implementing some new features, I have a few ideas. One of them is possibly displaying the percent change from the last price, or even adding some some new data to the script, like changes in volume large enough to be notable. 

And further down the line?

I play on adding some feature that will either email you, text you, or display a small popup message on your bottom tray that holds your icons (taskbar?), that lets you know if there is a major change in the price or volume! I would like to do some more research before I get into all of that just yet. I code Steempy in my free time, which I don't have a lot of. So, just trust that eventually, everything will get done!

Found a bug in my code?

If you find a bug in my code, please comment below or shoot me a email at [email protected]! I'll get back to you as soon as possible. And hopefully, get that bug squashed!

As always, now for the source:

# Steempy v0.0.3 is a bot that monitors theCryptoCompare API  
# Bug fixes from 0.0.2: fixed display issues by adding :.8 inside of
# the format curly brackets. Price change now displays as 
# intended.
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 {:.8f} BTC since last price".format(
					diff))
		coin_price.pop(0)
		print(a)
	elif a < b:
		diff = Decimal(b) - Decimal(a)
		print("a lower difference of {:.8f} BTC since last price".format(
					diff))
		coin_price.pop(0)
		print(a)
	else:
		coin_price.pop(0)
		print("Current Price: {} ".format(coin_price))

For more updates, please follow, upvote, and comment below some constructive feedback!