Skip to content

Commit

Permalink
Display total value depending on asset two
Browse files Browse the repository at this point in the history
  • Loading branch information
Endogen committed Jan 25, 2018
1 parent ec7f375 commit fdef6b5
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions telegram_kraken_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ def trade_currency(bot, update, chat_data):


# Save price per unit and choose how to enter the
# trade volume (euro, volume or all available funds)
# trade volume (fiat currency, volume or all available funds)
def trade_price(bot, update, chat_data):
chat_data["price"] = update.message.text

Expand Down Expand Up @@ -559,7 +559,7 @@ def trade_vol_type_all(bot, update, chat_data):

# SELL
if chat_data["buysell"].upper() == KeyboardEnum.SELL.clean():
# Send request to Kraken to get euro balance to calculate volume
# Send request to Kraken to get your coin balance to calculate volume
res_balance = kraken_api("Balance", private=True)

# If Kraken replied with an error, show it
Expand Down Expand Up @@ -960,9 +960,6 @@ def value_cmd(bot, update):
return WorkflowEnum.VALUE_CURRENCY


# TODO: For currencies that trade to XBT, option in config to not show value in XBT, but in EUR?
# TODO: If so, then get trade string from XBT, to know which fiat to use...
# TODO: This will only work if XBT is in config COINS_USED...
# Choose for which currency you want to know the current value
def value_currency(bot, update):
update.message.reply_text(emo_wa + " Retrieving current value...")
Expand All @@ -986,13 +983,13 @@ def value_currency(bot, update):
if data["altname"] == config["base_currency"]:
if asset.startswith("Z"):
# It's a fiat currency, show only 2 digits after decimal place
total_value_euro = "{0:.2f}".format(float(res_trade_balance["result"]["eb"]))
total_fiat_value = "{0:.2f}".format(float(res_trade_balance["result"]["eb"]))
else:
# It's not a fiat currency, show 8 digits after decimal place
total_value_euro = "{0:.8f}".format(float(res_trade_balance["result"]["eb"]))
total_fiat_value = "{0:.8f}".format(float(res_trade_balance["result"]["eb"]))

# Generate message to user
msg = "Overall: " + total_value_euro + " " + config["base_currency"]
msg = "Overall: " + total_fiat_value + " " + config["base_currency"]
update.message.reply_text(bold(msg), reply_markup=keyboard_cmds(), parse_mode=ParseMode.MARKDOWN)

# ONE COINS (balance of specific coin)
Expand Down

0 comments on commit fdef6b5

Please sign in to comment.