-
Notifications
You must be signed in to change notification settings - Fork 0
/
ctbot_helpers.py
159 lines (119 loc) · 4.78 KB
/
ctbot_helpers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
'''
Helper functions moved here to clean up main script and increase readability
'''
from keys import SMTP_SERVER, SMTP_PORT, SMTP_USERNAME, SMTP_PASSWORD, EMAIL_TO, EMAIL_FROM
from email.mime.text import MIMEText
import datetime, time
import smtplib
def send_email(subject, message):
date_string = datetime.datetime.utcfromtimestamp(time.time()).strftime('%Y-%m-%d %H:%M:%S')
msg = MIMEText(message)
msg['Subject'] = "{} {}".format(subject, date_string)
msg['To'] = ", ".join(EMAIL_TO)
msg['From'] = EMAIL_FROM
mail = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)
mail.starttls()
mail.login(SMTP_USERNAME, SMTP_PASSWORD)
mail.sendmail(EMAIL_FROM, EMAIL_TO, msg.as_string())
mail.quit()
def init_variables():
variables = {
#Live toggle
'live': False,
#Currency pair
'pair': '',
# Periods used. All available on Poloniex except 24h
# 5m, 15m, 30m, 2h, 4h
'periods': [300, 900, 1800, 7200, 14400],
# Each period has its own variables
300: {
'all_candles': list(),
'len_candles': 0,
'all_dates': list(),
'all_close_prices': list(),
'all_rsi': list(),
'all_rsi_d': list(),
'all_rsi_u': list(),
'all_macd': list(),
'all_macd_signal': list(),
'all_macd_hist': list(),
'all_bollinger': list(),
'all_score': list(),
'all_rsi_score': list(),
'all_macd_score': list()
},
900: {
'all_candles': list(),
'len_candles': 0,
'all_dates': list(),
'all_close_prices': list(),
'all_rsi': list(),
'all_rsi_d': list(),
'all_rsi_u': list(),
'all_macd': list(),
'all_macd_signal': list(),
'all_macd_hist': list(),
'all_bollinger': list(),
'all_score': list(),
'all_rsi_score': list(),
'all_macd_score': list()
},
1800: {
'all_candles': list(),
'len_candles': 0,
'all_dates': list(),
'all_close_prices': list(),
'all_rsi': list(),
'all_rsi_d': list(),
'all_rsi_u': list(),
'all_macd': list(),
'all_macd_signal': list(),
'all_macd_hist': list(),
'all_bollinger': list(),
'all_score': list(),
'all_rsi_score': list(),
'all_macd_score': list()
},
7200: {
'all_candles': list(),
'len_candles': 0,
'all_dates': list(),
'all_close_prices': list(),
'all_rsi': list(),
'all_rsi_d': list(),
'all_rsi_u': list(),
'all_macd': list(),
'all_macd_signal': list(),
'all_macd_hist': list(),
'all_bollinger': list(),
'all_score': list(),
'all_rsi_score': list(),
'all_macd_score': list()
},
14400: {
'all_candles': list(),
'len_candles': 0,
'all_dates': list(),
'all_close_prices': list(),
'all_rsi': list(),
'all_rsi_d': list(),
'all_rsi_u': list(),
'all_macd': list(),
'all_macd_signal': list(),
'all_macd_hist': list(),
'all_bollinger': list(),
'all_score': list(),
'all_rsi_score': list(),
'all_macd_score': list()
},
#Starting with 1 coin and 0 USDT
'coins': 1,
'usdt': 0,
#Trade details
'active_trade': False,
'active_trade_price': 0,
'current_trade_details': dict(),
'plot_buys': list(),
'plot_sells': list(),
}
return variables