This repository has been archived by the owner on Jul 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
92 lines (71 loc) · 1.81 KB
/
main.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
import database as db
import thread
import em
import sell
import req
import sys
import datetime
import oss
import time
def listen():
while True:
time.sleep(0.002)
raw_data = (em.read("[email protected]","password"))
if "," in raw_data:
raw_data = raw_data.split(",")
for i in raw_data:
if "sold" in raw_data:
db.removeQue(raw_data[0])
db.removePrice(raw_data[0])
break
data = []
for i in raw_data:
i = i.replace("\n","")
i = i.replace("\r","")
data.append(i)
item = data
isPresent = False
for i in db.loadPrices():
if item[0] in i:
isPresent = True
for i in db.loadQue():
if item[0] in i:
isPresent = True
if not isPresent:
db.insertPrice(item[0],item[1])
def check():
time.sleep(0.001)
while True:
for i in db.loadPrices():
symbol = i.split(",")[0]
now = datetime.datetime.now()
price = i.split(",")[1]
if sell.shouldSell(float(price),float(req.priceRequest(symbol))):
em.send("[email protected]","password","toAddres",("Should sell %s" % (symbol)))
db.removePrice(symbol)
db.insertQue(symbol,price,now.hour)
def que():
time.sleep(1)
while True:
#check if day in que is not equal to today date if so add it to boughts
data = db.loadQue()
for i in data:
past_time = i.split(",")[-1]
if not (str(past_time) == str(datetime.datetime.now().hour)):
db.insertPrice(i.split(",")[0],i.split(",")[1])
if __name__ == "__main__":
print("[+] Stock Advice Bot Running")
if not (os.path.exists("stock.db")):
print("[-] No Database Detected")
print("[+] Creating New Database")
db.createDatabase()
thread.start_new_thread(listen,())
thread.start_new_thread(check,())
thread.start_new_thread(que(),())
try:
print("<CTRL-C>")
while True:
pass
except KeyboardInterrupt:
print
print("[-] Exiting")