def calculate_fees(): # TODO Should this take in the data models or call it itself trade_history = TradeHistory(trading_api.return_trade_history()) all_fees = trade_history.get_all_fees() all_prices = public_api.return_ticker() fee_dict = defaultdict(float) print "--------------All Fees--------------" for currency_pair, fees in all_fees.iteritems(): print "{}={}".format(currency_pair, fees) base_currency = currency_pair.split("_")[0] fee_dict[base_currency] += fees total_fees = 0 print "-------------Total Fees-------------" for currency, fees in fee_dict.iteritems(): if currency != "BCC": if currency == "USDT": total_fees += float(all_prices["USDT_BCC"]['last']) * fees else: total_fees += float( all_prices["BCC_" + currency]['last']) * fees else: total_fees += fees print "Total fees in BCC={}".format(total_fees)
def get_detailed_overview(): ticker_price = TickerPrice(public_api.return_ticker()) trade_history = trading_api.return_trade_history() print "Warning, if you made non BCC trades, for example, ETH to USDT, some" print "of the values may look unusual. Since non BCC trades have not been" print "calculated in." for ticker in trade_history: if ticker.startswith("BCC_"): current = list(reversed(trade_history[ticker])) bcc_sum = 0 for trade in current: if trade['type'] == 'buy': bcc_sum += float(trade["total"]) else: # For some reason, the total for sells do not include the # fee so we include it here. bcc_sum -= (float(trade["total"]) * (1 - float(trade["fee"]))) print "bcc_sum = {}".format(bcc_sum) ticker_sum = 0 for trade in current: if trade['type'] == 'buy': ticker_sum += float(trade["amount"]) # Total ticker_sum -= float(trade["amount"]) * float( trade["fee"]) # Fee else: ticker_sum -= float(trade["amount"]) print "ticker_sum = {}".format(ticker_sum) if ticker_sum > -1: # Set to 0.000001 to hide 0 balances current_bcc_sum = float( ticker_price.get_price_for_ticker(ticker)) * ticker_sum total_bcc = current_bcc_sum - bcc_sum total_usd = float("{:.4}".format( total_bcc * ticker_price.get_price_for_ticker("USDT_BCC"))) print "--------------{}----------------".format(ticker) print "You invested {} BCC for {} {}/{} BCC".format( bcc_sum, ticker_sum, ticker.split("_")[1], current_bcc_sum) print "If you sold it all at the current price (assuming enough sell orders)" if total_bcc < 0: print utils.bcolors.RED, else: print utils.bcolors.GREEN, print "{} BCC/{} USD".format(total_bcc, total_usd) print utils.bcolors.END_COLOR, return current
def get_overview(): balances = Balances(trading_api.return_complete_balances()) dw_history = DWHistory(trading_api.return_deposits_withdrawals()) deposits, withdrawals = dw_history.get_dw_history() utils.print_dw_history(deposits, withdrawals) balance = dw_history.get_btc_balance(public_api.return_ticker()) current = balances.get_btc_total() usd_btc_price = return_usd_btc() balance_percentage = float("{:.4}".format(current / balance * 100)) btc_balance_sum = current - balance usd_balance_sum = "{:.2f}".format(btc_balance_sum * usd_btc_price) print "---Earnings/Losses Against Balance--" print "{} BTC/${}".format(btc_balance_sum, usd_balance_sum) if balance_percentage < 100: print "Stop trading! You're an idiot!" print "{}%".format(balance_percentage) elif balance_percentage < 110: print "You bring dishonor to your family." print "{}%".format(balance_percentage) elif balance_percentage < 150: print "Potatoes do better trading than you." print "{}%".format(balance_percentage) elif balance_percentage < 175: print "Describes your trading-style in a single sentence: https://www.youtube.com/watch?v=dQw4w9WgXcQ" print "{}%".format(balance_percentage) elif balance_percentage < 200: print "Like streaking at a wedding" print "{}%".format(balance_percentage) elif balance_percentage < 250: print "On your way to becoming a bitcoin sensei rockstar ninja guru." print "{}%".format(balance_percentage) else: print "Cryptocurrencies can get heavy, you should buy drugs on the internet with them. Down with the government!" print "{}%".format(balance_percentage)
def get_overview(): balances = Balances(trading_api.return_complete_balances()) dw_history = DWHistory(trading_api.return_deposits_withdrawals()) deposits, withdrawals = dw_history.get_dw_history() utils.print_dw_history(deposits, withdrawals) balance = dw_history.get_btc_balance(public_api.return_ticker()) current = balances.get_btc_total() usd_btc_price = return_usd_btc() balance_percentage = float("{:.4}".format(current / balance * 100)) btc_balance_sum = current - balance usd_balance_sum = "{:.2f}".format(btc_balance_sum * usd_btc_price) print "---Earnings/Losses Against Balance--" print "{} BTC/${}".format(btc_balance_sum, usd_balance_sum) if balance_percentage < 100: print "Stop trading!" print "{}%".format(balance_percentage) elif balance_percentage < 110: print "Still worse than an index." print "{}%".format(balance_percentage) elif balance_percentage < 150: print "Not bad" print "{}%".format(balance_percentage) elif balance_percentage < 175: print "You belong here" print "{}%".format(balance_percentage) elif balance_percentage < 200: print "Like striking crypto-oil" print "{}%".format(balance_percentage) elif balance_percentage < 250: print "On your way to becoming a bitcoin millionaire" print "{}%".format(balance_percentage) else: print "Cryptocurrencies can get heavy, you should send them over to me for safe keeping!" print "{}%".format(balance_percentage)
def __init__(self): self.ticker_price = public_api.return_ticker()