From 5531343475f2de1a98b703412bdb9c6c720360ac Mon Sep 17 00:00:00 2001 From: scoobybejesus Date: Fri, 26 Jul 2019 15:59:07 -0400 Subject: [PATCH] Move thumb to end of xmrtall --- price.py | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/price.py b/price.py index 50e1ce3..4c7f4fe 100644 --- a/price.py +++ b/price.py @@ -690,27 +690,6 @@ def tall(bot, trigger): def xmrtall(bot, trigger): stringtosend = '' - # Bithumb (Note: Must calculate BTCXMR price from BTCKRW and XMRKRW) - try: - xmr_r = requests.get(thumbxmrurl) - btc_r = requests.get(thumbbtcurl) - xmrjson = xmr_r.json() - btcjson = btc_r.json() - # No last price in api. Must average buy and sell price. - thumbXMRbuy = float(xmrjson['data']['buy_price']) - thumbXMRsell = float(xmrjson['data']['sell_price']) - thumbXMRkrw = (thumbXMRbuy + thumbXMRsell)/2 - # Same for BTC - thumbBTCbuy = float(btcjson['data']['buy_price']) - thumbBTCsell = float(btcjson['data']['sell_price']) - thumbBTCkrw = (thumbBTCbuy + thumbBTCsell)/2 - # Finally, price in BTC, and volume in XMR - thumbBTCxmr = thumbXMRkrw/thumbBTCkrw - thumbXMRVol = float(xmrjson['data']['volume_1day']) - stringtosend = "Bithumb last: {0:.6f} BTC on {1:.2f} XMR volume | ".format(thumbBTCxmr,thumbXMRVol) - except: - bot.say("Error - bithumb korea is worst korea.") - # Polo try: r=requests.get(polourl) @@ -785,6 +764,28 @@ def xmrtall(bot, trigger): except: bot.say("Something borked ( -.-)ノ-=≡≡卍") +# Bithumb (Note: Must calculate BTCXMR price from BTCKRW and XMRKRW) + try: + xmr_r = requests.get(thumbxmrurl) + btc_r = requests.get(thumbbtcurl) + xmrjson = xmr_r.json() + btcjson = btc_r.json() + # No last price in api. Must average buy and sell price. + thumbXMRbuy = float(xmrjson['data']['buy_price']) + thumbXMRsell = float(xmrjson['data']['sell_price']) + thumbXMRkrw = (thumbXMRbuy + thumbXMRsell)/2 + # Same for BTC + thumbBTCbuy = float(btcjson['data']['buy_price']) + thumbBTCsell = float(btcjson['data']['sell_price']) + thumbBTCkrw = (thumbBTCbuy + thumbBTCsell)/2 + # Finally, price in BTC, and volume in XMR + thumbBTCxmr = thumbXMRkrw/thumbBTCkrw + thumbXMRVol = float(xmrjson['data']['volume_1day']) + stringtosend = "Bithumb last: {0:.6f} BTC on {1:.2f} XMR volume | ".format(thumbBTCxmr,thumbXMRVol) + except: + bot.say("Error - bithumb korea is worst korea.") + + # Tux # try: # r = requests.get('https://tuxexchange.com/api?method=getticker')