[Steempy v0.0.4] A Steem Price Bot written in Python

4년 전

Steempy is now displaying the percentage changed whenever the price moves!

As promised, I updated Steempy in version 0.0.4 to be able to display the percentage changed between price changes along with the already implemented, amount changed which is displayed in bitcoin. This was a pretty implementation, that shouldn't have taken as long as it has but, hey. I'm a human, not a highly dedicated price bot like Steempy.

Steempy also got a few bugs squashed

Although, it was nothing major, I changed the way Steempy spits out his information to be a little easier on the eyes, and not so "cluttered." This makes looking at the price movements a breeze. Another, issue that I was having was how Steempy would start off with a really low value as a placeholder, which would, upon starting Steempy report a significant price increase. This was rectified by using a IF statement to check if Steempy's ```coin_price``` was empty, and if it was, it appends the current steem price into it, which always happens upon starting up Steempy. As always, if you ever notice a bug I missed, leave a comment!

New features in the future?

I plan to add some new information/data to Steempy's brain. That data will most likely be steem trading volume but, i'm not entirely sure what I want to have him do with that data. I'm trying to think of another use other than reiterating what i did with the steem price. Any suggestions would be great!

You're probably thinking  "Source C0d3 Pl0X"  well here you go

# Steempy v0.0.4.0 is a bot that monitors the CryptoCompare API  
# Bug fixes: issue with starting value in coin_price
# New for v0.0.4: Added percent of price change, formatted,
#  the way information is displayed, a bit cleaner than v0.0.3
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 = []
# Gets the percentage changed between two prices, returns ints
def PercentChange(previous,current):
	if previous == current or previous == 0 or current == 0:
		return 0
	else:
		return ((current-previous)/previous)*100

print("Steempy v0.0.4. Programmed by vidallia.")
print("Feel free modify the code to suit your needs.")

while True:
	print("Sleeping...")
	time.sleep(5)
	minutechart = requests.get(url).json()
	# list indexing from multiple nested lists/dicts
	a = minutechart['Data'][-1]['close']
	if len(coin_price) == 0: coin_price.append(a)
	coin_price.append(a)
	b = coin_price[0]
	if a > b:
		diff = Decimal(a) - Decimal(b)
		print("(+)Increase of: {:.7f}.\n\t+{:.4f}% Change. ".format(
		diff,PercentChange(b,a)))
		coin_price.pop(0)
		print("Current price: {}".format(coin_price))
	elif a < b:
		diff = Decimal(b) - Decimal(a)
		print("(-)Decrease of: {:.7f}.\n\t{:.4f}% Change.".format(
		diff,PercentChange(b,a)))
		coin_price.pop(0)
		print("Current price: {}".format(coin_price))
	else:
		coin_price.pop(0)
		print("Current Price: {} ".format(coin_price))


For more content, Upvote, ReSteem, and Follow!

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
STEEMKR.COM IS SPONSORED BY
ADVERTISEMENT
Sort Order:  trending

Need to work more on this..

You have good project here, thanks for sharing!

I'm going to follow your work since I'm beginner in python and this is really interesting for me.

Btw, when I copy/paste your code into my Ide (free Pycharm) editor "complains" because you are using tabs for indentation. :-) If you can, see if you have an option, so your editor would automatically insert 4 spaces every time you use tab for indent. Most, if not all IDE should have this setting.

It is not that important really, but it sort of is standard now a days. just though to mention this. If you can't find this option, then of course don't worry about it. :-)

·

First off, thank you for the comment! It means alot to get some engagement from my followers. Personally, I use notepad++ to do all of my coding and I find using a tab is the most consistent way to make sure my spacing is correct the entire way through my program. Instead of getting an indentation error for using 7 spaces instead of 8, I can just use 2 Tabs. The consistency is better. If you're having issues just run it from your command line.

I'll look for an option to do that thing you mentioned with notepad++ but, personally, spaces seem like just another thing to worry about. That's just my opinion though. Thanks for the feedback.

Also anyone reading this who does not know how to run this script, at least on windows, you can copy the source once you have Python3 or higher installed, paste it into a notepad or any text editor save it as steempy.py then open a command prompt where you saved the script, and simply type:
python steempy.py

·
·

No, don't worry about it, didn't know you are using a notepad. It's all good :-)

Just for your info, I'm running your program on Linux (Manjaro), Python 3.6.1 and it works great :-)

·
·
·

It's not like windows notepad or anything, Notepad++ is a text editor designed for programming, has most features all IDEs have like syntax highlighting, auto-completion, and a lot more. It just doesn't have a "run" built in, so I run all my scripts via command line/shell. Unless, I make a GUI for it of course.

excellent friend where I find this application, I am following, I expect the same

·

If you have Python installed you can simply add the source code into a file and say it with the .py file extension. Then run it from your command line.

Congratulations @vidallia! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

Award for the number of upvotes received

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

By upvoting this notification, you can help all Steemit users. Learn how here!

This looks like a great project and a great idea. I wish you all the best with it. I can see how this will be very useful to many. Tank you for putting the time in and for sharing your progress.

Congratulations @vidallia! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

Award for the number of upvotes

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

By upvoting this notification, you can help all Steemit users. Learn how here!

Congratulations @vidallia! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

Award for the number of upvotes

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

By upvoting this notification, you can help all Steemit users. Learn how here!