| | |
| | | addr, port = "127.0.0.1", 9001 |
| | | sk = socket.socket() # 生成socket,连接server |
| | | sk.connect((addr, port)) |
| | | try: |
| | | sk.sendall(socket_util.load_header(json.dumps(fdata).encode('utf-8'))) |
| | | print("发送成功") |
| | | result, header = socket_util.recv_data(sk) |
| | | print("接受到数据", result) |
| | | sk.close() |
| | | if result: |
| | | result = json.loads(result) |
| | | if result["code"] != 0: |
| | | raise Exception(result["msg"]) |
| | | finally: |
| | | sk.close() |
| | | |
| | |
| | | try: |
| | | # 如果带有头 |
| | | if _str.startswith("##"): |
| | | print("server接受到数据:",_str) |
| | | |
| | | total_length = int(_str[2:10]) |
| | | _str = _str[10:] |
| | |
| | | code_limit_up_reason_dict, shsz=True) |
| | | # 获取主板历史身位 |
| | | if is_top_4: |
| | | is_open_limit_up, msg = kpl_block_util.is_shsz_open_limit_up(code, block, limit_up_record_datas, |
| | | pen_limit_up_codes = kpl_block_util.get_shsz_open_limit_up_codes(code, block, limit_up_record_datas, |
| | | code_limit_up_reason_dict) |
| | | if is_open_limit_up: |
| | | if pen_limit_up_codes: |
| | | # 主板开1 |
| | | if current_shsz_rank < 2 and record_shsz_rank < 2: |
| | | if current_shsz_rank < len(pen_limit_up_codes) + 1 and record_shsz_rank < len(pen_limit_up_codes) + 1: |
| | | # 属于龙1,龙2 |
| | | return block, f"{block}:top4涨停板块,主板开1,属于龙1/龙2(实时身位-{current_shsz_rank})" |
| | | return block, f"{block}:top4涨停板块,主板开1({pen_limit_up_codes}),属于主板前龙{len(pen_limit_up_codes) + 1}(实时身位-{current_shsz_rank})" |
| | | else: |
| | | msg_list.append( |
| | | f"板块-{block}: top4涨停板块,主板开1({msg}),不为主板龙1龙2(实时身位-{current_shsz_rank},历史身位-{record_shsz_rank})") |
| | | f"板块-{block}: top4涨停板块,主板开1({pen_limit_up_codes}),不为主板前龙{len(pen_limit_up_codes) + 1}(实时身位-{current_shsz_rank},历史身位-{record_shsz_rank})") |
| | | continue |
| | | else: |
| | | if current_shsz_rank == 0 and record_shsz_rank < 2: |
| | |
| | | |
| | | # 是否主板开1 |
| | | # limit_up_record_datas 今日历史涨停 |
| | | def is_shsz_open_limit_up(code, block, limit_up_record_datas, code_block_dict): |
| | | def get_shsz_open_limit_up_codes(code, block, limit_up_record_datas, code_block_dict): |
| | | # 获取今日9:30的时间戳 |
| | | time_str = datetime.datetime.now().strftime("%Y-%m-%d") + " 09:30:00" |
| | | timestamp = time.mktime(time.strptime(time_str, '%Y-%m-%d %H:%M:%S')) |
| | | limit_up_codes = set() |
| | | for k in limit_up_record_datas: |
| | | if code_block_dict.get(k[3]) == block: |
| | | if int(k[5]) < timestamp: |
| | | return True, f"{k[3]}开一" |
| | | return False, "" |
| | | limit_up_codes.add(k[3]) |
| | | return limit_up_codes |
| | | |
| | | |
| | | # 代码是否是后排 |