| | |
| | | datas = _datas[1] |
| | | request_id = _datas[2] |
| | | logger_l2_codes_subscript.info("({})读取L2代码处理队列:数量-{}", request_id, len(datas)) |
| | | print("时间戳:", times) |
| | | print("内容:", datas) |
| | | # 只处理20s内的数据 |
| | | if time.time() - times < 20: |
| | | # 获取涨停列表中的数据 |
| | | # datas中的数据格式:(代码, 现价, 涨幅, 量, 时间) |
| | | codes = [d[0] for d in datas] |
| | | # 9:25-9:30之间获取 |
| | | if int("092500") < int(tool.get_now_time_str().replace(":", "")) < int("092955"): |
| | | try: |
| | | limit_up_data_str = kpl_api.getLimitUpInfoNew() |
| | | limit_up_datas = json.loads(limit_up_data_str) |
| | | limit_up_datas = limit_up_datas["list"] |
| | | for d in limit_up_datas: |
| | | code = d[0] |
| | | if code in codes: |
| | | continue |
| | | if not tool.is_can_buy_code(code): |
| | | continue |
| | | limit_up_price = gpcode_manager.get_limit_up_price(d[0]) |
| | | if limit_up_price: |
| | | # 默认设置涨停,量为0 |
| | | datas.append((code, 0, float(limit_up_price), |
| | | tool.get_shadow_price(float(limit_up_price)), 100)) |
| | | except Exception as e: |
| | | logger_l2_codes_subscript.exception(e) |
| | | if not datas: |
| | | # 没有数据需要处理 |
| | | continue |
| | |
| | | root_data = {"type": ClientSocketManager.CLIENT_TYPE_CMD_L2, |
| | | "data": datas} |
| | | queue_other_w_l2_r.put_nowait(json.dumps(root_data)) |
| | | print("设置L2代码结束") |
| | | # 如果在9:24-9:30 需要加载板块 |
| | | if int("092400") < int(tool.get_now_time_str().replace(":", "")) < int("093000"): |
| | | # 如果在9:24-9:29 需要加载板块 |
| | | if int("092400") < int(tool.get_now_time_str().replace(":", "")) < int("092900"): |
| | | for d in datas: |
| | | threading.Thread(target=lambda: KPLCodeJXBlockManager().load_jx_blocks(d[0], |
| | | gpcode_manager.get_price( |
| | |
| | | float(d[2]), |
| | | KPLLimitUpDataRecordManager.get_current_reasons()), |
| | | daemon=True).start() |
| | | time.sleep(1) |
| | | time.sleep(0.2) |
| | | logger_l2_codes_subscript.info("({})发送到华鑫L2代码处理队列:数量-{}", request_id, len(datas)) |
| | | except Exception as e: |
| | | logging.exception(e) |