def portfolio(): real_portfolio, simulated_portfolio = get_global_portfolio_currencies_amounts( ) filtered_real_portfolio = { currency: amounts for currency, amounts in real_portfolio.items() if amounts[Portfolio.TOTAL] > 0 } filtered_simulated_portfolio = { currency: amounts for currency, amounts in simulated_portfolio.items() if amounts[Portfolio.TOTAL] > 0 } _, _, portfolio_real_current_value, portfolio_simulated_current_value = get_portfolio_current_value( ) reference_market = get_reference_market() return render_template('portfolio.html', simulated_portfolio=filtered_simulated_portfolio, real_portfolio=filtered_real_portfolio, simulated_total_value=round( portfolio_simulated_current_value, 8), real_total_value=round(portfolio_real_current_value, 8), reference_unit=reference_market)
def command_portfolio(_, update): has_real_trader, has_simulated_trader, \ portfolio_real_current_value, portfolio_simulated_current_value = get_portfolio_current_value() reference_market = get_reference_market() real_global_portfolio, simulated_global_portfolio = get_global_portfolio_currencies_amounts( ) portfolios_string = "" if has_real_trader: portfolios_string += "{0}Portfolio value : {1} {2}{3}".format( REAL_TRADER_STR, PrettyPrinter.get_min_string_from_number( portfolio_real_current_value), reference_market, TelegramApp.EOL) portfolios_string += "{0}Portfolio : {2}{1}{2}{2}".format( REAL_TRADER_STR, PrettyPrinter.global_portfolio_pretty_print( real_global_portfolio), TelegramApp.EOL) if has_simulated_trader: portfolios_string += "{0}Portfolio value : {1} {2}{3}".format( SIMULATOR_TRADER_STR, PrettyPrinter.get_min_string_from_number( portfolio_simulated_current_value), reference_market, TelegramApp.EOL) portfolios_string += "{0}Portfolio : {2}{1}".format( SIMULATOR_TRADER_STR, PrettyPrinter.global_portfolio_pretty_print( simulated_global_portfolio), TelegramApp.EOL) if not portfolios_string: portfolios_string = TelegramApp.NO_TRADER_MESSAGE update.message.reply_text(portfolios_string)
def command_portfolio(_, update): portfolio_real_current_value, portfolio_simulated_current_value = get_portfolio_current_value() reference_market = get_reference_market() real_global_portfolio, simulated_global_portfolio = get_global_portfolio_currencies_amounts() update.message.reply_text("Portfolio real value : {0} {1}".format(portfolio_real_current_value, reference_market)) update.message.reply_text("Global real portfolio : \n{0}" .format(PrettyPrinter.global_portfolio_pretty_print(real_global_portfolio))) update.message.reply_text("Portfolio simulated value : {0} {1}".format(portfolio_simulated_current_value, reference_market)) update.message.reply_text("Global simulated portfolio : \n{0}" .format(PrettyPrinter.global_portfolio_pretty_print(simulated_global_portfolio)))
def command_portfolio(_, update): portfolio_real_current_value, portfolio_simulated_current_value = get_portfolio_current_value( ) reference_market = get_reference_market() real_global_portfolio, simulated_global_portfolio = get_global_portfolio_currencies_amounts( ) update.message.reply_text("Portfolio real value : {0} {1}".format( portfolio_real_current_value, reference_market)) update.message.reply_text("Global real portfolio : \n{0}".format( PrettyPrinter.global_portfolio_pretty_print( real_global_portfolio))) update.message.reply_text("Portfolio simulated value : {0} {1}".format( portfolio_simulated_current_value, reference_market)) update.message.reply_text("Global simulated portfolio : \n{0}".format( PrettyPrinter.global_portfolio_pretty_print( simulated_global_portfolio)))
def get_command_portfolio(markdown=False): _, b, c = PrettyPrinter.get_markets(markdown) has_real_trader, has_simulated_trader, \ portfolio_real_current_value, portfolio_simulated_current_value = get_portfolio_current_value() reference_market = get_reference_market() real_global_portfolio, simulated_global_portfolio = get_global_portfolio_currencies_amounts() portfolios_string = "" if has_real_trader: portfolios_string += InterfaceBot._print_portfolio(portfolio_real_current_value, reference_market, real_global_portfolio, REAL_TRADER_STR, markdown) if has_simulated_trader: portfolio_str = InterfaceBot._print_portfolio(portfolio_simulated_current_value, reference_market, simulated_global_portfolio, SIMULATOR_TRADER_STR, markdown) portfolios_string += f"{EOL}{portfolio_str}" if not portfolios_string: portfolios_string = NO_TRADER_MESSAGE return portfolios_string
def get_command_portfolio(): has_real_trader, has_simulated_trader, \ portfolio_real_current_value, portfolio_simulated_current_value = get_portfolio_current_value() reference_market = get_reference_market() real_global_portfolio, simulated_global_portfolio = get_global_portfolio_currencies_amounts( ) portfolios_string = "" if has_real_trader: portfolios_string += f"{REAL_TRADER_STR}Portfolio value : " \ f"{PrettyPrinter.get_min_string_from_number(portfolio_real_current_value)} {reference_market}{EOL}" portfolios_string += f"{REAL_TRADER_STR}Portfolio : {EOL}" \ f"{PrettyPrinter.global_portfolio_pretty_print(real_global_portfolio)}{EOL}{EOL}" if has_simulated_trader: portfolios_string += f"{SIMULATOR_TRADER_STR}Portfolio value : " \ f"{PrettyPrinter.get_min_string_from_number(portfolio_simulated_current_value)} {reference_market}{EOL}" portfolios_string += f"{SIMULATOR_TRADER_STR}Portfolio : {EOL}" \ f"{PrettyPrinter.global_portfolio_pretty_print(simulated_global_portfolio)}" if not portfolios_string: portfolios_string = NO_TRADER_MESSAGE return portfolios_string
def update_portfolio_history(): real_value, simulated_value = get_portfolio_current_value() add_to_portfolio_value_history(real_value, simulated_value)
def update_portfolio_history(): real_value, simulated_value = get_portfolio_current_value() add_to_portfolio_value_history(real_value, simulated_value)