From c7e33784489718ff2adbf056f59aaf824055ad40 Mon Sep 17 00:00:00 2001 From: ferretinjapan Date: Fri, 5 May 2017 22:03:11 +0930 Subject: [PATCH 1/3] Outputs cleaned up, XMR growth also added Output changed, also pulls data from coinmarket cap now. --- trifling.py | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/trifling.py b/trifling.py index 8e00279..48da6ed 100644 --- a/trifling.py +++ b/trifling.py @@ -367,7 +367,15 @@ def wave(bot, trigger): def asp(bot, trigger): polourl = "https://poloniex.com/public?command=returnTicker" stampurl = 'https://www.bitstamp.net/api/ticker/' + cmcurl = "https://api.coinmarketcap.com/v1/ticker/monero/" + try: + r=requests.get(cmcurl) + j=r.json() + xmrusd_price=float(j[0]['price_usd']) + except: + bot.say("Error connecting to CoinMarketCap") + try: r=requests.get(polourl) j=r.json() @@ -426,12 +434,18 @@ def asp(bot, trigger): value_ripple = float(last_ripple*27962.37965895) value_zcash = float(last_zcash*16.47649534) total = value_dash + value_decred + value_factom + value_golem + value_maidsafecoin + value_augur + value_stellar + value_nem + value_ripple + value_zcash - percent = (((stamp_price * total) / 14950)-1)*100 - if percent >= 0: - sign = '+' + xmr_totalvalue = float(stamp_price*total) / xmrusd_price + asppercent = (((stamp_price * total) / 14950)-1)*100 + if asppercent >= 0: + aspsign = '+' else: - sign = '-' + aspsign = '-' + xmrpercent = ((((stamp_price * total) / xmrusd_price ) / 650)-1)*100 + if xmrpercent >= 0: + xmrsign = '+' + else: + xmrsign = '-' - bot.say("{0} {1:.3f}BTC; {2} {3:.3f}BTC; {4} {5:.3f}BTC; {6} {7:.3f}BTC; {8} {9:.3f}BTC; {10} {11:.3f}BTC; {12} {13:.3f}BTC; {14} {15:.3f}BTC; {16} {17:.3f}BTC; {18} {19:.3f}BTC; ASP Total: {20:.3f}BTC ({21:,.1f}USD {22}{23:.2f}%) (02-May-17 outlay, 10 BTC@14,950 USD)".format("DASH", value_dash, "DCR", value_decred, "FCT", value_factom, "GNT", value_golem, "MAID", value_maidsafecoin, "REP", value_augur, "STR", value_stellar, "XEM", value_nem, "XRP", value_ripple, "ZEC", value_zcash, total, stamp_price * total, sign, percent)) + bot.say("{0} {1:.2f}BTC; {2} {3:.2f}BTC; {4} {5:.2f}BTC; {6} {7:.2f}BTC; {8} {9:.2f}BTC; {10} {11:.2f}BTC; {12} {13:.2f}BTC; {14} {15:.2f}BTC; {16} {17:.2f}BTC; {18} {19:.2f}BTC; ASP Total:{20:.2f}BTC/{21:,.0f}USD/{22:,.1f}XMR (02-May outlay, 10BTC/14,950USD/650XMR) (Since begin ASP:{23}{24:.2f}% XMR:{25}{26:.2f}%)".format("DASH", value_dash, "DCR", value_decred, "FCT", value_factom, "GNT", value_golem, "MAID", value_maidsafecoin, "REP", value_augur, "STR", value_stellar, "XEM", value_nem, "XRP", value_ripple, "ZEC", value_zcash, total, stamp_price * total, xmr_totalvalue, aspsign, asppercent, xmrsign, xmrpercent)) except: bot.say("ERROR!") From b3297c9eb3010195d4d6f5a3232dd8da6ebfd30d Mon Sep 17 00:00:00 2001 From: ferretinjapan Date: Fri, 5 May 2017 22:22:37 +0930 Subject: [PATCH 2/3] Fix to XMR growth percent. --- trifling.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/trifling.py b/trifling.py index 48da6ed..e666177 100644 --- a/trifling.py +++ b/trifling.py @@ -372,7 +372,7 @@ def asp(bot, trigger): try: r=requests.get(cmcurl) j=r.json() - xmrusd_price=float(j[0]['price_usd']) + xmrbtc_price=float(j[0]['price_btc']) except: bot.say("Error connecting to CoinMarketCap") @@ -434,13 +434,13 @@ def asp(bot, trigger): value_ripple = float(last_ripple*27962.37965895) value_zcash = float(last_zcash*16.47649534) total = value_dash + value_decred + value_factom + value_golem + value_maidsafecoin + value_augur + value_stellar + value_nem + value_ripple + value_zcash - xmr_totalvalue = float(stamp_price*total) / xmrusd_price + xmr_totalvalue = float(total / xmrbtc_price) asppercent = (((stamp_price * total) / 14950)-1)*100 if asppercent >= 0: aspsign = '+' else: aspsign = '-' - xmrpercent = ((((stamp_price * total) / xmrusd_price ) / 650)-1)*100 + xmrpercent = (((total / xmrbtc_price ) / 650)-1)*100 if xmrpercent >= 0: xmrsign = '+' else: From 831f11096a0021880d6274c91c01665f72b309e8 Mon Sep 17 00:00:00 2001 From: ferretinjapan Date: Sat, 6 May 2017 18:43:22 +0930 Subject: [PATCH 3/3] Fixed XMR percentage growth Now it actually reflects the XMR growth if you had invested those coins into Monero instead of the ASP. --- trifling.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trifling.py b/trifling.py index e666177..393f70f 100644 --- a/trifling.py +++ b/trifling.py @@ -440,7 +440,7 @@ def asp(bot, trigger): aspsign = '+' else: aspsign = '-' - xmrpercent = (((total / xmrbtc_price ) / 650)-1)*100 + xmrpercent = ((650*(xmrbtc_price*stamp_price)/14950)-1)*100 if xmrpercent >= 0: xmrsign = '+' else: