-
Notifications
You must be signed in to change notification settings - Fork 2
/
dl_validation.py
65 lines (45 loc) · 1.33 KB
/
dl_validation.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
# To make print working for Python2/3
from __future__ import print_function
import datetime
import glob
import stock_db_mgr as sdm
startdate = datetime.date(2021, 1, 1)
today = datetime.date.today()
# Pick one:
# enddate = datetime.date(2018, 2, 22)
enddate = today
def list_all_stockdb():
txt_list = glob.glob('stock_db/*.txt')
return [i.replace('.txt', '').replace('stock_db/', '') for i in txt_list]
def check_db(path):
print("Validating {} ...".format(path))
# Create data base:
db = sdm.StockDBMgr('./stock_db/' + path, startdate, enddate)
# db.update_all_symbols()
inv = []
symbol_list = db.get_all_symbols()
# print(symbol_list)
for s in symbol_list:
if not db.validate_symbol_data(s):
inv.append(s)
continue
df = db.get_symbol_data(s)
t = startdate
if df is not None and len(df) > 0:
t = df.iloc[-1].name.date()
else:
inv.append(s)
continue
if (today - t) > datetime.timedelta(4):
inv.append(s)
# print("%s: len = %d" % (s, len(df)))
if len(inv) > 0:
print(" Invalid list:")
for s in inv:
print(" " + s)
def _main():
db = list_all_stockdb()
for p in db:
check_db(p)
if __name__ == '__main__':
_main()