darylfunggg commited on
Commit
275785a
·
1 Parent(s): 0bfe7d4

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +8 -10
main.py CHANGED
@@ -15,7 +15,7 @@ all_processes = {}
15
  #
16
  # @bot.message_handler(commands=['showid'])
17
  # def start_message(message):
18
- # bot.send_message(message.chat.id, message.chat.id)
19
  # bot.infinity_polling()
20
 
21
  def get_data(symbol, exchange, interval):
@@ -107,13 +107,13 @@ def push_notification(symbol, exchange, interval):
107
  long_risk = check_risk(symbol, exchange, 'long')
108
 
109
  if table[-1, 1]:
110
- bot.send_message(os.getenv('TELEGRAM_CHAT_ID'), f'LONG now ({long_risk}): {symbol} {exchange} {interval}')
111
 
112
  # send short buy message
113
  table = get_buy_short_indicator(data)
114
  short_risk = check_risk(symbol, exchange, 'short')
115
  if table[-1, 1]:
116
- bot.send_message(os.getenv('TELEGRAM_CHAT_ID'), f'SHORT now ({short_risk}): {symbol} {exchange} {interval}')
117
 
118
  if 'H' in interval:
119
  time.sleep(3600)
@@ -196,14 +196,12 @@ def startpolling(exchange, symbol, interval):
196
  if all_processes.get(f'{symbol}_{exchange}_{interval}', None) is not None:
197
  return False
198
 
199
- all_processes[f'{symbol}_{exchange}_{interval}'] = {'process_stop': False, 'process': None}
200
- selected_process = all_processes[f'{symbol}_{exchange}_{interval}']
201
 
202
- bot.send_message(os.getenv('TELEGRAM_CHAT_ID'), f'STARTING BOT FOR: {symbol} {exchange} {interval}')
203
 
204
  process = multiprocessing.Process(target=push_notification, args=(symbol, exchange, interval))
205
  process.start()
206
- selected_process['process'] = process
207
  return True
208
 
209
 
@@ -216,10 +214,10 @@ def endpolling(exchange, symbol, interval):
216
  selected_process = all_processes[f'{symbol}_{exchange}_{interval}']
217
  selected_process['process_stop'] = True
218
 
219
- bot.send_message(os.getenv('TELEGRAM_CHAT_ID'), f'STOPPING BOT FOR: {symbol} {exchange} {interval}')
220
  selected_process['process'].terminate()
221
  all_processes.pop(f'{symbol}_{exchange}_{interval}')
222
- bot.send_message(os.getenv('TELEGRAM_CHAT_ID'), f'BOT STOPPED FOR: {symbol} {exchange} {interval}')
223
 
224
  return True
225
 
@@ -234,7 +232,7 @@ def end_all_processes():
234
 
235
  all_processes = {}
236
 
237
- bot.send_message(os.getenv('TELEGRAM_CHAT_ID'), f'ALL NOTIFICATIONS ENDED')
238
 
239
  return True
240
 
 
15
  #
16
  # @bot.message_handler(commands=['showid'])
17
  # def start_message(message):
18
+ # bot.send_message(message.chat.id, message.chat.id, timeout=20)
19
  # bot.infinity_polling()
20
 
21
  def get_data(symbol, exchange, interval):
 
107
  long_risk = check_risk(symbol, exchange, 'long')
108
 
109
  if table[-1, 1]:
110
+ bot.send_message(os.getenv('TELEGRAM_CHAT_ID'), f'LONG now ({long_risk}): {symbol} {exchange} {interval}', timeout=20)
111
 
112
  # send short buy message
113
  table = get_buy_short_indicator(data)
114
  short_risk = check_risk(symbol, exchange, 'short')
115
  if table[-1, 1]:
116
+ bot.send_message(os.getenv('TELEGRAM_CHAT_ID'), f'SHORT now ({short_risk}): {symbol} {exchange} {interval}', timeout=20)
117
 
118
  if 'H' in interval:
119
  time.sleep(3600)
 
196
  if all_processes.get(f'{symbol}_{exchange}_{interval}', None) is not None:
197
  return False
198
 
 
 
199
 
200
+ bot.send_message(os.getenv('TELEGRAM_CHAT_ID'), f'STARTING BOT FOR: {symbol} {exchange} {interval}', timeout=20)
201
 
202
  process = multiprocessing.Process(target=push_notification, args=(symbol, exchange, interval))
203
  process.start()
204
+ all_processes[f'{symbol}_{exchange}_{interval}'] = {'process_stop': False, 'process': process}
205
  return True
206
 
207
 
 
214
  selected_process = all_processes[f'{symbol}_{exchange}_{interval}']
215
  selected_process['process_stop'] = True
216
 
217
+ bot.send_message(os.getenv('TELEGRAM_CHAT_ID'), f'STOPPING BOT FOR: {symbol} {exchange} {interval}', timeout=20)
218
  selected_process['process'].terminate()
219
  all_processes.pop(f'{symbol}_{exchange}_{interval}')
220
+ bot.send_message(os.getenv('TELEGRAM_CHAT_ID'), f'BOT STOPPED FOR: {symbol} {exchange} {interval}', timeout=20)
221
 
222
  return True
223
 
 
232
 
233
  all_processes = {}
234
 
235
+ bot.send_message(os.getenv('TELEGRAM_CHAT_ID'), f'ALL NOTIFICATIONS ENDED', timeout=20)
236
 
237
  return True
238