| | |
| | | finally: |
| | | sk.sendall(socket_util.load_header(json.dumps({"code": 0}).encode(encoding='utf-8'))) |
| | | elif data_json["type"] == "l2_order": |
| | | # L2逐笔委托 |
| | | data = data_json["data"] |
| | | code = data["code"] |
| | | datas = data["data"] |
| | | hx_logger_l2_orderdetail.info(f"{code}#{datas}") |
| | | l2_log.threadIds[code] = random.randint(0, 100000) |
| | | l2_data_manager_new.L2TradeDataProcessor.process_huaxin(code, datas) |
| | | sk.sendall(json.dumps({"code": 0}).encode(encoding='utf-8')) |
| | | try: |
| | | # L2逐笔委托 |
| | | data = data_json["data"] |
| | | code = data["code"] |
| | | datas = data["data"] |
| | | hx_logger_l2_orderdetail.info(f"{code}#{datas}") |
| | | l2_log.threadIds[code] = random.randint(0, 100000) |
| | | l2_data_manager_new.L2TradeDataProcessor.process_huaxin(code, datas) |
| | | finally: |
| | | sk.sendall(json.dumps({"code": 0}).encode(encoding='utf-8')) |
| | | |
| | | elif data_json["type"] == "l2_trans": |
| | | data = data_json["data"] |
| | | code = data["code"] |
| | | datas = data["data"] |
| | | hx_logger_l2_transaction.info(f"{code}#{datas}") |
| | | if datas: |
| | | # 设置成交价 |
| | | current_price_process_manager.set_trade_price(code, datas[-1][1]) |
| | | try: |
| | | buyno_map = l2_data_util.local_today_buyno_map.get(code) |
| | | hx_logger_l2_transaction.info(f"{code}的买入订单号数量:{len(buyno_map.keys()) if buyno_map else 0}") |
| | | buy_progress_index = None |
| | | for i in range(len(datas) - 1, -1, -1): |
| | | d = datas[i] |
| | | buy_no = f"{d[6]}" |
| | | if buyno_map and buy_no in buyno_map: |
| | | hx_logger_l2_transaction.info(f"{code}成交进度:{buyno_map[buy_no]}") |
| | | buy_progress_index = buyno_map[buy_no]["index"] |
| | | break |
| | | data = data_json["data"] |
| | | code = data["code"] |
| | | datas = data["data"] |
| | | hx_logger_l2_transaction.info(f"{code}#{datas}") |
| | | if datas: |
| | | # 设置成交价 |
| | | current_price_process_manager.set_trade_price(code, datas[-1][1]) |
| | | try: |
| | | buyno_map = l2_data_util.local_today_buyno_map.get(code) |
| | | hx_logger_l2_transaction.info(f"{code}的买入订单号数量:{len(buyno_map.keys()) if buyno_map else 0}") |
| | | buy_progress_index = None |
| | | for i in range(len(datas) - 1, -1, -1): |
| | | d = datas[i] |
| | | buy_no = f"{d[6]}" |
| | | if buyno_map and buy_no in buyno_map: |
| | | hx_logger_l2_transaction.info(f"{code}成交进度:{buyno_map[buy_no]}") |
| | | buy_progress_index = buyno_map[buy_no]["index"] |
| | | break |
| | | |
| | | # 获取执行位时间 |
| | | buy_single_index, buy_exec_index, compute_index, num, count, max_num_set, volume_rate = l2_data_manager.TradePointManager.get_buy_compute_start_data( |
| | | code) |
| | | if True: |
| | | if buy_progress_index is not None: |
| | | self.__TradeBuyQueue.set_traded_index(code, buy_progress_index) |
| | | total_datas = l2_data_util.local_today_datas.get(code) |
| | | num_operate_map = l2_data_util.local_today_num_operate_map.get( |
| | | code) |
| | | logger_l2_trade_buy_queue.info("获取成交位置成功: code-{} index-{}", code, |
| | | buy_progress_index) |
| | | buy_time = total_datas[buy_progress_index]["val"][ |
| | | "time"] |
| | | limit_up_price = gpcode_manager.get_limit_up_price(code) |
| | | if buy_exec_index: |
| | | need_cancel, msg = DCancelBigNumComputer.set_trade_progress(code, |
| | | # 获取执行位时间 |
| | | buy_single_index, buy_exec_index, compute_index, num, count, max_num_set, volume_rate = l2_data_manager.TradePointManager.get_buy_compute_start_data( |
| | | code) |
| | | if True: |
| | | if buy_progress_index is not None: |
| | | self.__TradeBuyQueue.set_traded_index(code, buy_progress_index) |
| | | total_datas = l2_data_util.local_today_datas.get(code) |
| | | num_operate_map = l2_data_util.local_today_num_operate_map.get( |
| | | code) |
| | | logger_l2_trade_buy_queue.info("获取成交位置成功: code-{} index-{}", code, |
| | | buy_progress_index) |
| | | buy_time = total_datas[buy_progress_index]["val"][ |
| | | "time"] |
| | | limit_up_price = gpcode_manager.get_limit_up_price(code) |
| | | if buy_exec_index: |
| | | need_cancel, msg = DCancelBigNumComputer.set_trade_progress(code, |
| | | buy_progress_index, |
| | | buy_exec_index, |
| | | total_datas, |
| | | num_operate_map, |
| | | num * 100 * float( |
| | | limit_up_price), |
| | | limit_up_price) |
| | | if need_cancel: |
| | | L2TradeDataProcessor.cancel_buy(code, f"D撤:{msg}", source="d_cancel") |
| | | |
| | | f1 = dask.delayed(HourCancelBigNumComputer.set_trade_progress)(code, buy_time, |
| | | buy_exec_index, |
| | | buy_progress_index, |
| | | total_datas, |
| | | num_operate_map) |
| | | f2 = dask.delayed(LCancelBigNumComputer.set_trade_progress)(code, |
| | | buy_progress_index, |
| | | buy_exec_index, |
| | | total_datas, |
| | | num_operate_map, |
| | | num * 100 * float( |
| | | limit_up_price), |
| | | limit_up_price) |
| | | if need_cancel: |
| | | L2TradeDataProcessor.cancel_buy(code, f"D撤:{msg}", source="d_cancel") |
| | | |
| | | f1 = dask.delayed(HourCancelBigNumComputer.set_trade_progress)(code, buy_time, |
| | | buy_exec_index, |
| | | buy_progress_index, |
| | | total_datas, |
| | | num_operate_map) |
| | | f2 = dask.delayed(LCancelBigNumComputer.set_trade_progress)(code, |
| | | buy_progress_index, |
| | | total_datas) |
| | | f3 = dask.delayed(deal_big_money_manager.set_trade_progress)(code, |
| | | buy_progress_index, |
| | | total_datas, |
| | | num_operate_map) |
| | | dask.compute(f1, f2, f3) |
| | | except Exception as e: |
| | | hx_logger_l2_transaction.exception(e) |
| | | |
| | | sk.sendall(json.dumps({"code": 0}).encode(encoding='utf-8')) |
| | | total_datas) |
| | | f3 = dask.delayed(deal_big_money_manager.set_trade_progress)(code, |
| | | buy_progress_index, |
| | | total_datas, |
| | | num_operate_map) |
| | | dask.compute(f1, f2, f3) |
| | | except Exception as e: |
| | | hx_logger_l2_transaction.exception(e) |
| | | finally: |
| | | sk.sendall(json.dumps({"code": 0}).encode(encoding='utf-8')) |
| | | elif data_json["type"] == "l2_market_data": |
| | | try: |
| | | data = data_json["data"] |