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
Show file tree
Hide file tree
Changes from all 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
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
title: "[BUG]"
labels: ''
assignees: w1ld3r

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. git clone '...'
2. docker build -t dev/crypto-signals:latest .
3. docker run '....'
4. Error

**Expected behavior**
A clear and concise description of what you expected to happen.

**config.yml**
```yml
settings:
log_level: INFO
[...]
```

**Machine**
- OS name and version
- crypto-signal branch
- Docker version

**Additional context**
Add any other context about the problem here.
For example if any modification of the code as been made

19 changes: 19 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: Feature request
about: Suggest an idea for this project
title: "[FEATURE] ..."
labels: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
10 changes: 4 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.8-buster
FROM python:latest

# TA-lib is required by the python TA-lib wrapper. This provides analysis.
COPY lib/ta-lib-0.4.0-src.tar.gz /tmp/ta-lib-0.4.0-src.tar.gz
Expand All @@ -10,13 +10,11 @@ RUN cd /tmp && \
make && \
make install

ADD app/requirements-step-1.txt /app/requirements-step-1.txt
ADD app/requirements-step-2.txt /app/requirements-step-2.txt
COPY ./app /app

WORKDIR /app

# Pip doesn't install requirements sequentially.
# To ensure pre-reqs are installed in the correct
# order they have been split into two files
RUN pip install --upgrade pip
RUN pip install -r requirements-step-1.txt
RUN pip install -r requirements-step-2.txt

Expand Down
32 changes: 19 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,19 @@ Development branch to testing new features. This develop version has a lot of im


## Installing And Running
Because this is a development branch you need to build your custom Docker image. The commands listed below are intended to be run in a terminal.
The commands listed below are intended to be run in a terminal.

Be sure you have git installed in your system.

1. Clone this repo `git clone https://github.com/CryptoSignal/crypto-signal.git`
1. Clone this repo `git clone https://github.com/w1ld3r/crypto-signal.git`

1. Enter to cripto-signal folder `cd crypto-signal`

1. Switch to develop branch `git checkout develop`

1. Create a config.yml file and put it into "app" folder.

1. Build your own Docker image, for example, `docker build -t dev/crypto-signals:latest .`

1. For testing and debugging run docker with "-t" option `docker run --rm -ti -v $PWD/app:/app dev/crypto-signals:latest`

1. For production run in daemon mode using "-d" option `docker run --rm -di -v $PWD/app:/app dev/crypto-signals:latest`
1. Build and run the docker container: `docker-compose up --build`


### Configuring config.yml
Expand Down Expand Up @@ -125,7 +121,7 @@ exchanges:

#### Show me the price!

If you want prices in your notification messages, you can use the "prices" variable.
If you want prices in your notification messages, you can use the "prices" variable or "price_value".

```
notifiers:
Expand All @@ -138,6 +134,17 @@ notifiers:
template: "[{{analysis.config.candle_period}}] {{market}} {{values}} Prices: [{{prices}}]"
```

```
notifiers:
telegram:
required:
token: 791615820:AAGFgGSumWUrb-CyXtGxzAuYaabababababababa
chat_id: 687950000
optional:
parse_mode: html
template: "[{{analysis.config.candle_period}}] {{market}} {{values}} Price 15m low: [{{price_value['15m'].low}}]"
```

By the way, to have this feature you need to configure "ohlcv" informant for each candle period of your indicators.

```
Expand Down Expand Up @@ -723,8 +730,7 @@ informants:
- low
- close
candle_period: 4h
period_count: 14

period_count: 14
```

Then you can use the "price_value" variable to have the values of prices and be able to do some operations on them.
Expand All @@ -738,9 +744,9 @@ notifiers:
optional:
parse_mode: html
template: "{{ market }}
BUY {{ price_value.close }}
SL: {{ decimal_format|format(price_value.low * 0.9) }}
TP: {{ decimal_format|format(price_value.close * 1.02) }} {{ decimal_format|format(price_value.close * 1.04) }} "
BUY {{ price_value['1h'].close }}
SL: {{ decimal_format|format(price_value['4h'].low * 0.9) }}
TP: {{ decimal_format|format(price_value['1h'].close * 1.02) }} {{ decimal_format|format(price_value['4h'].close * 1.04) }} "
```

The code for "decimal_format" and "format" is necessary to obtain the prices formatted with the corresponding zeros.
6 changes: 3 additions & 3 deletions app/analyzers/indicators/ichimoku.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ def analyze(self, historical_data, tenkansen_period, kijunsen_period, senkou_spa
last_time = dataframe.index[-1]
timedelta = dataframe.index[1] - dataframe.index[0]
newindex = pandas.date_range(last_time + timedelta,
freq=timedelta,
periods=cloud_displacement)
freq=timedelta,
periods=cloud_displacement)
ichimoku_values = ichimoku_values.append(
pandas.DataFrame(index=newindex))
# cloud offset
Expand Down Expand Up @@ -133,4 +133,4 @@ def analyze(self, historical_data, tenkansen_period, kijunsen_period, senkou_spa
except Exception as e:
print('Error running ichimoku analysis: {}'.format(e))

return ichimoku_values
return ichimoku_values
2 changes: 1 addition & 1 deletion app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def main():
key: market_data[exchange][key] for key in chunk}

notifier = Notifier(
config.notifiers, config.indicators, market_data_chunk)
config.notifiers, config.indicators, config.conditionals, market_data_chunk)
behaviour = Behaviour(config, exchange_interface, notifier)

workerName = "Worker-{}".format(num)
Expand Down
36 changes: 19 additions & 17 deletions app/behaviour.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,23 +347,25 @@ def _get_crossover_results(self, new_result):
if not crossover_conf['enabled']:
self.logger.debug("%s is disabled, skipping.", crossover)
continue

key_indicator = new_result[crossover_conf['key_indicator_type']
][crossover_conf['key_indicator']][crossover_conf['key_indicator_index']]
crossed_indicator = new_result[crossover_conf['crossed_indicator_type']
][crossover_conf['crossed_indicator']][crossover_conf['crossed_indicator_index']]

crossover_conf['candle_period'] = crossover_conf['key_indicator'] + \
str(crossover_conf['key_indicator_index'])

dispatcher_args = {
'key_indicator': key_indicator['result'],
'key_signal': crossover_conf['key_signal'],
'key_indicator_index': crossover_conf['key_indicator_index'],
'crossed_indicator': crossed_indicator['result'],
'crossed_signal': crossover_conf['crossed_signal'],
'crossed_indicator_index': crossover_conf['crossed_indicator_index']
}
try:
key_indicator = new_result[crossover_conf['key_indicator_type']][crossover_conf['key_indicator']][crossover_conf['key_indicator_index']]
crossed_indicator = new_result[crossover_conf['crossed_indicator_type']][crossover_conf['crossed_indicator']][crossover_conf['crossed_indicator_index']]

crossover_conf['candle_period'] = crossover_conf['key_indicator'] + \
str(crossover_conf['key_indicator_index'])

dispatcher_args = {
'key_indicator': key_indicator['result'],
'key_signal': crossover_conf['key_signal'],
'key_indicator_index': crossover_conf['key_indicator_index'],
'crossed_indicator': crossed_indicator['result'],
'crossed_signal': crossover_conf['crossed_signal'],
'crossed_indicator_index': crossover_conf['crossed_indicator_index']
}
except Exception as e:
self.logger.warning(e)
self.logger.warning(traceback.format_exc())
continue

results[crossover].append({
'result': crossover_dispatcher[crossover](**dispatcher_args),
Expand Down
5 changes: 5 additions & 0 deletions app/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ def __init__(self):
self.exchanges = user_config['exchanges']
else:
self.exchanges = dict()

if 'conditionals' in user_config:
self.conditionals = user_config['conditionals']
else:
self.conditionals = None

for exchange in ccxt.exchanges:
if exchange not in self.exchanges:
Expand Down
3 changes: 2 additions & 1 deletion app/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions app/exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ def __init__(self, exchange_config):
# Loads the exchanges using ccxt.
for exchange in exchange_config:
if exchange_config[exchange]['required']['enabled']:
new_exchange = getattr(ccxt, exchange)({
"enableRateLimit": True
})
parameters = {'enableRateLimit': True}
if 'future' in exchange_config[exchange].keys():
if exchange_config[exchange]['future'] == True:
parameters['options'] = {'defaultType': 'future'}
new_exchange = getattr(ccxt, exchange)(parameters)

# sets up api permissions for user if given
if new_exchange:
Expand Down
Loading