File size: 1,292 Bytes
919ec8d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import threading
from config import *
import requests
import slack
import json
from datetime import datetime
import time
arr = []
def symbol_info(req_params, i):
    global arr
    url = "https://api.binance.com/api/v3/ticker/24hr"
    val = requests.get(url,params = req_params)
    try:
        data = json.loads(val.text)
        
        x = arr[i]
        try:
            if float(data["priceChangePercent"])>=x:
                client = slack.WebClient(token = SLACK_TOKEN)
                client.chat_postMessage(channel = "#bot_alerts", 
                        text = f"{datetime.now().strftime('%Y-%m-%d %H:%M:%S')} {data['symbol']} 24Hchange={float(data['priceChangePercent'])}% new benchmark {x+5}%")
                arr[i] = arr[i] + 5
        except:
            pass
    except:
        print("Could not connect")

for i in range(len(crypto_symbols)):
    arr.append(20)

while True:
    for i in range(len(crypto_symbols)):
        today = datetime.now()
        if today.hour + today.minute + today.second == 0:
            for i in range(len(crypto_symbols)):
                arr[i] = 20
        req_params = dict(symbol = crypto_symbols[i] + "USDT")
        thread = threading.Thread(target = symbol_info, args = (req_params,i,))
        thread.start()
    time.sleep(15)