| | |
| | | # 真实下单位之前的手数 |
| | | before_nums_info = [] |
| | | before_canceled_nums_info = [] |
| | | dealing_info = HuaXinBuyOrderManager.get_dealing_order_info(code) |
| | | for wi in watch_indexes: |
| | | data = total_data[wi] |
| | | val = data["val"] |
| | | cancel_data = L2DataComputeUtil.is_canceled(code, wi, total_data, canceled_buyno_map, trade_index, |
| | | cancel_data = L2DataComputeUtil.is_canceled(code, wi, total_data, canceled_buyno_map, dealing_info[0] if dealing_info else None, |
| | | deal_order_nos) |
| | | if str(wi) in after_place_order_index_dict: |
| | | # 真实下单位置之后的按照权重比例来计算 |
| | |
| | | rate = round(canceled_num / total_num, 3) |
| | | return rate, canceled_data_indexes, (before_nums_info, before_canceled_nums_info) |
| | | |
| | | def __compute_need_cancel(self, code, buy_exec_index, start_index, end_index, total_data, is_first_code, force_compute=False): |
| | | def __compute_need_cancel(self, code, buy_exec_index, start_index, end_index, total_data, is_first_code, |
| | | force_compute=False): |
| | | """ |
| | | L后撤单; |
| | | 撤单计算规则:计算撤单比例时,将真实下单位置之后的数据按权重(离下单位最近的权重越大)加入分子,不加入分母(总囊括手数)计算 |
| | |
| | | need_compute = True |
| | | break |
| | | if force_compute: |
| | | need_compute=True |
| | | need_compute = True |
| | | if need_compute: |
| | | # =====计算本批次大卖单成交量==== |
| | | sell_nos = set() |
| | |
| | | sell_nos.add(d[0]) |
| | | total_sell_nums += d[1] |
| | | # 获取正在成交的大卖单 |
| | | dealing_sell_order_info=HuaXinSellOrderStatisticManager.get_dealing_order_info(code) |
| | | if dealing_sell_order_info and dealing_sell_order_info[2]>=299e4: |
| | | dealing_sell_order_info = HuaXinSellOrderStatisticManager.get_dealing_order_info(code) |
| | | if dealing_sell_order_info and dealing_sell_order_info[2] >= 299e4: |
| | | total_sell_nums += dealing_sell_order_info[1] |
| | | total_sell_nums=total_sell_nums//100 |
| | | total_sell_nums = total_sell_nums // 100 |
| | | except Exception as e: |
| | | l2_log.l_cancel_debug(code, f"计算总卖大单出错:{str(e)}") |
| | | |
| | | # 计算撤单比例 |
| | | watch_indexes_list = list(watch_indexes) |
| | | watch_indexes_list.sort() |
| | | canceled_num = total_sell_nums # 将成交的大卖单计入已撤金额 |
| | | canceled_num = total_sell_nums # 将成交的大卖单计入已撤金额 |
| | | # 记录撤单索引 |
| | | canceled_indexes = [] |
| | | |
| | |
| | | # 如果撤单比例设置为100%就不需要计算下单位后面的订单 |
| | | need_compute_after = abs(thresh_hold_rate - 1.00) > 0.0001 |
| | | |
| | | dealing_info = HuaXinBuyOrderManager.get_dealing_order_info(code) |
| | | for wi in watch_indexes: |
| | | cancel_data = L2DataComputeUtil.is_canceled(code, wi, total_data, canceled_buyno_map, trade_index, |
| | | cancel_data = L2DataComputeUtil.is_canceled(code, wi, total_data, canceled_buyno_map, dealing_info[0] if dealing_info else None, |
| | | deal_order_nos) |
| | | if cancel_data: |
| | | if str(wi) in after_place_order_index_dict: |
| | |
| | | @return: 是否可撤单, 撤单数据 |
| | | """ |
| | | if not deal_order_list: |
| | | return False |
| | | return False,'' |
| | | # 添加成交量 |
| | | if code not in self.__total_big_sell_order_list_cache: |
| | | self.__total_big_sell_order_list_cache[code] = [] |
| | |
| | | |
| | | # 计算是否可撤单 |
| | | total_datas = local_today_datas.get(code) |
| | | return self.__compute_need_cancel(code, 0, total_datas[-1]["index"], total_datas[-1]["index"], total_datas, True, force_compute=True) |
| | | return self.__compute_need_cancel(code, 0, total_datas[-1]["index"], total_datas[-1]["index"], total_datas, |
| | | True, force_compute=True) |
| | | |
| | | # L后是否还有可能撤单 |
| | | def __is_l_down_can_cancel(self, code, buy_exec_index): |
| | |
| | | return end_index |
| | | |
| | | @classmethod |
| | | def is_canceled(cls, code, index, total_datas, canceled_buyno_map, trade_index, deal_order_nos): |
| | | def is_canceled(cls, code, index, total_datas, canceled_buyno_map, dealing_buy_order_no, deal_order_nos): |
| | | """ |
| | | 是否已经撤单 |
| | | @param deal_order_nos: 成交大单集合 |
| | | @param trade_index: 成交进度位 |
| | | @param dealing_buy_order_no: 正在成交的买单号 |
| | | @param index: 索引 |
| | | @param code: 代码 |
| | | @param total_datas: |
| | |
| | | # 已经撤单 |
| | | return cancel_data |
| | | else: |
| | | if trade_index and trade_index > index: |
| | | # 正在成交的买单号大于挂的买单 |
| | | orderNo = total_datas[index]['val']['orderNo'] |
| | | if dealing_buy_order_no and orderNo < dealing_buy_order_no: |
| | | # 成交进度大于索引位置,且还没成交 |
| | | if total_datas[index]["val"]["orderNo"] not in deal_order_nos: |
| | | if orderNo not in deal_order_nos: |
| | | return total_datas[index] |
| | | return None |
| | |
| | | if code in yesterday_codes: |
| | | continue |
| | | |
| | | if l2_trade_util.is_in_forbidden_trade_codes(code) and code not in deal_codes: |
| | | # 拉黑但是没成交 |
| | | continue |
| | | |
| | | # 人为拉黑的需要移除 |
| | | if HumanForbiddenManager().is_in_cache(code): |
| | | continue |
| | | |
| | | if not tool.is_can_buy_code(code): |
| | | continue |
| | | # (代码,名称,涨停时间,涨幅,现手,自由市值,现价) |
| | | data = [code, gpcode_manager.get_code_name(code)] |
| | | if not tool.is_can_buy_code(code): |
| | | fdatas.append(data) |
| | | continue |
| | | limit_up_time = LimitUpDataConstant.get_first_limit_up_time(code) |
| | | limit_up_price = gpcode_manager.get_limit_up_price_as_num(code) |
| | | data.append(limit_up_time) |