| | |
| | | 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: |
| | | deal_big_order_info = radical_buy_data_manager.get_total_deal_big_order_info(code, |
| | | gpcode_manager.get_limit_up_price_as_num( |
| | | code)) |
| | | # 根据成交额的大单成交占比来计算撤单比例 |
| | | 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) |
| | | if deal_big_order_info[0] <= 0: |
| | | # 大单足够,将基础比例调整至79% |
| | | threshold_rate = max(threshold_rate, 0.79) |
| | | return human_rate if human_rate > 0 else threshold_rate, False, (threshold_rate, human_rate) |
| | | else: |
| | | deal_rate = round(deal_big_order_info[1] / deal_big_order_info[2], 2) |
| | | threshold_rate = 0.5 * deal_rate + 0.35 |
| | | threshold_rate = max(threshold_rate, 0.375) |
| | | threshold_rate = min(threshold_rate, 0.8) |
| | | if deal_big_order_info[0] <= 0: |
| | | # 大单足够,将基础比例调整至79% |
| | | threshold_rate = max(threshold_rate, 0.79) |
| | | return human_rate if human_rate > 0 else threshold_rate, False, (threshold_rate, human_rate) |
| | | # deal_big_order_info = radical_buy_data_manager.get_total_deal_big_order_info(code, |
| | | # gpcode_manager.get_limit_up_price_as_num( |
| | | # code)) |
| | | # # 根据成交额的大单成交占比来计算撤单比例 |
| | | # 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) |
| | | # if deal_big_order_info[0] <= 0: |
| | | # # 大单足够,将基础比例调整至79% |
| | | # threshold_rate = max(threshold_rate, 0.79) |
| | | # return human_rate if human_rate > 0 else threshold_rate, False, (threshold_rate, human_rate) |
| | | # else: |
| | | # deal_rate = round(deal_big_order_info[1] / deal_big_order_info[2], 2) |
| | | # threshold_rate = 0.5 * deal_rate + 0.35 |
| | | # threshold_rate = max(threshold_rate, 0.375) |
| | | # threshold_rate = min(threshold_rate, 0.8) |
| | | # if deal_big_order_info[0] <= 0: |
| | | # # 大单足够,将基础比例调整至79% |
| | | # threshold_rate = max(threshold_rate, 0.79) |
| | | threshold_rate = constant.L_CANCEL_RATE |
| | | return human_rate if human_rate > 0 else threshold_rate, False, (threshold_rate, human_rate) |
| | | if must_buy: |
| | | if is_up: |
| | | return constant.L_CANCEL_RATE_UP_WITH_MUST_BUY, True, None |
| | |
| | | |
| | | L_CANCEL_MIN_WATCH_COUNT = 10 |
| | | # 撤单比例 |
| | | L_CANCEL_RATE = 0.6 # L后 |
| | | L_CANCEL_RATE = 0.39 # L后 |
| | | |
| | | L_CANCEL_RATE_WITH_MUST_BUY = 0.9 # 加红L后 |
| | | |
| | |
| | | |
| | | import constant |
| | | from cancel_strategy import s_l_h_cancel_strategy |
| | | from cancel_strategy.s_l_h_cancel_strategy import CancelRateHumanSettingManager |
| | | from code_attribute import big_money_num_manager, gpcode_manager, code_volumn_manager |
| | | import l2_data_util |
| | | from db import redis_manager_delegate as redis_manager |
| | |
| | | |
| | | # 下单3分钟内距离下单位置不足3笔(包含正在成交)且不到300w就需要撤单 |
| | | def need_cancel_for_deal_fast(self, code, trade_index=None): |
| | | # 人为改了撤单比例之后不能生效 |
| | | human_rate = CancelRateHumanSettingManager().get_l_down(code) |
| | | if human_rate: |
| | | return False, "人为修改了撤单比例" |
| | | |
| | | if trade_index is None: |
| | | trade_info = TradeBuyQueue().get_traded_index(code) |
| | | if trade_info and not trade_info[1] and trade_info[0] is not None: |
| | |
| | | # 是否是下单1分钟内 |
| | | if tool.trade_time_sub(tool.get_now_time_str(), total_datas[real_order_index]['val']['time']) > 1 * 60: |
| | | return False, "下单超过60s" |
| | | try: |
| | | if code in self.__max_buy_order_num_cache: |
| | | max_num = self.__max_buy_order_num_cache[code] |
| | | if max_num and tool.is_ge_code(code): |
| | | max_num = max_num * 6.6 |
| | | details = HuaXinSellOrderStatisticManager.get_latest_3s_continue_deal_volumes(code) |
| | | threshold_num = int(max_num * 0.5 * 100) |
| | | count = 0 |
| | | for d in details: |
| | | if d[1] > threshold_num: |
| | | count += 1 |
| | | if count >= 2: |
| | | return True, f"连续3秒有2s抛压过大:{details} 最大值:{max_num}" |
| | | except Exception as e: |
| | | l2_log.f_cancel_debug(code, f"大抛压撤单计算出错:{str(e)}") |
| | | # try: |
| | | # if code in self.__max_buy_order_num_cache: |
| | | # max_num = self.__max_buy_order_num_cache[code] |
| | | # if max_num and tool.is_ge_code(code): |
| | | # max_num = max_num * 6.6 |
| | | # details = HuaXinSellOrderStatisticManager.get_latest_3s_continue_deal_volumes(code) |
| | | # threshold_num = int(max_num * 0.5 * 100) |
| | | # count = 0 |
| | | # for d in details: |
| | | # if d[1] > threshold_num: |
| | | # count += 1 |
| | | # if count >= 2: |
| | | # return True, f"连续3秒有2s抛压过大:{details} 最大值:{max_num}" |
| | | # except Exception as e: |
| | | # l2_log.f_cancel_debug(code, f"大抛压撤单计算出错:{str(e)}") |
| | | |
| | | # 查询最近2秒成交是否超过阈值 |
| | | |
| | | THRESHOLD_MONEY_W, THRESHOLD_COUNT = self.__get_fast_deal_threshold_value(code, |
| | | total_datas[real_order_index]['val'][ |
| | | 'time']) |
| | | THRESHOLD_MONEY_W, THRESHOLD_COUNT = 1200, 3 # self.__get_fast_deal_threshold_value(code, |
| | | # total_datas[real_order_index]['val'][ |
| | | # 'time']) |
| | | |
| | | total_left_count = 0 |
| | | total_left_num = 0 |
| | |
| | | cls.__process_not_order(code, cancel_data["index"] + 1, end_index, capture_time, is_first_code) |
| | | finally: |
| | | l2_log.debug(code, "触发撤单,撤单位置:{} ,撤单原因:{}, 下单模式:{}", cancel_data["index"], cancel_msg, |
| | | f"{order_begin_pos.mode}") |
| | | f"{order_begin_pos.mode}") |
| | | else: |
| | | pass |
| | | |
| | |
| | | order_begin_pos.buy_exec_index, |
| | | local_today_datas.get(code)) |
| | | return False |
| | | l2_log.debug(code, "可以下单,原因:{}, 下单模式:{} 最小订单号:{}", reason, order_begin_pos.mode, order_begin_pos.min_order_no) |
| | | l2_log.debug(code, "可以下单,原因:{}, 下单模式:{} 最小订单号:{}", reason, order_begin_pos.mode, |
| | | order_begin_pos.min_order_no) |
| | | l2_log.debug(code, "开始执行买入") |
| | | trade_manager.start_buy(code, capture_timestamp, last_data, |
| | | last_data_index, order_begin_pos.mode, order_begin_pos.buy_exec_index) |
| | |
| | | # 扫入下单只有L撤能撤单 |
| | | if order_begin_pos and order_begin_pos.mode == OrderBeginPosInfo.MODE_RADICAL and cancel_type not in { |
| | | trade_constant.CANCEL_TYPE_L_DOWN, trade_constant.CANCEL_TYPE_L, trade_constant.CANCEL_TYPE_RD, |
| | | trade_constant.CANCEL_TYPE_P}: |
| | | trade_constant.CANCEL_TYPE_P, trade_constant.CANCEL_TYPE_F}: |
| | | l2_log.cancel_debug(code, "撤单中断,原因:{}", "扫入下单不是L撤") |
| | | return False |
| | | # 加绿只有L撤/人撤生效 |
| | | if gpcode_manager.GreenListCodeManager().is_in_cache(code): |
| | | if cancel_type not in {trade_constant.CANCEL_TYPE_L, trade_constant.CANCEL_TYPE_L_UP, |
| | | trade_constant.CANCEL_TYPE_L_DOWN, trade_constant.CANCEL_TYPE_RD, |
| | | trade_constant.CANCEL_TYPE_P}: |
| | | trade_constant.CANCEL_TYPE_P, trade_constant.CANCEL_TYPE_F}: |
| | | l2_log.cancel_debug(code, "撤单中断,原因:{}", "加绿不是L撤") |
| | | return False |
| | | |