Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow conditional notifications #388

Open
wants to merge 61 commits into
base: develop
Choose a base branch
from
Open
Changes from 3 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
069cc31
Allow conditional notifications
Aug 1, 2020
2f3a9e1
Correct DatetimeIndex error due to new version of pandas
Aug 2, 2020
ca74b30
delete
w1ld3r Aug 2, 2020
ddc2019
Correct crossover
Aug 2, 2020
f4b1204
Merge pull request #1 from CryptoSignal/develop
w1ld3r Aug 3, 2020
305388e
Merge pull request #2 from CryptoSignal/develop
w1ld3r Aug 4, 2020
8ffc451
Format document
Aug 5, 2020
79ea219
Update Dockerfile
w1ld3r Nov 22, 2020
5cd159c
Merge pull request #3 from CryptoSignal/develop
w1ld3r Nov 22, 2020
2b13b19
Update issue templates
w1ld3r Dec 2, 2020
8bebae2
Update issue templates
w1ld3r Dec 2, 2020
d187dff
Update bug_report.md
w1ld3r Dec 2, 2020
64956c7
Update bug_report.md
w1ld3r Dec 2, 2020
fcfd022
Update issue templates
w1ld3r Dec 2, 2020
249e5fa
Update README.md
w1ld3r Dec 2, 2020
4afde15
Merge pull request #11 from CryptoSignal/develop
w1ld3r Dec 29, 2020
1101e77
Merge pull request #13 from CryptoSignal/develop
w1ld3r Jan 24, 2021
3266bb5
Merge pull request #14 from CryptoSignal/develop
w1ld3r Feb 18, 2021
e7a3a9c
Custom smtp server
chamoda May 1, 2021
c717379
Add notification with conditional
May 1, 2021
e5a6c54
Merge pull request #20 from chamoda/custom-smtp-server
w1ld3r May 12, 2021
f650d83
add price_value functionality to conditional
May 24, 2021
9a7aafb
add decimal_format in conditional reformated message
May 26, 2021
699f3a4
adding doc for decimal_format casting in jinja template
May 26, 2021
31e2d99
Merge branch 'develop' of https://github.com/x1n5h3n/crypto-signal in…
May 27, 2021
e532d61
Add Advanced Settings doc et update conditionals doc
w1ld3r Jun 19, 2021
f95af1b
Update Advanced Settings doc
w1ld3r Jun 19, 2021
0f74f5e
Update bug_report.md
w1ld3r Jul 1, 2021
56851a7
[FEATURE] Multiple notifier from the same family
w1ld3r Jul 3, 2021
a99514b
Merge branch 'develop' of github.com:w1ld3r/crypto-signal into develop
w1ld3r Jul 3, 2021
a0a23cd
[UPDATE] Update doc for multiple notifier functionality
w1ld3r Jul 4, 2021
44f27b9
[FEATURE] Add ability to request market future api
w1ld3r Jul 5, 2021
f3689d8
[Merge] Merge New source changes
w1ld3r Jul 5, 2021
4e26750
Merge branch 'develop' of https://github.com/CryptoSignal/Crypto-Sign…
w1ld3r Jul 5, 2021
72827f7
Merge branch 'CryptoSignal-develop' into develop
w1ld3r Jul 5, 2021
bee5f83
remove error
w1ld3r Jul 7, 2021
9835f5a
add check on split market pair
Jul 23, 2021
bf91f18
correct alert once in conditionnal
Jul 24, 2021
8a27d38
Fix uninitialized conditional_mode variable
Aug 3, 2021
3d8c91c
Add candle_period in message for conditional
Aug 13, 2021
d01d948
add try catch on telegram notify function
Sep 1, 2021
ceb8175
Add alert_frequency in timedelta format (day, hour, minutes, seconds)…
Sep 3, 2021
2011750
correct errors
Sep 3, 2021
0095bc1
Add alert_frequency in timedelta format (day, hour, minutes, seconds)…
Sep 3, 2021
e17d0f5
ADD documentation for new alert_frequency functionnality
Sep 14, 2021
d2385b1
resolve alert_fequency notification issue
Oct 3, 2021
ec97d91
Add try/except in _get_crossover_results because of user-input usage
Oct 19, 2021
c5748aa
fix docker and docker-compose
w1ld3r Feb 26, 2022
753c2f8
update readme with new docke commands
w1ld3r Feb 26, 2022
edcd860
Update feature_request.md
w1ld3r Feb 26, 2022
8084f6a
Send charts with Discord webhooks
incontestableness Mar 19, 2022
6c78df2
remove
w1ld3r Mar 20, 2022
a2ea684
new branch
w1ld3r Mar 20, 2022
35ae822
Merge pull request #56 from incontestableness/discord-charts
w1ld3r Mar 20, 2022
13fb0ee
reformat pull request
w1ld3r Mar 20, 2022
6271c5e
reformat discord notification module
w1ld3r Mar 20, 2022
6ec778b
reformat discord notification module
w1ld3r Mar 20, 2022
9906644
Merge pull request #58 from w1ld3r/reformat_telegram
w1ld3r Mar 20, 2022
348e65b
Merge pull request #57 from w1ld3r/discord_charts
w1ld3r Mar 20, 2022
64011a4
Merge pull request #60 from CryptoSignal/develop
w1ld3r Jun 12, 2022
8ae4739
Add numpy minimum version
w1ld3r Nov 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/defaults.yml
Original file line number Diff line number Diff line change
@@ -36,8 +36,9 @@ notifiers:
webhook: null
optional:
template: "{{exchange}}-{{market}}-{{indicator}}-{{indicator_number}} is {{status}}!{{ '\n' -}}"
gmail:
email:
required:
smtp_server: null
username: null
password: null
destination_emails: null
40 changes: 21 additions & 19 deletions app/notification.py
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@
from analyzers.indicators import candle_recognition, ichimoku
from analyzers.utils import IndicatorUtils
from notifiers.discord_client import DiscordNotifier
from notifiers.gmail_client import GmailNotifier
from notifiers.email_client import EmailNotifier
from notifiers.slack_client import SlackNotifier
from notifiers.stdout_client import StdoutNotifier
from notifiers.telegram_client import TelegramNotifier
@@ -91,15 +91,16 @@ def __init__(self, notifier_config, indicator_config, conditional_config, market
)
enabled_notifiers.append('slack')

self.gmail_configured = self._validate_required_config(
'gmail', notifier_config)
if self.gmail_configured:
self.gmail_client = GmailNotifier(
username=notifier_config['gmail']['required']['username'],
password=notifier_config['gmail']['required']['password'],
destination_addresses=notifier_config['gmail']['required']['destination_emails']
self.email_configured = self._validate_required_config(
'email', notifier_config)
if self.email_configured:
self.email_client = EmailNotifier(
smtp_server=notifier_config['email']['required']['smtp_server'],
username=notifier_config['email']['required']['username'],
password=notifier_config['email']['required']['password'],
destination_addresses=notifier_config['email']['required']['destination_emails']
)
enabled_notifiers.append('gmail')
enabled_notifiers.append('email')

self.telegram_configured = self._validate_required_config(
'telegram', notifier_config)
@@ -223,7 +224,7 @@ def notify_all_messages(self, exchange, market_pair, candle_period, messages):
self.notify_discord(messages)
self.notify_webhook(messages, chart_file)
# self.notify_twilio(new_analysis)
# self.notify_gmail(new_analysis)
self.notify_email(messages)
self.notify_telegram(messages, chart_file)
self.notify_stdout(messages)

@@ -274,20 +275,21 @@ def notify_twilio(self, new_analysis):
if message.strip():
self.twilio_client.notify(message)

def notify_gmail(self, new_analysis):
"""Send a notification via the gmail notifier
def notify_email(self, new_analysis):
"""Send a notification via the email notifier

Args:
new_analysis (dict): The new_analysis to send.
"""
if not self.email_configured:
return

if self.gmail_configured:
message = self._indicator_message_templater(
new_analysis,
self.notifier_config['gmail']['optional']['template']
)
if message.strip():
self.gmail_client.notify(message)
message_template = Template(
self.notifier_config['email']['optional']['template'])

for message in new_analysis:
formatted_message = message_template.render(message)
self.email_client.notify(formatted_message.strip())

def notify_telegram(self, messages, chart_file):
"""Send notifications via the telegram notifier
17 changes: 9 additions & 8 deletions app/notifiers/gmail_client.py → app/notifiers/email_client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Notify a user via Gmail
"""Notify a user via Email
"""

import smtplib
@@ -9,21 +9,22 @@
from notifiers.utils import NotifierUtils


class GmailNotifier(NotifierUtils):
"""Class for handling gmail notifications
class EmailNotifier(NotifierUtils):
"""Class for handling email notifications
"""

def __init__(self, username, password, destination_addresses):
"""Initialize GmailNotifier class
def __init__(self, smtp_server, username, password, destination_addresses):
"""Initialize EmailNotifier class

Args:
username (str): Username of the gmail account to use for sending message.
password (str): Password of the gmail account to use for sending message.
smtp_server (str): Smtp server address in form host:port
username (str): Username of the email account to use for sending message.
password (str): Password of the email account to use for sending message.
destination_addresses (list): A list of email addresses to notify.
"""

self.logger = structlog.get_logger()
self.smtp_server = 'smtp.gmail.com:587'
self.smtp_server = smtp_server
self.username = username
self.password = password
self.destination_addresses = ','.join(destination_addresses)
24 changes: 15 additions & 9 deletions docs/config.md
Original file line number Diff line number Diff line change
@@ -145,34 +145,40 @@ notifiers:
template: "{{exchange}}-{{market}}-{{indicator}}-{{indicator_number}} is {{status}}!{{ '\n' -}}"
```

## Gmail
## Email
**smtp_server**\
default: None\
necessity: required for Email\
description: Your smtp server hostname

**username**\
default: None\
necessity: required for Gmail\
description: Your gmail username which is required for sending emails.
necessity: required for Email\
description: Your email username which is required for sending emails.

**password**\
default: None\
necessity: required for Gmail\
description: Your gmail password which is required for sending emails.
necessity: required for Email\
description: Your email password which is required for sending emails.

**destination_emails**\
default: None\
necessity: required for Gmail\
necessity: required for Email\
description: The email addresses to receive the emails that are sent.

**template**\
default: {{exchange}}-{{market}}-{{analyzer}}-{{analyzer_number}} is {{status}}!{{ '\n' -}}\
necessity: optional\
description: See the notifier templating section.

An example of notifier settings for gmail
An example of notifier settings for email

```yml
notifiers:
gmail:
email:
required:
username: [email protected]
smtp_server: smtp.gmail.com:587
username: [email protected]
password: abcd1234
destination_emails:
- [email protected]