Skip to content

Instantly share code, notes, and snippets.

@roelandp
Created May 1, 2018 05:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roelandp/8550d9256cbc58e35e2fc0b2306f88bc to your computer and use it in GitHub Desktop.
Save roelandp/8550d9256cbc58e35e2fc0b2306f88bc to your computer and use it in GitHub Desktop.
New exchanges (Binance, Huobi, Upbit) (Steem-BTC pairs) added for Steem Pricefeed monitoring based on Clayop's pricefeed script. -> https://github.com/clayop/steemfeed
# I'm using a (heavily) altered pricefeed script based on Clayop's (I use alternative publishing method mainly)
# Clayop's pricefeed script. -> https://github.com/clayop/steemfeed
# What I particularly like about the script is the live-trading monitoring, reflecting actually volumes as they happen in realtime.
# I've Written new API parsers for (recent) new exchanges (Binance, Huobi, Upbit)
# I think you can paste them inside Clayop's script (he has also added weight factors in the meantime) but volume is also a weight metric imho
# Or use them to get inspired in adding them to your own scripts.
# @roelandp
# Binance
try:
bn_h = requests.get("https://api.binance.com//api/v1/trades?symbol=STEEMBTC&limit=350")
bn_hist = bn_h.json()
for bn_entry in reversed(bn_hist): #Binance has 'ASCENDING' list, so we reverse here for the loop.
strf_t = bn_entry["time"]
unix_t = int(strf_t)/1000
unix_t += time_adj
print('Binance', unix_t , curr_t, (unix_t >= curr_t))
if unix_t >= curr_t:
steem_q += float(bn_entry["qty"])
btc_q += float(bn_entry["price"]) * float(bn_entry["qty"])
pass
else:
break
except:
print("Error in fetching Binance market history")
pass
# Huobi
try:
huo_h = requests.get("http://api.huobi.pro/market/history/trade?symbol=steembtc&size=350")
huo_hist = huo_h.json()
for huo_entry in huo_hist["data"]:
strf_t = huo_entry["ts"]
unix_t = int(strf_t)/1000
unix_t += time_adj
print('Huobi', unix_t , curr_t, (unix_t >= curr_t))
if unix_t >= curr_t:
for huo_trade in huo_entry["data"]:
steem_q += float(huo_trade["amount"])
btc_q += float(huo_trade["price"]) * float(huo_trade["amount"])
pass
else:
break
except:
print("Error in fetching Huobi market history")
pass
# Upbit
try:
upbit_h = requests.get("https://crix-api.upbit.com/v1/crix/trades/ticks?code=CRIX.UPBIT.BTC-STEEM&count=50")
upbit_hist = upbit_h.json()
for upbit_entry in upbit_hist:
strf_t = upbit_entry["tradeTimestamp"]
unix_t = int(strf_t)/1000
unix_t += time_adj
print('Upbit', unix_t , curr_t, (unix_t >= curr_t))
if unix_t >= curr_t:
steem_q += float(upbit_entry["tradeVolume"])
btc_q += float(upbit_entry["tradePrice"]) * float(upbit_entry["tradeVolume"])
pass
else:
break
except:
print("Error in fetching Upbit market history")
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment