admin
2023-04-28 c082b525b5e501dfa24038e3a85e444d88bfb1d0
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
 
import json
import random
 
import xlwt
 
# k_form=(15个交易日是否涨幅24.9%,是否破前高,是否超跌,是否接近前高,是否N)
# code_nature = (是否有涨停,是否有溢价)
# hot_block(板块中涨停票个数(包含自己),板块炸板票个数)
# zyltgb自由流通市值是否大于250亿
# limit_price 涨停价是否大于100块
# limit_up_time 是否10点之前涨停
def getscore(bidding_money, big_money, volume, k_form, code_nature, hot_block, zyltgb, limit_price, limit_up_time):
    score = 0
    score_list = []
    # 开盘前竞价
    if bidding_money:
        score += 200
        score_list.append(200)
    else:
        score_list.append(0)
    # 大单成交
    if big_money:
        score += 150
        score_list.append(150)
    else:
        score_list.append(0)
    # 量
    volume_score = [0, 200, 250, 200, 150, 100, -500, -1000]
    score += volume_score[volume]
    score_list.append(volume_score[volume])
 
    # 15个交易日是否涨幅24.9%
    if k_form[0]:
        score += -1000
        score_list.append(-1000)
    else:
        score_list.append(0)
    # 是否破前高
    if k_form[1]:
        score += 150
        score_list.append(150)
    else:
        score_list.append(0)
    # 是否超跌
    if k_form[2]:
        score += 170
        score_list.append(170)
    else:
        score_list.append(0)
 
    # 是否接近前高
    if k_form[3]:
        score += -1000
        score_list.append(-1000)
    else:
        score_list.append(0)
    # 是否N
    if k_form[4]:
        score += 160
        score_list.append(160)
    else:
        score_list.append(0)
 
    if not code_nature[0]:
        score += 50
        score_list.append(50)
    else:
        score_list.append(0)
    if code_nature[1]:
        score += 100
        score_list.append(100)
    else:
        score_list.append(0)
 
    if hot_block[0] >= 2:
        score += 200
        score_list.append(200)
    else:
        score += 150
        score_list.append(150)
    if hot_block[1] > 0:
        score += 50
        score_list.append(50)
    else:
        score_list.append(0)
 
    if zyltgb:
        score += -500
        score_list.append(-500)
    else:
        score_list.append(0)
 
    if limit_price:
        score += -1000
        score_list.append(-1000)
    else:
        score_list.append(0)
 
    if limit_up_time:
        score += 150
        score_list.append(150)
    else:
        score_list.append(0)
 
    return score, score_list
 
 
if __name__ == "__main__":
    bidding_money = [True, False]
    bidding_money_desc = ["Y", "N"]
    big_money = [True, False]
    big_money_desc = ["Y", "N"]
    volume = [0, 1, 2, 3, 4, 5, 6, 7]
    volume_desc = ["换手量<49.9%。", "64.9%>换手量≥49.9%。", "79.9%>换手量≥64.9%。", "94.9%>换手量≥79.9%。", "109.9%>换手量≥94.9%。",
                   "124.9%>换手量≥109.9%。", "139.9%>换手量≥124.9%。", "换手量≥139.9%。"]
    k_form = []
    k_form_str = []
    for i in range(0, 5):
        k_form.append([True, False])
        k_form_str.append(["Y", "N"])
 
    code_nature = []
    code_nature_str = []
    for i in range(0, 2):
        code_nature.append([True, False])
        code_nature_str.append(["Y", "N"])
 
    hot_block = []
    hot_block.append([1, 2])
    hot_block.append([0, 1])
 
    zyltgb = [True, False]
    limit_price = [True, False]
    limit_up_time = [True, False]
 
    total_count = 0
 
    params = {}
    for i0 in range(0, len(bidding_money)):
        for i1 in range(0, len(big_money)):
            for i2 in range(0, len(volume)):
                for i3 in range(0, len(k_form)):
                    ks = []
                    for i in range(0, len(k_form)):
                        ks.append(0)
                    for n in range(0, 2):
                        ks[0] = k_form[0][n]
                        for n1 in range(0, 2):
                            ks[1] = k_form[1][n1]
                            for n2 in range(0, 2):
                                ks[2] = k_form[2][n2]
                                for n3 in range(0, 2):
                                    ks[3] = k_form[3][n3]
                                    for n4 in range(0, 2):
                                        ks[4] = k_form[4][n4]
                                        cns = []
                                        for i in range(0, len(code_nature)):
                                            cns.append(0)
                                        for j in range(0, 2):
                                            cns[0] = code_nature[0][j]
                                            for j1 in range(0, 2):
                                                cns[1] = code_nature[1][j1]
                                                hbs = []
                                                for i in range(0, len(hot_block)):
                                                    hbs.append(0)
                                                for h in range(0, 2):
                                                    hbs[0] = hot_block[0][h]
                                                    for h1 in range(0, 2):
                                                        hbs[1] = hot_block[1][h1]
                                                        for i10 in range(0, len(zyltgb)):
                                                            for i11 in range(0, len(limit_price)):
                                                                for i12 in range(0, len(limit_up_time)):
                                                                    param = (bidding_money[i0], big_money[i1],
                                                                             volume[i2], ks, cns, hbs,
                                                                             zyltgb[i10], limit_price[i11],
                                                                             limit_up_time[i12])
 
                                                                    score, score_list = getscore(bidding_money[i0],
                                                                                                 big_money[i1],
                                                                                                 volume[i2], ks, cns,
                                                                                                 hbs,
                                                                                                 zyltgb[i10],
                                                                                                 limit_price[i11],
                                                                                                 limit_up_time[i12])
                                                                    params[json.dumps(param)] = (score, score_list)
 
    titles = ["竞价强度", "资金力度", "换手量能", ["K线-涨幅24.9%", "K线-是否破前高", "K线-是否超跌", "K线-是否接近前高", "K线-是否N"],
              ["股性-无涨停", "股性-有溢价"],
              ["板块-涨停票数", "板块-炸板票数"], "股价>100", "自由流通市值>250亿", "10点前涨停", "得分"]
 
    # 写入excel
    datas = []
    for key in params:
        param = json.loads(key)
        score = params[key]
        # 15个交易日是否涨幅24.9 %, 是否破前高,是否超跌,是否接近前高,是否N
        if param[3][1:2] == [True, True]:
            continue
        if param[3][1] == True and param[3][3] == True:
            continue
        if param[4][0] == True and param[4][1] == True:
            continue
        datas.append((param, score))
 
    print("数量", len(datas))
 
    random.shuffle(datas)
    datas = datas[:1000]
 
    if True:
        print("总数", len(datas))
 
        file_name = "D:/test__.xls"
        wb = xlwt.Workbook()
        ws = wb.add_sheet('sheet1')
        ws.write(0, 0, '序号')
        index = 1
        for title in titles:
            if type(title) != str:
                for t in title:
                    ws.write(0, index, t)
                    index += 1
            else:
                ws.write(0, index, title)
                index += 1
 
        index = 0
        for data in datas:
            index += 1
            col = 1
            ws.write(index, 0, index)
            for d in data[0]:
                col_data = ""
                if type(d) == list:
                    for dd in d:
                        if type(dd) == bool:
                            col_data = "Y" if dd else "N"
                        else:
                            col_data = str(dd)
 
                        ws.write(index, col, f"{col_data}({data[1][1][col - 1]})")
                        col += 1
                else:
                    if type(d) == bool:
                        col_data = "Y" if d else "N"
                    else:
                        if col == 3:
                            col_data = volume_desc[d]
                        else:
                            col_data = str(d)
 
                    print(col)
                    ws.write(index, col, f"{col_data}({data[1][1][col - 1]})")
                    col += 1
 
            ws.write(index, col, data[1][0])
        wb.save(file_name)