Ejemplo n.º 1
0
    def get_command_profitability(markdown=False):
        _, bold, code = pretty_printer.get_markers(markdown)
        has_real_trader, has_simulated_trader, \
        real_global_profitability, simulated_global_profitability, \
        real_percent_profitability, simulated_percent_profitability, \
        real_no_trade_profitability, simulated_no_trade_profitability, \
        market_average_profitability = interfaces.get_global_profitability()
        profitability_string = ""
        if has_real_trader:
            real_profitability_pretty = pretty_printer.portfolio_profitability_pretty_print(
                real_global_profitability, None,
                interfaces.get_reference_market())
            profitability_string = \
                f"{bold}{trading_constants.REAL_TRADER_STR}{bold}Global profitability : {code}{real_profitability_pretty}" \
                f"({pretty_printer.get_min_string_from_number(real_percent_profitability, 2)}%){code}, market: {code}" \
                f"{pretty_printer.get_min_string_from_number(market_average_profitability, 2)}%{code}, initial portfolio:" \
                f" {code}{pretty_printer.get_min_string_from_number(real_no_trade_profitability, 2)}%{code}{interfaces.EOL}"
        if has_simulated_trader:
            simulated_profitability_pretty = \
                pretty_printer.portfolio_profitability_pretty_print(
                    simulated_global_profitability, None, interfaces.get_reference_market())
            profitability_string += \
                f"{bold}{trading_constants.SIMULATOR_TRADER_STR}{bold}Global profitability : {code}" \
                f"{simulated_profitability_pretty}" \
                f"({pretty_printer.get_min_string_from_number(simulated_percent_profitability, 2)}%){code}, " \
                f"market: {code}{pretty_printer.get_min_string_from_number(market_average_profitability, 2)}%{code}, " \
                f"initial portfolio: {code}" \
                f"{pretty_printer.get_min_string_from_number(simulated_no_trade_profitability, 2)}%{code}"
        if not profitability_string:
            profitability_string = interfaces.NO_TRADER_MESSAGE

        return profitability_string
Ejemplo n.º 2
0
    def get_command_configuration(markdown=False):
        _, bold, code = pretty_printer.get_markers(markdown)
        message = f"{bold}My configuration:{bold}{interfaces.EOL}{interfaces.EOL}"

        message += f"{bold}Traders: {bold}{interfaces.EOL}"
        if interfaces.has_trader():
            has_real_trader, has_simulated_trader = interfaces.has_real_and_or_simulated_traders(
            )
            if has_real_trader:
                message += f"{code}- Real trader{code}{interfaces.EOL}"
            if has_simulated_trader:
                message += f"{code}- Simulated trader{code}{interfaces.EOL}"
        else:
            message += f"{code}- No activated trader{code}{interfaces.EOL}"

        message += f"{interfaces.EOL}{bold}Exchanges:{bold}{interfaces.EOL}"
        for exchange_name in trading_api.get_exchange_names():
            message += f"{code}- {exchange_name.capitalize()}{code}{interfaces.EOL}"

        try:
            import octobot_evaluators.api as evaluators_api
            import octobot_evaluators.enums as evaluators_enums
            tentacle_setup_config = interfaces.get_bot_api(
            ).get_tentacles_setup_config()
            message += f"{interfaces.EOL}{bold}Evaluators:{bold}{interfaces.EOL}"
            evaluators = evaluators_api.get_evaluator_classes_from_type(
                evaluators_enums.EvaluatorMatrixTypes.TA.value,
                tentacle_setup_config)
            evaluators += evaluators_api.get_evaluator_classes_from_type(
                evaluators_enums.EvaluatorMatrixTypes.SOCIAL.value,
                tentacle_setup_config)
            evaluators += evaluators_api.get_evaluator_classes_from_type(
                evaluators_enums.EvaluatorMatrixTypes.REAL_TIME.value,
                tentacle_setup_config)
            for evaluator in evaluators:
                message += f"{code}- {evaluator.get_name()}{code}{interfaces.EOL}"

            message += f"{interfaces.EOL}{bold}Strategies:{bold}{interfaces.EOL}"
            for strategy in evaluators_api.get_evaluator_classes_from_type(
                    evaluators_enums.EvaluatorMatrixTypes.STRATEGIES.value,
                    tentacle_setup_config):
                message += f"{code}- {strategy.get_name()}{code}{interfaces.EOL}"
        except ImportError:
            message += f"{interfaces.EOL}{bold}Impossible to retrieve evaluation configuration: requires OctoBot-Evaluators " \
                       f"package installed{bold}{interfaces.EOL}"
        try:
            trading_mode = interfaces.get_bot_api().get_trading_mode()
        except IndexError:
            # no activated trader
            trading_mode = None
        if trading_mode:
            message += f"{interfaces.EOL}{bold}Trading mode:{bold}{interfaces.EOL}"
            message += f"{code}- {trading_mode.get_name()}{code}"

        return message
Ejemplo n.º 3
0
 def _print_trades(trades_history, trader_str, markdown=False):
     _, bold, code = pretty_printer.get_markers(markdown)
     trades_history_string = f"{bold}{trader_str}{bold}{code}Trades :{interfaces.EOL}{code}"
     if trades_history:
         for trade in trades_history:
             exchange_name = trading_api.get_trade_exchange_name(trade)
             trades_history_string += \
                 f"{pretty_printer.trade_pretty_printer(exchange_name, trade, markdown=markdown)}{interfaces.EOL}"
     else:
         trades_history_string += f"{code}No trade yet.{code}"
     return trades_history_string
 def _print_open_orders(open_orders, trader_str, markdown=False):
     _, bold, code = get_markers(markdown)
     orders_string = f"{bold}{trader_str}{bold}{code}Open orders :{code}{EOL}"
     if open_orders:
         for order in open_orders:
             exchange_name = get_order_exchange_name(order).capitalize()
             orders_string += open_order_pretty_printer(
                 exchange_name, order_to_dict(order),
                 markdown=markdown) + EOL
     else:
         orders_string += f"{code}No open order yet.{code}"
     return orders_string
 def get_command_fees(markdown=False):
     _, bold, _ = get_markers(markdown)
     real_trader_fees, simulated_trader_fees = get_total_paid_fees()
     result_str = ""
     if real_trader_fees is not None:
         result_str = f"{bold}{REAL_TRADER_STR}{bold}{PAID_FEES_STR}: " \
                      f"{pretty_print_dict(real_trader_fees, markdown=markdown)}"
     if simulated_trader_fees is not None:
         result_str = f"{result_str}\n{bold}{SIMULATOR_TRADER_STR}{bold}{PAID_FEES_STR}: " \
                      f"{pretty_print_dict(simulated_trader_fees, markdown=markdown)}"
     if not result_str:
         result_str = NO_TRADER_MESSAGE
     return result_str
Ejemplo n.º 6
0
 def _print_portfolio(current_val,
                      ref_market,
                      portfolio,
                      trader_str,
                      markdown=False):
     _, bold, code = pretty_printer.get_markers(markdown)
     portfolios_string = f"{bold}{trader_str}{bold}Portfolio value : " \
                         f"{bold}{pretty_printer.get_min_string_from_number(current_val)} {ref_market}{bold}" \
                         f"{interfaces.EOL}"
     portfolio_str = pretty_printer.global_portfolio_pretty_print(
         portfolio, markdown=markdown)
     if not portfolio_str:
         portfolio_str = "Nothing there."
     portfolios_string += f"{bold}{trader_str}{bold}Portfolio : {interfaces.EOL}{code}{portfolio_str}{code}"
     return portfolios_string
Ejemplo n.º 7
0
 def get_command_fees(markdown=False):
     _, bold, _ = pretty_printer.get_markers(markdown)
     real_trader_fees, simulated_trader_fees = interfaces.get_total_paid_fees(
     )
     result_str = ""
     if real_trader_fees is not None:
         result_str = f"{bold}{trading_constants.REAL_TRADER_STR}{bold}{constants.PAID_FEES_STR}: " \
                      f"{pretty_printer.pretty_print_dict(real_trader_fees, markdown=markdown)}"
     if simulated_trader_fees is not None:
         result_str = f"{result_str}\n{bold}{trading_constants.SIMULATOR_TRADER_STR}{bold}" \
                      f"{constants.PAID_FEES_STR}: " \
                      f"{pretty_printer.pretty_print_dict(simulated_trader_fees, markdown=markdown)}"
     if not result_str:
         result_str = interfaces.NO_TRADER_MESSAGE
     return result_str
Ejemplo n.º 8
0
 def get_command_market_status(markdown=False):
     _, bold, code = pretty_printer.get_markers(markdown)
     message = f"{bold}My cryptocurrencies evaluations are:{bold} {interfaces.EOL}{interfaces.EOL}"
     at_least_one_currency = False
     for currency_pair, currency_info in interfaces.get_currencies_with_status(
     ).items():
         at_least_one_currency = True
         message += f"{code}{currency_pair}:{code}{interfaces.EOL}"
         for _, evaluation in currency_info.items():
             message += f"{code}- {evaluation[2].capitalize()}: {evaluation[0]}{code}{interfaces.EOL}"
     if not at_least_one_currency:
         message += f"{code}{interfaces.NO_CURRENCIES_MESSAGE}{code}{interfaces.EOL}"
     risk = interfaces.get_risk()
     if risk:
         message += f"{interfaces.EOL}{code}My current risk is: {interfaces.get_risk()}{code}"
     return message
    def get_command_configuration(markdown=False):
        _, bold, code = get_markers(markdown)
        message = f"{bold}My configuration:{bold}{EOL}{EOL}"

        message += f"{bold}Traders: {bold}{EOL}"
        has_real_trader, has_simulated_trader = has_real_and_or_simulated_traders(
        )
        if has_real_trader:
            message += f"{code}- Real trader{code}{EOL}"
        if has_simulated_trader:
            message += f"{code}- Simulated trader{code}{EOL}"

        message += f"{EOL}{bold}Exchanges:{bold}{EOL}"
        for exchange_name in get_exchange_names():
            message += f"{code}- {exchange_name.capitalize()}{code}{EOL}"

        try:
            from octobot_evaluators.api.evaluators import get_evaluator_classes_from_type
            from octobot_evaluators.enums import EvaluatorMatrixTypes
            tentacle_setup_config = get_bot_api().get_tentacles_setup_config()
            message += f"{EOL}{bold}Evaluators:{bold}{EOL}"
            evaluators = get_evaluator_classes_from_type(
                EvaluatorMatrixTypes.TA.value, tentacle_setup_config)
            evaluators += get_evaluator_classes_from_type(
                EvaluatorMatrixTypes.SOCIAL.value, tentacle_setup_config)
            evaluators += get_evaluator_classes_from_type(
                EvaluatorMatrixTypes.REAL_TIME.value, tentacle_setup_config)
            for evaluator in evaluators:
                message += f"{code}- {evaluator.get_name()}{code}{EOL}"

            message += f"{EOL}{bold}Strategies:{bold}{EOL}"
            for strategy in get_evaluator_classes_from_type(
                    EvaluatorMatrixTypes.STRATEGIES.value,
                    tentacle_setup_config):
                message += f"{code}- {strategy.get_name()}{code}{EOL}"
        except ImportError:
            message += f"{EOL}{bold}Impossible to retrieve evaluation configuration: requires OctoBot-Evaluators " \
                       f"package installed{bold}{EOL}"

        message += f"{EOL}{bold}Trading mode:{bold}{EOL}"
        trading_mode = get_bot_api().get_trading_mode()
        if trading_mode:
            message += f"{code}- {trading_mode.get_name()}{code}"

        return message