-
Notifications
You must be signed in to change notification settings - Fork 21
/
start.py
executable file
·84 lines (63 loc) · 2.02 KB
/
start.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
#
# exec script
import os
import sys
import signal
import threading,time
import queue
code = '600600'
def handler(signum, frame):
print("是不是想让我退出啊")
sys.exit()
def macd(code,name):
os.system('rm -f ./datas/ts_' + code+'.csv')
y1 = os.system('python3 ts_to_csv.py --code '+code+' --start 2019-10-01')
y2 = os.system('python3 btrmacd.py --datafile ./datas/ts_'+code+'.csv' + ' --code ' + code
+' --name ' + name + ' --savedb 1')
def mrk(code,name):
y1 = os.system('python3 btrmrk.py --datafile ./datas/ts_'+code+'.csv' + ' --code ' + code
+' --name ' + name + ' --savedb 1')
if y1 == 2: #ctrl+c
print(y1)
sys.exit()
def atr(code,name):
y1 = os.system('python3 btratr.py --datafile ./datas/ts_'+code+'.csv' + ' --code ' + code
+' --name ' + name + ' --savedb 1')
if y1 == 2: #ctrl+c
print(y1)
sys.exit()
def get_code_cvs(code):
os.system('rm -f ./datas/ts_' + code+'.csv')
y1 = os.system('python3 ts_to_csv.py --code '+code+' --start 2019-10-01')
if y1 == 2 : #ctrl+c
print(y1)
sys.exit()
def getstockinfo(stock):
#2019-12-09,sz.002094,青岛金王,化工,申万一级行业
# 时间,股票代码,名称,类别
d,code,name,skip1,skip2 = stock.split(',')
code = code.split('.')[1]
return code,name
def get_data_thread(n):
for stock in stocklist:
code ,name = getstockinfo(stock)
print('正在获取',name,'代码',code)
get_code_cvs(code)
q.put((code,name))
q.task_done()
signal.signal(signal.SIGINT, handler)
signal.signal(signal.SIGHUP, handler)
signal.signal(signal.SIGTERM, handler)
q = queue.Queue()
if len(sys.argv) > 1:
code = sys.argv[1]
if not os.path.exists('./datas/stock_industry_check.csv'):
print('正在下载股票库列表....')
os.system('python3 bs_get_industry_check.py')
stocklist = open('./datas/stock_industry_check.csv').readlines()
stocklist = stocklist[1:] #删除第一行
threading.Thread(target=get_data_thread,args=(1,)).start()
while True:
code,name = q.get()
print('正在分析',name,'代码',code)
atr(code,name)