| | |
| | | # 扫入下单只有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 |
| | | |
| | |
| | | RDCancelBigNumComputer().set_watch_indexes(code, radical_result[4]) |
| | | return |
| | | else: |
| | | radical_result = cls.__compute_radical_order_begin_pos_for_many_sell(code, compute_start_index, compute_end_index) |
| | | radical_result = cls.__compute_radical_order_begin_pos_for_many_sell(code, compute_start_index, |
| | | compute_end_index) |
| | | if radical_result[0]: |
| | | buy_single_index, buy_exec_index = radical_result[0][0], radical_result[0][1] |
| | | buy_volume_rate = cls.volume_rate_info[code][0] |
| | |
| | | limit_up_price = gpcode_manager.get_limit_up_price_as_num(code) |
| | | bigger_money = l2_data_util.get_big_money_val(limit_up_price, tool.is_ge_code(code)) |
| | | min_num = int(bigger_money / limit_up_price / 100) |
| | | refer_sell_data = L2MarketSellManager().get_refer_sell_data(code, radical_data[3]) |
| | | # 参考总卖额 |
| | | refer_sell_money = 0 |
| | | if refer_sell_data: |
| | | refer_sell_money = refer_sell_data[1] |
| | | big_order_deal_enough_result = radical_buy_data_manager.is_big_order_deal_enough(code, |
| | | code_volumn_manager.CodeVolumeManager().get_volume_rate_refer_in_5days( |
| | | code), |
| | | refer_sell_money, |
| | | for_buy=True, |
| | | is_almost_open_limit_up= |
| | | radical_data[5]) |
| | | # 缺乏的大单金额 |
| | | lack_money = big_order_deal_enough_result[3] |
| | | # 如果有大单成交就不需要看大单 |
| | | if constant.CAN_RADICAL_BUY_NEED_BIG_ORDER_EVERYTIME: |
| | | # 每次下单都需要大单 |
| | | current_big_order_deal_money_info = EveryLimitupBigDealOrderManager.get_big_buy_deal_order_money_info( |
| | | code) |
| | | if current_big_order_deal_money_info and tool.trade_time_sub(tool.get_now_time_str(), |
| | | current_big_order_deal_money_info[1]) > 60: |
| | | # 60s以上就不下单了 |
| | | return False, None, "距离上次统计大单时间过去60s", set() |
| | | |
| | | if lack_money == 0: |
| | | if not tool.is_sh_code(code): |
| | | # 非上证的票看50w |
| | | min_num = int(5000 / limit_up_price) |
| | | # 需要监听的大单 |
| | | watch_indexes = set() |
| | | # 总委托大单金额 |
| | | total_delegating_big_money = 0 |
| | | single_index = None |
| | | # 从成交进度位开始看 |
| | | trade_index, is_default = cls.__TradeBuyQueue.get_traded_index(code) |
| | | if trade_index is None: |
| | | trade_index = 0 |
| | | canceled_buyno_map = local_today_canceled_buyno_map.get(code) |
| | | for i in range(trade_index, end_index + 1): |
| | | data = total_datas[i] |
| | | val = data["val"] |
| | | if not L2DataUtil.is_limit_up_price_buy(val): |
| | | continue |
| | | if val["num"] < min_num: |
| | | continue |
| | | # 撤单不算 |
| | | left_count = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count_v2(code, i, |
| | | total_datas, |
| | | canceled_buyno_map) |
| | | if left_count == 0: |
| | | continue |
| | | |
| | | # 上证有可能是部分成交的大单 |
| | | if i == start_index and tool.is_sh_code(code): |
| | | dealing_active_order_info = HuaXinBuyOrderManager().get_dealing_active_order_info(code) |
| | | if dealing_active_order_info and dealing_active_order_info[0] == int(val["orderNo"]): |
| | | # 判断是否为大单 |
| | | order_money = dealing_active_order_info[2] + round(val["price"], 2) * val["num"] * 100 |
| | | if order_money >= bigger_money: |
| | | lack_money -= order_money |
| | | watch_indexes.add(i) |
| | | if lack_money < 0: |
| | | single_index = i |
| | | break |
| | | |
| | | if int(val["orderNo"]) <= radical_data[1]: |
| | | # 主动买单后的数据不算 |
| | | continue |
| | | watch_indexes.add(i) |
| | | lack_money -= round(val["price"], 2) * val["num"] * 100 |
| | | if lack_money < 0: |
| | | single_index = i |
| | | break |
| | | if single_index is not None: |
| | | return True, single_index, "有大单", watch_indexes |
| | | return False, None, f"大单不足:{trade_index}-{end_index} 缺少的大单-{lack_money}", watch_indexes |
| | | |
| | | def __can_order_v2(): |
| | | # 判断是否是板上放量 |
| | | if cls.__is_at_limit_up_buy(code, start_index): |
| | | return False, None, "板上放量", None |
| | | total_datas = local_today_datas[code] |
| | | limit_up_price = gpcode_manager.get_limit_up_price_as_num(code) |
| | | bigger_money = l2_data_util.get_big_money_val(limit_up_price, tool.is_ge_code(code)) |
| | | min_num = int(bigger_money / limit_up_price / 100) |
| | | # 统计委托大买单 |
| | | bigger_money_delegate_list = [] |
| | | for i in range(start_index, end_index + 1): |
| | | val = total_datas[i] |
| | | if val["num"] < min_num: |
| | | continue |
| | | if not L2DataUtil.is_limit_up_price_buy(val): |
| | | continue |
| | | bigger_money_delegate_list.append( |
| | | (val["orderNo"], int(float(val["price"]) * val["num"] * 100), val["time"])) |
| | | radical_buy_data_manager.EveryLimitupBigDelegateOrderManager.add_big_buy_order_delegate(code, |
| | | bigger_money_delegate_list) |
| | | |
| | | refer_sell_data = L2MarketSellManager().get_refer_sell_data(code, radical_data[3]) |
| | | # 参考总卖额 |
| | |
| | | # 板上放量可扫入 |
| | | if t.time() > radical_data[0] and not is_radical_buy: |
| | | # 没扫入过才需要判断时间 |
| | | radical_buy_data_manager.EveryLimitupBigDelegateOrderManager.clear(code, '超过生效时间') |
| | | return False, None, "超过生效时间" |
| | | else: |
| | | # 板上放量不可扫入 |
| | | if t.time() > radical_data[0]: |
| | | radical_buy_data_manager.EveryLimitupBigDelegateOrderManager.clear(code, '超过生效时间') |
| | | return False, None, "超过生效时间" |
| | | |
| | | result = __can_order() |
| | | result = __can_order_v2() |
| | | l2_log.debug(code, f"L2扫入判断:{result}") |
| | | if result[0]: |
| | | # 已经扫入下过单且允许板上放量扫入的就需要判断板上放量的距离 |
| | |
| | | @param end_index: |
| | | @return: 信号信息(信号位,执行位), 消息, 可买入的板块 |
| | | """ |
| | | if True: |
| | | return None, "暂不生效", None |
| | | if not tool.is_sz_code(code): |
| | | return None, "非深证的票", None |
| | | # 判断抛压是否大于5000w |