def test_get_reference_market(self): config, _, trader_inst, _ = self.init_default() assert TradesManager.get_reference_market(config) == DEFAULT_REFERENCE_MARKET config[CONFIG_TRADER][CONFIG_TRADER_REFERENCE_MARKET] = "ETH" assert TradesManager.get_reference_market(config) == "ETH" self.stop(trader_inst)
def test_get_reference_market(self): config, _, trader_inst, _ = self.init_default() assert TradesManager.get_reference_market(config) == DEFAULT_REFERENCE_MARKET config[CONFIG_TRADING][CONFIG_TRADER_REFERENCE_MARKET] = "ETH" assert TradesManager.get_reference_market(config) == "ETH" self.stop(trader_inst)
def notify_state_changed(self, final_eval, crypto_currency_evaluator, symbol, trader, result, matrix): if self.gmail_notification_available(): profitability, profitability_percent, _ = trader.get_trades_manager( ).get_profitability() self.gmail_notification_factory( "CRYPTO BOT ALERT : {0} / {1}".format( crypto_currency_evaluator.crypto_currency, result), "CRYPTO BOT ALERT : {0} / {1} \n {2} \n Current portfolio " "profitability : {3} " "{4} ({5}%)".format( crypto_currency_evaluator.crypto_currency, result, pprint.pformat(matrix), round(profitability, 2), TradesManager.get_reference_market(self.config), round(profitability_percent, 2))) alert_content = PrettyPrinter.cryptocurrency_alert( crypto_currency_evaluator.crypto_currency, symbol, result, final_eval) if self.twitter_notification_available(): self.tweet_instance = self.twitter_notification_factory( alert_content) if self.telegram_notification_available(): self.telegram_notification_factory(alert_content) return self
def notify_alert(self, final_eval, crypto_currency_evaluator, symbol, trader, result, matrix): title = f"OCTOBOT ALERT : {crypto_currency_evaluator.crypto_currency} / {result}" if self.gmail_notification_available(CONFIG_NOTIFICATION_PRICE_ALERTS): profitability, profitability_percent, _, _ = trader.get_trades_manager().get_profitability() self.gmail_notification_factory( title, "OCTOBOT ALERT : {0} / {1} \n {2} \n Current portfolio " "profitability : {3} " "{4} ({5}%)".format( crypto_currency_evaluator.crypto_currency, result, pprint.pformat(matrix), round(profitability, 2), TradesManager.get_reference_market(self.config), round(profitability_percent, 2))) alert_content = PrettyPrinter.cryptocurrency_alert( crypto_currency_evaluator.crypto_currency, symbol, result, final_eval) self.tweet_instance = self.send_twitter_notification_if_necessary(alert_content, CONFIG_NOTIFICATION_PRICE_ALERTS) self.send_telegram_notification_if_necessary(alert_content, CONFIG_NOTIFICATION_PRICE_ALERTS) self.send_web_notification_if_necessary(InterfaceLevel.INFO, title, alert_content, CONFIG_NOTIFICATION_PRICE_ALERTS) return self
def notify_state_changed(self, final_eval, symbol_evaluator, trader, result, matrix): if self.gmail_notification_available(): profitability, profitability_percent = trader.get_trades_manager( ).get_profitability() self.gmail_notification_factory( "CRYPTO BOT ALERT : {0} / {1}".format( symbol_evaluator.crypto_currency, result), "CRYPTO BOT ALERT : {0} / {1} \n {2} \n Current portfolio " "profitability : {3} " "{4} ({5}%)".format( symbol_evaluator.crypto_currency, result, pprint.pformat(matrix), round(profitability, 2), TradesManager.get_reference_market(self.config), round(profitability_percent, 2))) if self.twitter_notification_available(): # + "\n see more at https://github.com/Trading-Bot/CryptoBot" formatted_pairs = [ p.replace("/", "") for p in symbol_evaluator.get_symbol_pairs() ] self.tweet_instance = self.twitter_notification_factory( "CryptoBot ALERT : #{0} " "\n Cryptocurrency : #{1}" "\n Result : {2}" "\n Evaluation : {3}".format(symbol_evaluator.crypto_currency, " #".join(formatted_pairs), str(result).split(".")[1], final_eval)) return self
def notify_end(self, order_filled, orders_canceled, symbol, trade_profitability, portfolio_profitability): if self.twitter_notification_available() \ and self.evaluator_notification is not None \ and self.evaluator_notification.get_tweet_instance() is not None: currency, market = Exchange.split_symbol(symbol) tweet_instance = self.evaluator_notification.get_tweet_instance() content = "" if order_filled is not None: content += "Order filled \n {0}".format( OrdersNotification.twitter_order_description( order_filled.get_order_type(), order_filled.get_origin_quantity(), currency, order_filled.get_origin_price(), market)) if orders_canceled is not None and len(orders_canceled) > 0: content += "\n Order canceled " for order in orders_canceled: content += "\n {0}".format( OrdersNotification.twitter_order_description( order.get_order_type(), order.get_origin_quantity(), currency, order.get_origin_price(), market)) if trade_profitability is not None: content += "\n Trade profitability : {0} {1}".format( round(trade_profitability, 7), TradesManager.get_reference_market(self.config)) if portfolio_profitability is not None: content += "\n Portfolio profitability : {0}%".format( round(portfolio_profitability, 5)) self.twitter_response_factory(tweet_instance, content)
def notify_state_changed(self, final_eval, crypto_currency_evaluator, symbol, trader, result, matrix): if self.gmail_notification_available(): profitability, profitability_percent, _ = trader.get_trades_manager().get_profitability() self.gmail_notification_factory( "CRYPTO BOT ALERT : {0} / {1}".format(crypto_currency_evaluator.crypto_currency, result), "CRYPTO BOT ALERT : {0} / {1} \n {2} \n Current portfolio " "profitability : {3} " "{4} ({5}%)".format( crypto_currency_evaluator.crypto_currency, result, pprint.pformat(matrix), round(profitability, 2), TradesManager.get_reference_market(self.config), round(profitability_percent, 2))) alert_content = PrettyPrinter.cryptocurrency_alert( crypto_currency_evaluator.crypto_currency, symbol, result, final_eval) if self.twitter_notification_available(): self.tweet_instance = self.twitter_notification_factory(alert_content) if self.telegram_notification_available(): self.telegram_notification_factory(alert_content) return self