Skip to content

Commit 91084ad

Browse files
authored
Merge pull request #387 from x1n5h3n/develop
Correct Erros && Remove Unnecessary comparaisons && Allow usage of newer versions of python and requirements modules && Allow to define more settings
2 parents 0b05308 + 9e70841 commit 91084ad

File tree

10 files changed

+41
-38
lines changed

10 files changed

+41
-38
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.6-jessie
1+
FROM python:3
22

33
# TA-lib is required by the python TA-lib wrapper. This provides analysis.
44
COPY lib/ta-lib-0.4.0-src.tar.gz /tmp/ta-lib-0.4.0-src.tar.gz
@@ -20,4 +20,4 @@ WORKDIR /app
2020
RUN pip install -r requirements-step-1.txt
2121
RUN pip install -r requirements-step-2.txt
2222

23-
CMD ["/usr/local/bin/python","app.py"]
23+
CMD ["python","app.py"]

app/analyzers/crossover.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ def analyze(self, key_indicator, key_signal, key_indicator_index,
3333
column_indexed_name = '{}_{}'.format(column, key_indicator_index)
3434
new_key_indicator.rename(columns={column: column_indexed_name}, inplace=True)
3535

36+
length = new_key_indicator.shape()
3637
crossed_indicator_name = '{}_{}'.format(crossed_signal, crossed_indicator_index)
37-
new_crossed_indicator = crossed_indicator.copy(deep=True)
38+
new_crossed_indicator = crossed_indicator[:length[1]].copy(deep=True)
3839
for column in new_crossed_indicator:
3940
column_indexed_name = '{}_{}'.format(column, crossed_indicator_index)
4041
new_crossed_indicator.rename(columns={column: column_indexed_name}, inplace=True)

app/analyzers/indicators/ichimoku.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@ def analyze(self, historical_data, tenkansen_period, kijunsen_period, senkou_spa
8888
close_hot = dataframe['close'][date] > ichimoku_values['leading_span_a'][date]
8989
if hot_thresh:
9090
ichimoku_values.at[date,
91-
'is_hot'] = span_hot and close_hot
91+
'is_hot'] = span_hot & close_hot
9292
span_cold = ichimoku_values['leading_span_a'][date] < ichimoku_values['leading_span_b'][date]
9393
close_cold = dataframe['close'][date] < ichimoku_values['leading_span_a'][date]
9494
if cold_thresh:
9595
ichimoku_values.at[date,
96-
'is_cold'] = span_cold and close_cold
96+
'is_cold'] = span_cold & close_cold
9797
else:
9898
pass
9999

app/app.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def main():
4444

4545
for exchange in market_data:
4646
num = 1
47-
for chunk in split_market_data(market_data[exchange]):
47+
for chunk in split_market_data(market_data[exchange], settings['market_data_chunk_size']):
4848
market_data_chunk = dict()
4949
market_data_chunk[exchange] = {
5050
key: market_data[exchange][key] for key in chunk}
@@ -60,7 +60,7 @@ def main():
6060
worker.daemon = True
6161
worker.start()
6262

63-
time.sleep(60)
63+
time.sleep(settings['start_worker_interval'])
6464
num += 1
6565

6666
logger.info('All workers are running!')
@@ -69,9 +69,9 @@ def main():
6969
worker.join()
7070

7171

72-
def split_market_data(market_data):
73-
if len(market_data.keys()) > 20:
74-
return list(chunks(list(market_data.keys()), 20))
72+
def split_market_data(market_data, chunk_size):
73+
if len(market_data.keys()) > chunk_size:
74+
return list(chunks(list(market_data.keys()), chunk_size))
7575
else:
7676
return [list(market_data.keys())]
7777

app/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ def __init__(self):
1616
"""
1717

1818
with open('defaults.yml', 'r') as config_file:
19-
default_config = yaml.load(config_file)
19+
default_config = yaml.load(config_file, Loader=yaml.FullLoader)
2020

2121
if os.path.isfile('config.yml'):
2222
with open('config.yml', 'r') as config_file:
23-
user_config = yaml.load(config_file)
23+
user_config = yaml.load(config_file, Loader=yaml.FullLoader)
2424
else:
2525
user_config = dict()
2626

app/defaults.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ settings:
88
enable_charts: false
99
output_mode: cli
1010
update_interval: 300
11+
start_worker_interval: 60
12+
market_data_chunk_size: 20
1113
market_pairs: null
1214
timezone: UTC
1315

app/notification.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def notify_all(self, new_analysis):
138138

139139
messages = self.get_indicator_messages(new_analysis)
140140

141-
if self.enable_charts == True:
141+
if self.enable_charts:
142142
if not os.path.exists(charts_dir):
143143
os.mkdir(charts_dir)
144144

@@ -158,7 +158,7 @@ def notify_all(self, new_analysis):
158158
def notify_all_messages(self, exchange, market_pair, candle_period, messages):
159159
chart_file = None
160160

161-
if self.enable_charts == True:
161+
if self.enable_charts:
162162
try:
163163
candles_data = self.all_historical_data[exchange][market_pair][candle_period]
164164
chart_file = self.create_chart(
@@ -258,8 +258,8 @@ def notify_telegram(self, messages, chart_file):
258258
for message in messages:
259259
formatted_messages.append(message_template.render(message))
260260

261-
if self.enable_charts == True:
262-
if chart_file != None and os.path.exists(chart_file):
261+
if self.enable_charts:
262+
if chart_file and os.path.exists(chart_file):
263263
try:
264264
self.telegram_client.send_chart_messages(
265265
open(chart_file, 'rb'), formatted_messages)
@@ -644,7 +644,7 @@ def get_indicator_messages(self, new_analysis):
644644
# Merge changes from new analysis into last analysis
645645
self.last_analysis = {**self.last_analysis, **new_analysis}
646646

647-
if self.first_run == True:
647+
if self.first_run:
648648
self.first_run = False
649649

650650
return new_messages

app/notifiers/webhook_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def notify(self, messages, chart_file):
3232

3333
data = {'messages': json.dumps(messages)}
3434

35-
if chart_file != None and os.path.exists(chart_file):
35+
if chart_file and os.path.exists(chart_file):
3636
files = {'chart': open(chart_file, 'rb')}
3737

3838
if self.username and self.password:

app/requirements-step-1.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
numpy==1.14.0
2-
Cython==0.28.2
1+
numpy>=1.14.0
2+
Cython>=0.28.2

app/requirements-step-2.txt

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
twilio==6.6.3
2-
ccxt==1.25.40
3-
structlog==17.2.0
4-
python-json-logger==0.1.8
5-
pandas==0.22.0
6-
stockstats==0.2.0
7-
TA-lib==0.4.17
8-
tabulate==0.8.2
9-
slackweb==1.0.5
10-
tenacity==4.8.0
11-
python-telegram-bot==10.0.1
12-
webcord==0.2
13-
jinja2==2.10
14-
requests==2.20.0
15-
PyYAML==3.12
16-
tulipy==0.2.1
17-
matplotlib==3.0.1
18-
scipy==1.1.0
1+
twilio>=6.6.3
2+
ccxt>=1.25.40
3+
structlog>=17.2.0
4+
python-json-logger>=0.1.8
5+
pandas>=0.22.0
6+
stockstats>=0.2.0
7+
TA-lib>=0.4.17
8+
tabulate>=0.8.2
9+
slackweb>=1.0.5
10+
tenacity>=4.8.0
11+
python-telegram-bot>=10.0.1
12+
webcord>=0.2
13+
jinja2>=2.10
14+
requests>=2.20.0
15+
PyYAML>=3.12
16+
tulipy>=0.2.1
17+
matplotlib>=3.0.1
18+
scipy>=1.1.0

0 commit comments

Comments
 (0)