Exemple #1
0
    def get_command_open_orders():
        has_real_trader, has_simulated_trader = has_real_and_or_simulated_traders(
        )
        portfolio_real_open_orders, portfolio_simulated_open_orders = get_open_orders(
        )

        orders_string = ""
        if has_real_trader:
            orders_string += f"{REAL_TRADER_STR}Open orders :{EOL}"
            for orders in portfolio_real_open_orders:
                for order in orders:
                    orders_string += PrettyPrinter.open_order_pretty_printer(
                        order) + EOL

        if has_simulated_trader:
            orders_string += EOL + f"{SIMULATOR_TRADER_STR}Open orders :{EOL}"
            for orders in portfolio_simulated_open_orders:
                for order in orders:
                    orders_string += PrettyPrinter.open_order_pretty_printer(
                        order) + EOL

        if not orders_string:
            orders_string = NO_TRADER_MESSAGE

        return orders_string
Exemple #2
0
    def command_open_orders(_, update):
        has_real_trader, has_simulated_trader = has_real_and_or_simulated_traders(
        )
        portfolio_real_open_orders, portfolio_simulated_open_orders = get_open_orders(
        )

        orders_string = ""
        if has_real_trader:
            orders_string += "{0}Open orders :{1}".format(
                REAL_TRADER_STR, TelegramApp.EOL)
            for orders in portfolio_real_open_orders:
                for order in orders:
                    orders_string += PrettyPrinter.open_order_pretty_printer(
                        order) + TelegramApp.EOL

        if has_simulated_trader:
            orders_string += TelegramApp.EOL + "{0}Open orders :{1}".format(
                SIMULATOR_TRADER_STR, TelegramApp.EOL)
            for orders in portfolio_simulated_open_orders:
                for order in orders:
                    orders_string += PrettyPrinter.open_order_pretty_printer(
                        order) + TelegramApp.EOL

        if not orders_string:
            orders_string = TelegramApp.NO_TRADER_MESSAGE

        update.message.reply_text(orders_string)
Exemple #3
0
    def notify_create(self, evaluator_notification, orders):
        if orders:
            content = orders[0].trader.trader_type_str
            if evaluator_notification is not None:
                self.evaluator_notification = evaluator_notification

            title = "Order(s) creation "
            content += title
            for order in orders:
                content += "\n- {0}".format(
                    PrettyPrinter.open_order_pretty_printer(order))

            if self.twitter_notification_available(CONFIG_NOTIFICATION_TRADES) \
                    and self.evaluator_notification is not None \
                    and self.evaluator_notification.get_tweet_instance() is not None:
                tweet_instance = self.evaluator_notification.get_tweet_instance(
                )
                self.twitter_response_factory(tweet_instance, content)

            if self.telegram_notification_available(
                    CONFIG_NOTIFICATION_TRADES):
                self.telegram_notification_factory(content)

            if self.web_interface_notification_available(
                    CONFIG_NOTIFICATION_TRADES):
                self.web_interface_notification_factory(
                    InterfaceLevel.INFO, title, content)
Exemple #4
0
    def notify_end(self,
                   order_filled,
                   orders_canceled,
                   trade_profitability,
                   portfolio_profitability,
                   portfolio_diff,
                   profitability=False):

        title = "Order status updated"
        content = ""

        if order_filled is not None:
            content += "\n{0}Order(s) filled : \n- {1}".format(
                order_filled.trader.trader_type_str,
                PrettyPrinter.open_order_pretty_printer(order_filled))

        if orders_canceled is not None and len(orders_canceled) > 0:
            content += "\n{0}Order(s) canceled :".format(
                orders_canceled[0].trader.trader_type_str)
            for order in orders_canceled:
                content += "\n- {0}".format(
                    PrettyPrinter.open_order_pretty_printer(order))

        if trade_profitability is not None and profitability:
            content += "\n\nTrade profitability : {0}{1}%".format(
                "+" if trade_profitability >= 0 else "",
                round(trade_profitability * 100, 7))

        if portfolio_profitability is not None and profitability:
            content += "\nGlobal Portfolio profitability : {0}% {1}{2}%".format(
                round(portfolio_profitability, 5),
                "+" if portfolio_diff >= 0 else "", round(portfolio_diff, 7))

        if self.twitter_notification_available(CONFIG_NOTIFICATION_TRADES) \
                and self.evaluator_notification is not None \
                and self.evaluator_notification.get_tweet_instance() is not None:
            tweet_instance = self.evaluator_notification.get_tweet_instance()

            self.twitter_response_factory(tweet_instance, content)

        if self.telegram_notification_available(CONFIG_NOTIFICATION_TRADES):
            self.telegram_notification_factory(content)

        if self.web_interface_notification_available(
                CONFIG_NOTIFICATION_TRADES):
            self.web_interface_notification_factory(InterfaceLevel.INFO, title,
                                                    content)
Exemple #5
0
    def command_open_orders(_, update):
        portfolio_real_open_orders, portfolio_simulated_open_orders = get_open_orders()

        portfolio_real_current_value_string = TelegramApp.EOL
        for orders in portfolio_real_open_orders:
            for order in orders:
                portfolio_real_current_value_string += PrettyPrinter.open_order_pretty_printer(order) + \
                                                       TelegramApp.EOL

        portfolio_simulated_current_value_string = TelegramApp.EOL
        for orders in portfolio_simulated_open_orders:
            for order in orders:
                portfolio_simulated_current_value_string += PrettyPrinter.open_order_pretty_printer(order) + \
                                                            TelegramApp.EOL

        update.message.reply_text("Real open orders : {0}".format(portfolio_real_current_value_string))
        update.message.reply_text("Simulated open orders : {0}".format(portfolio_simulated_current_value_string))
Exemple #6
0
 def _print_open_orders(open_orders, trader_str, markdown=False):
     _, b, c = PrettyPrinter.get_markets(markdown)
     orders_string = f"{b}{trader_str}{b}{c}Open orders :{c}{EOL}"
     for orders in open_orders:
         if orders:
             for order in orders:
                 orders_string += PrettyPrinter.open_order_pretty_printer(order, markdown=markdown) + EOL
         else:
             orders_string += f"{c}No open order yet.{c}"
     return orders_string
Exemple #7
0
    def command_open_orders(_, update):
        portfolio_real_open_orders, portfolio_simulated_open_orders = get_open_orders(
        )

        portfolio_real_current_value_string = TelegramApp.EOL
        for orders in portfolio_real_open_orders:
            for order in orders:
                portfolio_real_current_value_string += PrettyPrinter.open_order_pretty_printer(order) + \
                                                       TelegramApp.EOL

        portfolio_simulated_current_value_string = TelegramApp.EOL
        for orders in portfolio_simulated_open_orders:
            for order in orders:
                portfolio_simulated_current_value_string += PrettyPrinter.open_order_pretty_printer(order) + \
                                                            TelegramApp.EOL

        update.message.reply_text("Real open orders : {0}".format(
            portfolio_real_current_value_string))
        update.message.reply_text("Simulated open orders : {0}".format(
            portfolio_simulated_current_value_string))
Exemple #8
0
    def notify_end(self,
                   order_filled,
                   orders_canceled,
                   trade_profitability,
                   portfolio_profitability,
                   portfolio_diff,
                   profitability=False):

        content = ""

        if order_filled is not None:
            content += "\nOrder(s) filled : \n- {0}".format(
                PrettyPrinter.open_order_pretty_printer(order_filled))

        if orders_canceled is not None and len(orders_canceled) > 0:
            content += "\nOrder(s) canceled :"
            for order in orders_canceled:
                content += "\n- {0}".format(
                    PrettyPrinter.open_order_pretty_printer(order))

        if trade_profitability is not None and profitability:
            content += "\n\nTrade profitability : {0}{1}%".format(
                "+" if trade_profitability >= 0 else "",
                round(trade_profitability * 100, 7))

        if portfolio_profitability is not None and profitability:
            content += "\nGlobal Portfolio profitability : {0}% {1}{2}%".format(
                round(portfolio_profitability, 5),
                "+" if portfolio_diff >= 0 else "", round(portfolio_diff, 7))

        if self.twitter_notification_available() \
                and self.evaluator_notification is not None \
                and self.evaluator_notification.get_tweet_instance() is not None:
            tweet_instance = self.evaluator_notification.get_tweet_instance()

            self.twitter_response_factory(tweet_instance, content)

        if self.telegram_notification_available():
            self.telegram_notification_factory(content)
    def notify_end(self,
                   order_filled,
                   orders_canceled,
                   trade_profitability,
                   portfolio_profitability,
                   portfolio_diff,
                   profitability=False):

        content = ""

        if order_filled is not None:
            content += "\nOrder(s) filled : \n- {0}".format(PrettyPrinter.open_order_pretty_printer(order_filled))

        if orders_canceled is not None and len(orders_canceled) > 0:
            content += "\nOrder(s) canceled :"
            for order in orders_canceled:
                content += "\n- {0}".format(PrettyPrinter.open_order_pretty_printer(order))

        if trade_profitability is not None and profitability:
            content += "\n\nTrade profitability : {0}{1}%".format("+" if trade_profitability >= 0 else "",
                                                                  round(trade_profitability * 100, 7))

        if portfolio_profitability is not None and profitability:
            content += "\nGlobal Portfolio profitability : {0}% {1}{2}%".format(round(portfolio_profitability, 5),
                                                                                "+" if portfolio_diff >= 0 else "",
                                                                                round(portfolio_diff, 7))

        if self.twitter_notification_available() \
                and self.evaluator_notification is not None \
                and self.evaluator_notification.get_tweet_instance() is not None:
            tweet_instance = self.evaluator_notification.get_tweet_instance()

            self.twitter_response_factory(tweet_instance, content)

        if self.telegram_notification_available():
            self.telegram_notification_factory(content)
Exemple #10
0
    def notify_create(self, evaluator_notification, orders):
        if evaluator_notification is not None:
            self.evaluator_notification = evaluator_notification

        content = "Order(s) creation "
        for order in orders:
            content += "\n- {0}".format(PrettyPrinter.open_order_pretty_printer(order))

        if self.twitter_notification_available() \
                and self.evaluator_notification is not None \
                and self.evaluator_notification.get_tweet_instance() is not None:
            tweet_instance = self.evaluator_notification.get_tweet_instance()
            self.twitter_response_factory(tweet_instance, content)

        if self.telegram_notification_available():
            self.telegram_notification_factory(content)
Exemple #11
0
    def notify_create(self, evaluator_notification, orders):
        if evaluator_notification is not None:
            self.evaluator_notification = evaluator_notification

        content = "Order(s) creation "
        for order in orders:
            content += "\n- {0}".format(
                PrettyPrinter.open_order_pretty_printer(order))

        if self.twitter_notification_available() \
                and self.evaluator_notification is not None \
                and self.evaluator_notification.get_tweet_instance() is not None:
            tweet_instance = self.evaluator_notification.get_tweet_instance()
            self.twitter_response_factory(tweet_instance, content)

        if self.telegram_notification_available():
            self.telegram_notification_factory(content)