Skip to content

Commit

Permalink
Fix notifications : only concerned symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Bouquet committed May 5, 2018
1 parent 9a6d7dd commit 8d67355
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 23 deletions.
1 change: 1 addition & 0 deletions evaluator/evaluator_final.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def _set_state(self, new_state):
evaluator_notification = self.notifier.notify_state_changed(
self.final_eval,
self.symbol_evaluator.get_crypto_currency_evaluator(),
self.symbol_evaluator.get_symbol(),
self.symbol_evaluator.get_trader(self.exchange),
self.state,
self.symbol_evaluator.get_matrix(self.exchange).get_matrix())
Expand Down
3 changes: 3 additions & 0 deletions evaluator/symbol_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,8 @@ def get_strategies_eval_list(self, exchange):
def get_evaluator_order_creator(self):
return self.evaluator_order_creator

def get_symbol(self):
return self.symbol

def get_crypto_currency_evaluator(self):
return self.crypto_currency_evaluator
46 changes: 23 additions & 23 deletions tools/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,33 +83,33 @@ def __init__(self, config):
super().__init__(config)
self.tweet_instance = None

def notify_state_changed(self, final_eval, crypto_currency_evaluator, trader, result, matrix):
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)))
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)))

if self.twitter_notification_available():
# + "\n see more at https://github.com/Trading-Bot/CryptoBot"
formatted_pairs = [p.replace("/", "") for p in crypto_currency_evaluator.get_symbol_pairs()]
self.tweet_instance = self.twitter_notification_factory("CryptoBot ALERT : #{0} "
"\n Cryptocurrency : #{1}"
"\n Result : {2}"
"\n Evaluation : {3}".format(
crypto_currency_evaluator.crypto_currency,
" #".join(formatted_pairs),
str(result).split(".")[1],
final_eval)
self.tweet_instance = self.twitter_notification_factory(
"CryptoBot ALERT : #{0} "
"\n Symbol : #{1}"
"\n Result : {2}"
"\n Evaluation : {3}".format(
crypto_currency_evaluator.crypto_currency,
symbol.replace("/", ""),
str(result).split(".")[1],
final_eval)
)

return self
Expand Down Expand Up @@ -186,7 +186,7 @@ def notify_end(self,

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))
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),
Expand Down

0 comments on commit 8d67355

Please sign in to comment.