Python-Steem Price Bot

in steem •  7 years ago 

As a series of Steem-Python scripts I have been sharing, today I wanted to show you the code of a bot that gets the latest price of Bitcoin, Steem and Steem Dollar from the Poloniex API and creates a post on Steemit.

To start, create the python file:

sudo nano price_bot.py

Then paste this code inside (make sure to put your posting key and user in the required fields):


from steem import Steem
import urllib.request
import json

url = urllib.request.urlopen('https://poloniex.com/public?command=returnTicker')
result = url.read()
resultj = json.loads(result)

BTC = resultj['USDT_BTC']['last']
BTC = float(BTC)
BTC = round(BTC, 2)
STEEM = resultj['BTC_STEEM']['last']
STEEM = float(STEEM) * float(BTC)
STEEM = round(STEEM, 2)
SBD = resultj['BTC_SBD']['last']
SBD = float(SBD) * float(BTC)
SBD = round(SBD, 2)

print ("posting prices...")
s = Steem(keys=["YOUR POSTING KEY"])
s.commit.post(
    "Todays Daily Market: STEEM @ {} ...".format(STEEM),
    "**Bitcoin:** {} USD".format(BTC) + "<br>**Steem:** {}".format(STEEM) + "<br>**Steem Dollars:** {}<br>".format(SBD) + "<br>*This is an automated msg posted by the [price_bot.py](https://github.com/PixelNoob/python-steem)*" ,
    "YOUR ACCOUNT",
    tags=["bitcoin","steem", "trade"]
)

print ("prices posted succesfully")

To run the the script just type:

python3 bot_price.py

The end result should look like this:

Captura de pantalla 2018-03-27 a la(s) 18.07.31.png

You could also create a crontab job to run this script daily and get a daily price update on your feed.

Let me know what you think and make sure the check out my other scripts here:

https://github.com/PixelNoob/python-steem

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!
Sort Order:  

Is poloniex STEEM wallet still under 'maintanance"? Thanks for sharing the knowledge, @tipu send tip:)

I am not sure, I have been using binance for a while now.

You got a 45.83% upvote from @dailyupvotes courtesy of @hcf27!

Please upvote this comment to support the service.

Thank you for sharing,, good post I like it

Wonderful post ..thanks for sharing...Best of luck friend ✫
this is the best bot for steembottracker clik here https://steemit.com/bots/@hassanbenali/the-best-bot-for-service-how-to-create-steem-bot-tracker

Transfer 0.200 SBD or 0.250 steem to @mrbean1 and put the link of your post in the public memo you get 5 good UPVOT and resteem by @mrbean1 +followers

Hi @chitty! You have received 0.3 SBD tip from @cardboard!

it's really valuable information for us . Thanks a lot for sharing this post . I'm waiting for your next post .