Administrator
2023-10-09 0d91cf2beb00fcb4e4c2b9e38ecbf496f86ab2a6
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
"""
代码信息对外输出
"""
 
# score_info 得分信息
# 下单参数信息
# 选股宝
# 市场热度
import sys
import time
import code_attribute
from code_attribute import code_volumn_manager, limit_up_time_manager, global_data_loader, gpcode_manager
import constant
from utils import global_util, tool
from log_module import log, log_export
from l2 import l2_data_manager, l2_data_util, transaction_progress, l2_data_manager_new, code_price_manager
from l2.cancel_buy_strategy import HourCancelBigNumComputer
import l2.l2_data_manager_new
from third_data import kpl_data_manager, kpl_api
from third_data.kpl_data_manager import KPLLimitUpDataRecordManager
from trade import first_code_score_manager, l2_trade_factor, trade_manager, l2_trade_util
from trade.l2_trade_factor import L2TradeFactorUtil
import trade.deal_big_money_manager
 
base_output_content = {}
kpl_block_info_dict = {}
 
__kplDataManager = kpl_data_manager.KPLDataManager()
 
 
def __get_base_html_content():
    print("路径", sys.path[0])
    if base_output_content.get('css') is None:
        __base_html_content = ""
        with open("./output/css/style.css", mode='r') as f:
            lines = f.readlines()
            for line in lines:
                __base_html_content += line
        base_output_content['css'] = __base_html_content
 
    return f"<head><style>{base_output_content['css']}</style></head>"
 
 
 
def money_desc(money):
    if abs(money) > 100000000:
        return f"{round(money / 100000000, 2)}亿"
    else:
        return f"{round(money / 10000, 2)}万"
 
 
def get_output_params(code, jingxuan_cache_dict, industry_cache_dict):
    __start_time = time.time()
 
    def format_plate_output(_plat):
        if _plat in jingxuan_cache_dict:
            return _plat, money_desc(jingxuan_cache_dict[_plat][3])
        elif _plat in industry_cache_dict:
            return _plat, money_desc(industry_cache_dict[_plat][3])
        else:
            return _plat, ''
 
    params = {
        "base_url": "http://192.168.3.252/kp/",
    }
 
    day = tool.get_now_date_str()
    is_target_code = gpcode_manager.FirstCodeManager().is_in_first_record_cache(code)
    code_extra_infos = []
    if l2_trade_util.BlackListCodeManager().is_in_cache(code):
        code_extra_infos.append("黑名单")
    if l2_trade_util.WhiteListCodeManager().is_in_cache(code):
        code_extra_infos.append("白名单")
    # 获取白名单,黑名单
    if code_attribute.gpcode_manager.WantBuyCodesManager().is_in_cache(code):
        code_extra_infos.append("想买单")
    if code_attribute.gpcode_manager.PauseBuyCodesManager().is_in_cache(code):
        code_extra_infos.append("暂不买")
    params["code"] = code
    params["code_name"] = f"{gpcode_manager.get_code_name(code)} {code}  ({','.join(code_extra_infos)})"
 
    score_info = None
    buy_params_info = None
    xgb_infos = None
    total_datas = l2_data_util.local_today_datas.get(code)
    if total_datas is None:
        l2_data_util.load_l2_data(code)
        total_datas = l2_data_util.local_today_datas.get(code)
    if is_target_code:
        params["score_data"] = {}
        limit_up_price = gpcode_manager.get_limit_up_price(code)
        limit_up_time = limit_up_time_manager.LimitUpTimeManager().get_limit_up_time_cache(code)
        volume_rate, volume_info = code_volumn_manager.get_volume_rate(code, True)
        (score, score_list), score_source_list = first_code_score_manager.get_score(code, volume_rate, limit_up_time,
                                                                                    True)
 
        ################################买前评分################################
        # ["换手量能", "竞价强度", "资金力度", "K线形态", "历史股性", "板块热度", "上板时间", "市值大小","股价大小"]
 
        # 换手量能
        # 获取当前量信息
        max_60, yest = code_volumn_manager.get_histry_volumn(code)
        today = code_volumn_manager.get_today_volumn(code)
        params["score_data"]["volume"] = {"score": score_list[6], "now": f"{round(int(today) / 1000000, 2)}",
                                          "high": {"num": round(max_60[0] / 1000000, 2), "date": max_60[1]},
                                          "rate": round(score_source_list[6] * 100, 2)}
 
        # 竞价强度
        params["score_data"]["bidding"] = {"score": score_list[2],
                                           "money": (score_source_list[2] if score_source_list[2] else 0)}
 
        # 资金力度
        deal_indexes = set()
        deal_info = ""
        params["score_data"]["deal_big_money"] = {"score": score_list[8], "money": score_source_list[8][0] // 10000,
                                                  "base_money": score_source_list[8][1] // 10000,
                                                  "rate": round(score_source_list[8][0] / score_source_list[8][1], 2)}
        if deal_indexes:
            temps = []
            for index in deal_indexes:
                temps.append(int(index))
            temps.sort()
            start_index = temps[0]
            end_index = temps[-1]
            try:
                deal_info = f"【{total_datas[start_index]['val']['time']}&{total_datas[start_index]['val']['num']}手-{total_datas[end_index]['val']['time']}&{total_datas[end_index]['val']['num']}手】,"
            except:
                pass
            params["score_data"]["deal_big_money"]["start"] = {"time": total_datas[start_index]['val']['time'],
                                                               "num": total_datas[start_index]['val']['num']}
            params["score_data"]["deal_big_money"]["end"] = {"time": total_datas[end_index]['val']['time'],
                                                             "num": total_datas[end_index]['val']['num']}
 
        # K线形态
        k_score = 0
        k_source = []
        for k in score_list[3]:
            k_score += k
 
        # (15个交易日是否涨幅24.9%,是否破前高,是否超跌,是否接近前高,是否N,是否V)
        for k in range(0, len(score_source_list[3])):
            if k == 0:
                if score_source_list[3][k][0]:
                    k_source.append(("涨幅过高", score_list[3][k]))
            elif k == 1:
                if score_source_list[3][k][0]:
                    k_source.append(("突破前高", score_list[3][k]))
            elif k == 2:
                if score_source_list[3][k][0]:
                    k_source.append(("超跌补涨", score_list[3][k]))
            elif k == 3:
                if score_source_list[3][k][0]:
                    k_source.append((f"逼近前高-{score_source_list[3][k][1]}】", score_list[3][k]))
            elif k == 4:
                if score_source_list[3][k][0]:
                    k_source.append(("N字型", score_list[3][k]))
            elif k == 5:
                if score_source_list[3][k][0]:
                    k_source.append(("V字型", score_list[3][k]))
            elif k == 6:
                if not score_source_list[3][k][0]:
                    k_source.append(("不满足任何形态", score_list[3][k]))
            elif k == 7:
                if score_source_list[3][k][0]:
                    k_source.append(("天量大阳", score_list[3][k]))
 
        params["score_data"]["k_form"] = {"score": k_score, "datas": k_source}
 
        log.logger_debug.info(f"K线形态耗时:{time.time() - __start_time}")
        __start_time = time.time()
 
        # 历史股性
        nature_score = 0
        nature_source = []
        for k in score_list[4]:
            nature_score += k
 
        code_nature_datas = {"score": nature_score, "limit_up_count": score_source_list[4][0]}
 
        for n in range(0, len(score_source_list[4])):
            if n == 0:
                nature_source.append(f"涨停次数【{score_source_list[4][n]}】")
            elif n == 1:
                if score_source_list[4][n]:
                    nature_source.append(f"首板溢价率【{round(score_source_list[4][n], 2)}】")
                    code_nature_datas["first_limit_up_yijia"] = round(score_source_list[4][1], 2)
                else:
                    nature_source.append(f"无首板")
                    code_nature_datas["first_limit_up_yijia"] = "无首板"
            elif n == 2:
                if score_source_list[4][n]:
                    nature_source.append(f"首板炸板溢价率【{round(score_source_list[4][n], 2)}】")
                    code_nature_datas["first_open_limit_up_yijia"] = round(score_source_list[4][2], 2)
                else:
                    nature_source.append(f"无首板炸板")
                    code_nature_datas["first_open_limit_up_yijia"] = "无首板炸板"
 
        params["score_data"]["code_nature"] = code_nature_datas
 
        log.logger_debug.info(f"历史股性耗时:{time.time() - __start_time}")
        __start_time = time.time()
 
        # 板块热度
        hot_block_score = 0
        for k in score_list[5]:
            hot_block_score += k
        hot_block_source_data = score_source_list[5]
        for k in hot_block_source_data:
            hot_block = {
                # 目标板块信息(板块名称,板块涨幅,历史板块出现次数)
                "target_block_info": ("无板块", 0, 0),
                # 涨停顺序
                "limit_up_index": 0,
                # 涨停代码数量
                "limit_up_codes_count": 0,
                # 板块代码涨幅信息
                "block_codes_rates_info": (0, 0),
                # 炸板代码数量
                "break_size": 0,
                # 炸板回封数量
                "re_limit_up_size": 0,
                # 高位版信息
                "high_block_infos": [],
            }
        params["score_data"]["hot_block"] = {"score": hot_block_score,
                                             "limit_up_index": hot_block_source_data['limit_up_index'] + 1,
                                             "block_name": hot_block_source_data['target_block_info'][0],
                                             "limit_up_count": hot_block_source_data['limit_up_codes_count'],
                                             "block_history_count": hot_block_source_data['target_block_info'][2],
                                             "open_limit_up_count": hot_block_source_data['break_size']}
 
        # 上板时间
        params["score_data"]["limit_up_time"] = {"score": score_list[7], "time": score_source_list[7]}
        # 市值大小
        params["score_data"]["zyltgb"] = {"score": score_list[0], "value": round(score_source_list[0] / 100000000, 2)}
        # 股价大小
        params["score_data"]["limit_up_price"] = {"score": score_list[1], "price": score_source_list[1]}
 
        params["score_data"]["total_score"] = score
 
        # zyltgb, limit_price, bidding, k_form, code_nature, hot_block, volume_rate, limit_up_time,
        # deal_big_money
        log.logger_debug.info(f"板块热度耗时:{time.time() - __start_time}")
        __start_time = time.time()
 
        ###############################下单信息###############################
        params["trade_data"] = {}
 
        # 获取买入意愿
        volume_rate = score_source_list[6]
        __L2PlaceOrderParamsManager = l2_trade_factor.L2PlaceOrderParamsManager(code, True, volume_rate,
                                                                                code_volumn_manager.get_volume_rate_index(
                                                                                    volume_rate),
                                                                                (
                                                                                    (score, score_list),
                                                                                    score_source_list))
        # 是否可以买入的信息
        can_buy_info = l2.l2_data_manager_new.L2TradeDataProcessor.can_buy_first(code, limit_up_price)
        params["trade_data"]["can_buy_info"] = can_buy_info
 
        __base_L2PlaceOrderParamsManager = l2_trade_factor.L2PlaceOrderParamsManager(code, False, volume_rate,
                                                                                     code_volumn_manager.get_volume_rate_index(
                                                                                         volume_rate),
                                                                                     ((score, score_list),
                                                                                      score_source_list))
        if -1 < __L2PlaceOrderParamsManager.score_index < 3:
            params["trade_data"]["star"] = {"desc": "主动买入"}
            if __L2PlaceOrderParamsManager.score_index == 0:
                params["trade_data"]["star"]["count"] = 3
            elif __L2PlaceOrderParamsManager.score_index == 1:
                params["trade_data"]["star"]["count"] = 2
            else:
                params["trade_data"]["star"]["count"] = 1
 
        elif __L2PlaceOrderParamsManager.score_index < 0:
            params["trade_data"]["star"] = {"desc": "不执行买入", "count": 0}
        else:
            params["trade_data"]["star"] = {"desc": "被动买入", "count": 0}
        # 安全笔数
        safe_count = __L2PlaceOrderParamsManager.get_safe_count()
        base_safe_count, min_count, max_count = L2TradeFactorUtil.get_safe_buy_count(code, True)
        params["trade_data"]["safe_count"] = {"base": base_safe_count, "now": safe_count}
        # 动态M值
        m = __L2PlaceOrderParamsManager.get_m_val()
        zyltgb = global_util.zyltgb_map.get(code)
        if zyltgb is None:
            global_data_loader.load_zyltgb()
            zyltgb = global_util.zyltgb_map.get(code)
        base_m = L2TradeFactorUtil.get_base_safe_val(zyltgb)
        params["trade_data"]["m_val"] = {"base": base_m // 10000, "now": m[0] // 10000}
        # 买前大单
        big_num = __L2PlaceOrderParamsManager.get_big_num_count()
        base_big_num = __base_L2PlaceOrderParamsManager.get_big_num_count()
        params["trade_data"]["big_num"] = {"base": base_big_num, "now": big_num}
        # 成交进度
        trade_progress, is_default = transaction_progress.TradeBuyQueue().get_traded_index(code)
        if trade_progress is None or trade_progress < 0 or is_default:
            # buy_params_info.append("未识别")
            pass
        else:
            if trade_progress<len(total_datas):
                data = total_datas[trade_progress]
                params["trade_data"]["trade_progress"] = {"time": data['val']['time'],
                                                          "num": data['val']['num'], "money": round(
                        data['val']['num'] * float(data['val']['price']) * 100 / 10000, 1)}
 
        # 买入信号
        buy_single_index, buy_exec_index, compute_index, num, count, max_num_set, volume_rate = l2_data_manager.TradePointManager().get_buy_compute_start_data_cache(
            code)
 
        if buy_single_index is None:
            # buy_params_info.append("无信号")
            pass
        else:
            data = total_datas[buy_single_index]
            params["trade_data"]["buy_single"] = {"time": data['val']['time'], "num": data['val']['num'],
                                                  "money": round(data['val']['num'] * float(
                                                      data['val']['price']) * 100 / 10000, 1)}
 
        if buy_exec_index is None or buy_exec_index < 0:
            # buy_params_info.append("未下单")
            pass
        else:
            data = total_datas[buy_exec_index]
            params["trade_data"]["buy_exec"] = {"time": data['val']['time'], "num": data['val']['num'],
                                                "money": round(data['val']['num'] * float(
                                                    data['val']['price']) * 100 / 10000, 1)}
        params["trade_data"]["trade_state"] = {}
        trade_state = trade_manager.CodesTradeStateManager().get_trade_state_cache(code)
        if trade_state == trade_manager.TRADE_STATE_BUY_PLACE_ORDER or trade_state == trade_manager.TRADE_STATE_BUY_DELEGATED:
            params["trade_data"]["trade_state"]["order"] = True
            params["trade_data"]["trade_state"]["desc"] = "已下单"
        else:
            params["trade_data"]["trade_state"]["order"] = False
            if trade_state == trade_manager.TRADE_STATE_NOT_TRADE:
                params["trade_data"]["trade_state"]["desc"] = "未交易"
            elif trade_state == trade_manager.TRADE_STATE_BUY_CANCEL_ING:
                params["trade_data"]["trade_state"]["desc"] = "撤单中"
            elif trade_state == trade_manager.TRADE_STATE_BUY_CANCEL_SUCCESS:
                params["trade_data"]["trade_state"]["desc"] = "撤单成功"
            elif trade_state == trade_manager.TRADE_STATE_BUY_SUCCESS:
                params["trade_data"]["trade_state"]["desc"] = "已成交"
 
        log.logger_debug.info(f"下单信息耗时:{time.time() - __start_time}")
        __start_time = time.time()
 
        # H撤监听范围
        if trade_state == trade_manager.TRADE_STATE_BUY_PLACE_ORDER or trade_state == trade_manager.TRADE_STATE_BUY_DELEGATED or trade_state == trade_manager.TRADE_STATE_BUY_SUCCESS:
            hcancel_datas_dict, cancel_indexes_set = HourCancelBigNumComputer().get_watch_index_dict(code)
            # 根据日志读取实时的计算数据
            h_cancel_latest_compute_info = log_export.get_h_cancel_compute_info(code)
            if hcancel_datas_dict:
                temp_list = [(k, hcancel_datas_dict[k][0]) for k in hcancel_datas_dict]
                canceled_indexs = set([int(k.split("-")[0]) for k in cancel_indexes_set])
                temp_list.sort(key=lambda x: x[0])
                params["trade_data"]["h_cancel"] = {
                    "computed_info": list(h_cancel_latest_compute_info) if h_cancel_latest_compute_info else None,
                    "datas": []}
                for i in range(0, len(temp_list)):
                    temp = temp_list[i]
                    val = total_datas[temp[0]]["val"]
                    canceled = temp[0] in canceled_indexs
                    params["trade_data"]["h_cancel"]["datas"].append(
                        (val["time"], val["num"], money_desc(val["num"] * float(val["price"]) * 100),
                         (1 if canceled else 0)))
        log.logger_debug.info(f"H撤监听范围耗时:{time.time() - __start_time}")
        __start_time = time.time()
 
    ##############################主动买,被动买##################################
    # 返回主动买,被动买,不买的列表(代码, 名称, 得分, 是否涨停)
    codes_score = __load_codes_scores()
    params["initiative_buy_codes"] = []
    for d in codes_score[0]:
        params["initiative_buy_codes"].append(
            {"name": d[1], "code": d[0], "score": d[2], "limit_up": d[3], "open_limit_up": d[4]})
 
    params["passive_buy_codes"] = []
    for d in codes_score[1]:
        params["passive_buy_codes"].append(
            {"name": d[1], "code": d[0], "score": d[2], "limit_up": d[3], "open_limit_up": d[4]})
 
    params["passive_buy_codes"] = params["passive_buy_codes"]
    log.logger_debug.info(f"主动买,被动买耗时:{time.time() - __start_time}")
    __start_time = time.time()
 
    trade_info = __load_trade_record(code, total_datas)
    params["trade_record"] = {"open_limit_up": trade_info[0], "records": trade_info[2]}
 
    log.logger_debug.info(f"读取交易记录耗时:{time.time() - __start_time}")
    __start_time = time.time()
 
    ##############################开盘啦相关信息##################################
    industry = global_util.code_industry_map.get(code)
    params["kpl_code_info"] = {
        "industry": format_plate_output(industry)}
    # 获取开盘啦板块
    plate_info = None
    if code not in kpl_block_info_dict:
        plate_info = kpl_api.getStockIDPlate(code)
    else:
        plate_info = kpl_block_info_dict.get(code)
    if plate_info:
        kpl_block_info_dict[code] = plate_info
        plate_info.sort(key=lambda x: x[2])
        plate_info.reverse()
        params["kpl_code_info"]["plate"] = [(k[0], k[1], k[2], format_plate_output(k[1])[1]) for k in plate_info]
 
    log.logger_debug.info(f"开盘啦板块耗时:{time.time() - __start_time}")
    __start_time = time.time()
 
    # 获取代码的历史涨停数据,(涨停原因,日期,板块)
    code_records = KPLLimitUpDataRecordManager.get_latest_infos(code, 4, False)[:2]
    if code_records:
        code_records = [(format_plate_output(k[0]), k[1], [format_plate_output(k1) for k1 in k[2].split("、")]) for k in
                        code_records]
    params["kpl_code_info"]["code_records"] = code_records
 
    if not KPLLimitUpDataRecordManager.total_datas:
        KPLLimitUpDataRecordManager.load_total_datas()
    for d in KPLLimitUpDataRecordManager.total_datas:
        if d[3] == code:
            # 获取今日
            plates = d[6].split("、")
            plates = [format_plate_output(p) for p in plates]
            params["kpl_code_info"]["today"] = (format_plate_output(d[2]), d[1], plates)
            break
 
    log.logger_debug.info(f"获取代码的历史涨停数据耗时:{time.time() - __start_time}")
    __start_time = time.time()
    return params
 
 
def __load_codes_scores():
    # 获取所有监听中的代码
    codes = gpcode_manager.FirstGPCodesManager().get_first_gp_codes()
    scores = {}  # l2_data_manager_new.L2TradeDataProcessor.get_code_scores()
    for code in codes:
        if code not in scores:
            # 获取分数
            try:
                limit_up_time = limit_up_time_manager.LimitUpTimeManager().get_limit_up_time_cache(code)
                volume_rate, volume_info = code_volumn_manager.get_volume_rate(code, True)
                (score, score_list), score_source_list = first_code_score_manager.get_score(code, volume_rate,
                                                                                            limit_up_time,
                                                                                            True)
                scores[code] = score
            except:
                pass
    # 筛选180分以上的代码
    scores_list = []
    for code in scores:
        code_name = gpcode_manager.get_code_name(code)
        # 获取现价,判断是否涨停
        current_price_info = global_util.cuurent_prices.get(code)
        limit_up_info = code_price_manager.Buy1PriceManager().get_limit_up_info(code)
        is_limit_up = True
        open_limit_up = limit_up_info[0] and limit_up_info[1]
        if current_price_info is not None and not current_price_info[1]:
            is_limit_up = False
        else:
            is_limit_up = True
        scores_list.append((code, code_name, scores[code], is_limit_up, open_limit_up))
    scores_list.sort(key=lambda x: x[2], reverse=True)
    fscores_list = [[], [], []]
    for score in scores_list:
        if score[2] >= constant.BUY_SCORE_RANK_1:
            fscores_list[0].append(score)
        elif score[2] >= constant.BUY_SCORE_RANK_0:
            fscores_list[1].append(score)
        else:
            fscores_list[2].append(score)
 
    return fscores_list
 
 
def __load_trade_record(code, total_datas):
    def format_l2_data(item):
        return f"{item['val']['time']}#{item['val']['num']}手#{round(item['val']['num'] * float(item['val']['price']) * 100 / 10000, 1)}万"
 
    # 获取炸板信息
    limit_up_info = code_price_manager.Buy1PriceManager().get_limit_up_info(code)
    break_time = limit_up_info[1]
    records = []
    try:
        records = log_export.load_buy_score_recod(code)
    except:
        pass
    records_new = []
    records_new_data = []
    index = 0
    if records:
        try:
            for record in records:
                time_ = record[0]
                type = record[1]
                data = record[2]
                if type == '下单':
                    index += 1
                    temp = f"第{index}次下单:【{time_}】&【{data['score']}分】,{data.get('desc')}"
                    records_new.append(temp)
                    records_new_data.append({"type": 1, "index": index, "time": time_, "score": data['score']})
                elif type == 'S撤':
                    # index':378 , 'rate':0.51 , 'target_rate':0.49
                    pass
                elif type == 'S撤范围':
                    start = format_l2_data(total_datas[data['start_index']])
                    end = format_l2_data(total_datas[data['end_index']])
                    range_seconds = data['range_seconds']
                    temp = f"第{index}次撤单:S撤囊括范围:【起始位:{start}】至【截止位:{end}】囊括时间【{range_seconds}】秒"
                elif type == 'H撤范围':
                    start = format_l2_data(total_datas[data['start_index']])
                    end = format_l2_data(total_datas[data['end_index']])
                    count = data['count']
                    temp = f"H撤囊括范围:【起始位:{start}】至【截止位:{end}】物理笔数共【{count}】笔"
                elif type == 'H撤':
                    # 'start_index':339,'end_index':464, 'count':17
                    pass
                elif type == '撤单':
                    temp = f"第{index}次撤单:【{time_}】{data['msg']}"
                    records_new.append(temp)
                    records_new_data.append({"type": 0, "time": time_, "desc": data['msg']})
 
        except:
            pass
 
    return break_time, records_new, records_new_data
 
if __name__ == '__main__':
    plate_info = kpl_api.getStockIDPlate("600748")
    print(plate_info)
 
if __name__ == '__main__1':
    datas = {
        "base_url": "http://192.168.3.122/kp/",
        "code_name": "天域生态 002255",
        "score_data": {"volume": {"score": 20, "now": "12", "high": {"num": "56", "date": "2023-04-13"}},
                       "bidding": {"score": 10, "money": "4563"},
                       "deal_big_money": {"score": 10, "money": 0, "base_money": 456.5,
                                          "start": {"time": "09:00:00", "num": 1456},
                                          "end": {"time": "09:00:00", "num": 1456}},
                       "k_form": {"score": 10, "datas": ["破前高", "超跌补涨", "涨幅过高"]},
                       "code_nature": {"score": 10, "data_desc": "涨停次数2次"},
                       "hot_block": {"score": 10, "block_name": "影视", "limit_up_count": 10, "open_limit_up_count": 2},
                       "limit_up_time": {"score": 10, "time": "09:56:00"},
                       "zyltgb": {"score": 10, "value": "12.5"},
                       "limit_up_price": {"score": 10, "price": "6.35"},
                       "total_score": "210"
                       },
        "trade_data": {"star": {"desc": "被动买入", "count": 0},
                       "safe_count": {"base": 12, "now": 2},
                       "m": {"base": 1200, "now": 1000},
                       "big_num": {"base": 10, "now": 2},
                       "trade_progress": {"time": "09:12:12", "num": 1111, "money": "12.56"},
                       "buy_single": {"time": "09:12:12", "num": 1111, "money": "12.56"},
                       "buy_exec": {"time": "09:12:12", "num": 1111, "money": "12.56"},
 
                       },
        "xgb_code_infos": [{"date": "今天", "blocks": [
            {"name": "影视", "limit_up_count": 2, "index": 1, "price": "12.00", "rate": "+10.00%"},
            {"name": "文旅", "limit_up_count": 3, "index": 2, "price": "12.00", "rate": "+10.00%"},
        ]}],
        "initiative_buy_codes": [
            {"name": "测试1", "code": "000123", "score": 125, "limit_up": True, "open_limit_up": True},
            {"name": "测试2", "code": "000123", "score": 125, "limit_up": False, "open_limit_up": True},
            {"name": "测试2", "code": "000123", "score": 125, "limit_up": False, "open_limit_up": True},
            {"name": "测试2", "code": "000123", "score": 125, "limit_up": False, "open_limit_up": False}
        ],
        "passive_buy_codes": [{"name": "测试1", "code": "000123", "score": 125},
                              {"name": "测试2", "code": "000123", "score": 125},
                              {"name": "测试2", "code": "000123", "score": 125},
                              {"name": "测试2", "code": "000123", "score": 125}
                              ],
        "trade_record": {"open_limit_up": "10:00:03", "records": [
            {"type": 1, "index": 1, "time": "11:00:00", "score": 12},
            {"type": 0, "time": "11:26:00", "desc": "H撤撤单"}
        ]},
        "xgb_infos": [{"block": {"name": "测试1", "rate": "+12.00%", "limit_up_count": 10},
                       "codes": [
                           {"limit_up": True, "name": "测试代码", "code": "000654"},
                           {"limit_up": True, "name": "测试代码", "code": "000654"},
                           {"limit_up": True, "name": "测试代码", "code": "000654"},
                           {"limit_up": False, "name": "测试代码", "code": "000654"},
                       ]}]
    }
    print(render(datas))