| | |
| | | t1.start() |
| | | t2 = threading.Thread(target=lambda: self.__run_upload_transaction_task(code), daemon=True) |
| | | t2.start() |
| | | t3 = threading.Thread(target=lambda: self.__run_log_task(code), daemon=True) |
| | | t3.start() |
| | | self.upload_l2_data_task_dict[code] = (t1, t2, t3) |
| | | # t3 = threading.Thread(target=lambda: self.__run_log_task(code), daemon=True) |
| | | # t3.start() |
| | | self.upload_l2_data_task_dict[code] = (t1, t2) |
| | | # 释放已经分配的队列 |
| | | |
| | | def release_distributed_upload_queue(self, code): |
| | |
| | | if not real_place_index: |
| | | real_place_index_info = shadow_place_order_index, RELIABILITY_TYPE_VIRTUAL |
| | | else: |
| | | # TODO 需要矫正是否撤单 |
| | | real_place_index_info = real_place_index, RELIABILITY_TYPE_REAL |
| | | elif tool.trade_time_sub(datas[-1]['val']['time'], exec_data['val']['time']) >= estimate_time_space: |
| | | # 下单超过2s |
| | |
| | | if not jx_blocks_info: |
| | | start_time = time.time() |
| | | blocks = kpl_api.getCodeBlocks(code) |
| | | async_log_util.info(logger_kpl_block_can_buy, |
| | | f"{code}:获取到精选板块-{blocks} 耗时:{int(time.time() - start_time)}s") |
| | | self.save_jx_blocks(code, blocks, current_limit_up_blocks) |
| | | async_log_util.info(logger_kpl_block_can_buy, f"{code}:获取到精选板块-{blocks} 耗时:{int(time.time() - start_time)}s") |
| | | else: |
| | | # 还没涨停的需要更新精选板块 更新精选板块 |
| | | if abs(float(buy_1_price) - float(limit_up_price)) >= 0.001: |
| | |
| | | start_time = time.time() |
| | | # 距离上次更新时间过去了5分钟 |
| | | blocks = kpl_api.getCodeBlocks(code) |
| | | async_log_util.info(logger_kpl_block_can_buy, |
| | | f"{code}:获取到精选板块(更新)-{blocks} 耗时:{int(time.time() - start_time)}s") |
| | | self.save_jx_blocks(code, blocks, current_limit_up_blocks) |
| | | async_log_util.info(logger_kpl_block_can_buy, f"{code}:获取到精选板块(更新)-{blocks} 耗时:{int(time.time() - start_time)}s") |
| | | |
| | | |
| | | elif price_rate > 0.03: |
| | | # 添加备用板块 |
| | |
| | | raise Exception("请求出错") |
| | | return response.text |
| | | else: |
| | | fdata = middle_api_protocol.load_kpl(url, data) |
| | | fdata = middle_api_protocol.load_kpl(url, data, timeout) |
| | | return middle_api_protocol.request(fdata) |
| | | |
| | | |
| | |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | | print(getLimitUpInfoNew()) |
| | | print(getCodeBlocks("600822")) |
| | |
| | | # 如果在9:24-9:30 需要加载板块 |
| | | if int("092400") < int(tool.get_now_time_str().replace(":", "")) < int("093000"): |
| | | for d in datas: |
| | | KPLCodeJXBlockManager().load_jx_blocks(d[0], gpcode_manager.get_price(d[0]), float(d[2]), |
| | | KPLLimitUpDataRecordManager.get_current_reasons()) |
| | | threading.Thread(target=lambda: KPLCodeJXBlockManager().load_jx_blocks(d[0], |
| | | gpcode_manager.get_price( |
| | | d[0]), |
| | | float(d[2]), |
| | | KPLLimitUpDataRecordManager.get_current_reasons()), |
| | | daemon=True).start() |
| | | time.sleep(1) |
| | | logger_l2_codes_subscript.info("({})发送到华鑫L2代码处理队列:数量-{}", request_id, len(datas)) |
| | | except Exception as e: |
| | |
| | | |
| | | |
| | | # ------------------------------开盘啦------------------------------------- |
| | | def load_kpl(url, data): |
| | | fdata = {"type": "kpl", "data": {"ctype": "kpl", "data": {"url": url, "data": data}}} |
| | | def load_kpl(url, data, timeout): |
| | | fdata = {"type": "kpl", "data": {"ctype": "kpl", "data": {"url": url, "data": data, "timeout": timeout}}} |
| | | return fdata |
| | | |
| | | |