添加G撤日志/真实下单位计算修改/设置L2特殊量监听日志添加
| | |
| | | code = data["data"]["code"] |
| | | spi.set_code_special_watch_volume(code, volume) |
| | | elif _type == "l2_cmd": |
| | | __start_time = time.time() |
| | | # 线程池 |
| | | __l2_cmd_thread_pool.submit( |
| | | lambda: l2CommandManager.process_command(command_manager.CLIENT_TYPE_CMD_L2, None, data)) |
| | | use_time = time.time() - __start_time |
| | | if use_time > 0.005: |
| | | huaxin_l2_log.info(logger_local_huaxin_l2_subscript, f"l2_cmd耗时:{use_time}s") |
| | | |
| | | except Exception as e: |
| | | logging.exception(e) |
| | |
| | | final_watch_indexes = origin_watch_index | watch_indexes |
| | | self.__watch_indexes_dict[code] = final_watch_indexes |
| | | else: |
| | | l2_log.g_cancel_debug(code,f"没有大单监听,开始计算小单:{start_index}-{real_order_index}") |
| | | # 没有300万以上的大单了,计算备用 |
| | | # 只有备用单成交了或者没有备用单,才会再次寻找备用单 |
| | | need_find_by = False |
| | |
| | | need_find_by = False |
| | | break |
| | | if need_find_by: |
| | | l2_log.g_cancel_debug(code, f"启动小单备用监听:{start_index}-{real_order_index}") |
| | | temp_list = [] |
| | | for i in range(start_index, real_order_index): |
| | | data = total_datas[i] |
| | |
| | | break |
| | | temp_list.sort(key=lambda x: x[0], reverse=True) |
| | | if temp_list: |
| | | l2_log.g_cancel_debug(code, f"小单备用监听位置:{temp_list[0][1]['index']}") |
| | | watch_indexes.add(temp_list[0][1]["index"]) |
| | | self.__watch_indexes_by_dict[code] = origin_watch_index_by | watch_indexes |
| | | |
| | |
| | | return info |
| | | |
| | | |
| | | RELIABILITY_TYPE_REAL = 1 # 真实下单位 |
| | | RELIABILITY_TYPE_VIRTUAL = 2 # 影子单下单位 |
| | | RELIABILITY_TYPE_ESTIMATE = 3 # 估算下单位 |
| | | |
| | | |
| | | # 计算预估下单位 |
| | | def __compute_estimate_order_position(code, exec_buy_index): |
| | | total_datas = l2_data_util.local_today_datas.get(code) |
| | | exec_data = total_datas[exec_buy_index] |
| | | THRESH_MS = 20 if code.find('00') == 0 else 100 |
| | | for i in range(exec_buy_index, total_datas[-1]["index"]): |
| | | if L2DataUtil.time_sub_as_ms(total_datas[i]['val'], exec_data["val"]) >= THRESH_MS: |
| | | return i |
| | | return None |
| | | |
| | | |
| | | # L2数据列表 |
| | | # 范围(位置信息,可信的类型) |
| | | def get_l2_place_order_position(code, limit_up_price, datas): |
| | | order_info = get_order_info(code) |
| | | if not order_info: |
| | |
| | | price = order_info[0] |
| | | volume = order_info[1] |
| | | exec_data = order_info[2] |
| | | order_time = order_info[3] # 下单时间 |
| | | order_ref = order_info[4] |
| | | shadow_price = order_info[5] |
| | | shadow_place_order_index = None |
| | |
| | | continue |
| | | shadow_place_order_index = d["index"] |
| | | break |
| | | if shadow_place_order_index is None: |
| | | return None |
| | | real_place_index_info = None |
| | | if shadow_place_order_index: |
| | | total_datas = l2_data_util.local_today_datas.get(code) |
| | | # 找到不是同一ms的结束 |
| | | temp_start_index = shadow_place_order_index |
| | |
| | | continue |
| | | real_place_index = i |
| | | break |
| | | |
| | | if not real_place_index: |
| | | real_place_index = shadow_place_order_index |
| | | real_place_index_info = shadow_place_order_index, RELIABILITY_TYPE_VIRTUAL |
| | | else: |
| | | real_place_index_info = real_place_index, RELIABILITY_TYPE_REAL |
| | | elif time.time() - order_time >= 1: |
| | | # 下单超过1s |
| | | estimate_index = __compute_estimate_order_position(code, exec_data["index"]) |
| | | if estimate_index: |
| | | real_place_index_info = estimate_index, RELIABILITY_TYPE_ESTIMATE |
| | | if real_place_index_info: |
| | | # 获取到了下单位置 |
| | | async_log_util.info(hx_logger_trade_debug, f"真实下单位置:{code}-{real_place_index}") |
| | | async_log_util.info(logger_real_place_order_position, f"真实下单位置:{code}-{real_place_index}") |
| | | async_log_util.info(hx_logger_trade_debug, f"真实下单位置:{code}-{real_place_index_info}") |
| | | async_log_util.info(logger_real_place_order_position, f"真实下单位置:{code}-{real_place_index_info}") |
| | | if code in _place_order_info_dict: |
| | | _place_order_info_dict.pop(code) |
| | | __place_order_position[code] = real_place_index |
| | | return real_place_index |
| | | __place_order_position[code] = real_place_index_info[0] |
| | | return real_place_index_info[0] |
| | | else: |
| | | return None |
| | | |
| | | |
| | | # 获取真实下单位置 |
| | |
| | | from log_module import async_log_util |
| | | from log_module.log import logger_l2_trade_cancel, logger_l2_trade_buy, logger_trade_record, logger_l2_trade, \ |
| | | logger_l2_s_cancel, logger_l2_h_cancel, logger_l2_l_cancel, logger_l2_error, logger_l2_d_cancel, logger_l2_f_cancel |
| | | logger_l2_s_cancel, logger_l2_h_cancel, logger_l2_l_cancel, logger_l2_error, logger_l2_d_cancel, logger_l2_f_cancel, \ |
| | | logger_l2_g_cancel |
| | | |
| | | threadIds = {} |
| | | |
| | |
| | | def f_cancel_debug(code, content, *args): |
| | | __add_async_log(logger_l2_f_cancel, code, content, *args) |
| | | |
| | | def g_cancel_debug(code, content, *args): |
| | | __add_async_log(logger_l2_g_cancel, code, content, *args) |
| | | |
| | | # 交易记录 |
| | | def trade_record(code, type, content, *args): |
| | | if len(args) > 0: |