| | |
| | | # 获取撤单比例,返回(撤单比例,是否必买) |
| | | @classmethod |
| | | def get_cancel_rate(cls, code, is_up=False, is_l_down_recomputed=False, buy_mode=None): |
| | | """ |
| | | |
| | | @param code: |
| | | @param is_up: |
| | | @param is_l_down_recomputed: |
| | | @param buy_mode: |
| | | @return: 撤单比例, 是否加红, (原值,人为设置的值) |
| | | """ |
| | | try: |
| | | must_buy = cls.__MustBuyCodesManager.is_in_cache(code) |
| | | if buy_mode == OrderBeginPosInfo.MODE_RADICAL: |
| | |
| | | human_rate = 0 |
| | | if must_buy: |
| | | # 扫入加红 |
| | | return max(constant.L_CANCEL_RATE_WITH_MUST_BUY_FOR_REDICAL_BUY, human_rate), True |
| | | return max(constant.L_CANCEL_RATE_WITH_MUST_BUY_FOR_REDICAL_BUY, human_rate), True, (constant.L_CANCEL_RATE_WITH_MUST_BUY_FOR_REDICAL_BUY, human_rate) |
| | | else: |
| | | # 根据成交额的大单成交占比来计算撤单比例 |
| | | big_money_rate = radical_buy_data_manager.TotalDealBigOrderInfoManager.get_big_order_rate(code) |
| | | if big_money_rate is not None: |
| | | threshold_rate = min(big_money_rate * 3, 0.8) |
| | | return max(threshold_rate, human_rate), False |
| | | return max(threshold_rate, human_rate), False, (threshold_rate, human_rate) |
| | | else: |
| | | deal_big_order_info = radical_buy_data_manager.get_total_deal_big_order_info(code, |
| | | gpcode_manager.get_limit_up_price_as_num( |
| | |
| | | threshold_rate = 0.5 * deal_rate + 0.35 |
| | | threshold_rate = max(threshold_rate, 0.375) |
| | | threshold_rate = min(threshold_rate, 0.8) |
| | | return max(threshold_rate, human_rate), False |
| | | return max(threshold_rate, human_rate), False, (threshold_rate, human_rate) |
| | | if must_buy: |
| | | if is_up: |
| | | return constant.L_CANCEL_RATE_UP_WITH_MUST_BUY, True |
| | | return constant.L_CANCEL_RATE_UP_WITH_MUST_BUY, True, None |
| | | else: |
| | | return constant.L_CANCEL_RATE_WITH_MUST_BUY, True |
| | | return constant.L_CANCEL_RATE_WITH_MUST_BUY, True, None |
| | | except Exception as e: |
| | | async_log_util.error(logger_l2_l_cancel, str(e)) |
| | | |
| | |
| | | base_rate += deal_rate |
| | | except Exception as e: |
| | | l2_log.l_cancel_debug(code, f"计算撤单比例出错:{e}") |
| | | return round(base_rate, 2), False |
| | | return round(base_rate, 2), False, None |
| | | |
| | | # 获取L后成交太快的撤单比例 |
| | | @classmethod |
| | |
| | | # 计算监听的总条数 |
| | | total_num = 0 |
| | | max_num, max_num_count = 0, 0 |
| | | thresh_hold_rate, must_buy = LCancelRateManager.get_cancel_rate(code) |
| | | thresh_hold_rate, must_buy, cancel_rate_info = LCancelRateManager.get_cancel_rate(code) |
| | | |
| | | for wi in watch_indexes: |
| | | if str(wi) in after_place_order_index_dict: |
| | |
| | | else: |
| | | canceled_count_weight += WATCH_INDEX_WEIGHTS[-1] |
| | | rate = round(canceled_count_weight / total_count_weight, 3) |
| | | thresh_cancel_rate, must_buy = LCancelRateManager.get_cancel_rate(code, is_up=True) |
| | | thresh_cancel_rate, must_buy, cancel_rate_info = LCancelRateManager.get_cancel_rate(code, is_up=True) |
| | | l2_log.l_cancel_debug(code, f"计算范围:{start_index}-{end_index},L前已撤单比例:{rate}/{thresh_cancel_rate}") |
| | | if rate >= thresh_cancel_rate: |
| | | # 计算成交进度位置到当前下单位置的纯买额 |
| | |
| | | total_nums += val["num"] |
| | | if left_count > 0 and index < trade_index: |
| | | total_deal_nums += val["num"] |
| | | thresh_hold_rate, must_buy = LCancelRateManager.get_cancel_rate(code) |
| | | thresh_hold_rate, must_buy, cancel_rate_info = LCancelRateManager.get_cancel_rate(code) |
| | | if total_deal_nums / total_nums > 1 - thresh_hold_rate - 0.05: |
| | | return False |
| | | return True |