Administrator
2023-04-21 0ed2c53acd278d57a39390fd4db78c5aaf088e0a
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
import json
 
 
def parse_kpl_datas(results):
    start_y = -1
    end_x = -1
    index = 0
    datas = []
    for result in results:
        text = result[1]
        if text.find("股票名称") > -1:
            start_y = result[0][0][1]
 
        if text.find("竞价涨幅") > -1:
            end_x = result[0][0][0]
        if start_y > 0 and end_x > 0:
            if result[0][0][0] < end_x and result[0][0][1] > start_y and (result[0][1][0] - result[0][0][0]) > 30:
                datas.append(text)
                index += 1
    datas = datas[:3 * 5]
    fdatas = []
    temp = []
    for data in datas:
        temp.append(data)
        if len(temp) == 3:
            fdatas.append((temp[2][:6], temp[1]))
            temp = []
    return fdatas
 
 
# 涨停代码:
# (代码,名称,首次涨停时间,最近涨停时间,几板,涨停原因,板块,实际流通,主力净额)
# (0,1,6,25,9,16,11,15,12)
# 竞价代码:
# (代码,名称,涨停委买额,板块,竞价成交额,实际流通)
# (0,1,18,11,22,15)
# 炸板:
# (代码,名称,涨幅,板块,实际流通)
# (0,1,4,11,15)
# 跌停:
# (代码,名称,板块,实际流通)
# (0,1,11,15)
# 曾跌停:
# (代码,名称,涨幅,板块,实际流通)
# (0,1,4,11,15)
 
TYPE_BIDDING = 8
TYPE_LIMIT_UP = 1
TYPE_OPEN_LIMIT_UP = 2
TYPE_LIMIT_DOWN = 3
TYPE_EVER_LIMIT_DOWN = 5
 
 
def __parseItemData(data, type):
    if type == TYPE_BIDDING:
        return data[0], data[1], data[18], data[11], data[22], data[15]
    elif type == TYPE_LIMIT_UP:
        return data[0], data[1], data[6], data[25], data[9], data[16], data[11], data[15], data[12]
    elif type == TYPE_OPEN_LIMIT_UP:
        return data[0], data[1], data[4], data[11], data[15]
    elif type == TYPE_LIMIT_DOWN:
        return data[0], data[1], data[11], data[15]
    elif type == TYPE_EVER_LIMIT_DOWN:
        return data[0], data[1], data[4], data[11], data[15]
 
    return None
 
 
def parseData(data, type):
    data = json.loads(data)
    if data["errcode"] != 0:
        raise Exception(f"解析数据出错,errcode:{data['errcode']}")
    list_ = data["list"]
    fresult_ = []
    for d in list_:
        pdata = __parseItemData(d, type)
        if pdata:
            fresult_ .append(pdata)
    return fresult_