Trading advice from a python script

in #python10 years ago (edited)

This is a simple python script that retrieves current Steem Dollar price from Poloniex and tells you whether to buy, sell or hold!

from urllib.request import urlopen
import json

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

SBD = result['BTC_SBD']['last']
BTC = result['USDT_BTC']['last']
SBD_USD = float(SBD) * float(BTC)

print "SBD $",'{0:.2f}'.format(SBD_USD)
SBD = '{0:.2f}'.format(SBD_USD)
SBD = float(SBD)
if SBD > 1:
  print 'sell, sell.. we are riaaach $$$!!'
elif SBD < 0.90:
  print 'buy!!'
else:
  print 'hoooodl !!!'

You can run it online here

Or, If you have a raspberry pi and a sense hat you could even tweak it so it shows on your screen, like this:

Note: the advice given represents my personal strategy, the idea is to take advantage of the price swings of SBD, please do not take it too seriously.

#steemdollars
#raspberrypi

Sort:  

I don't really understand it but I'm guessing it's not just telling you to buy under 90 cents and sell above a dollar. Could you explain a bit how float works?

hehe that is exactly what it is telling you... its very simple, mostly for fun and learning how to program on python.

oh ok then I thought there was something more complex going on.

It is really simple, but funny! :)

Artuido motheboard ?

Yeah It should work on an arduino too

would you please, provide me a php script ?

Coin Marketplace

STEEM 0.04
TRX 0.32
JST 0.083
BTC 60578.05
ETH 1558.21
USDT 1.00
SBD 0.50