| | |
| | | def cancel_success(self, code): |
| | | self.clear(code) |
| | | |
| | | # 下单3分钟内距离下单位置不足3笔且不到300w就需要撤单 |
| | | def need_cancel_for_deal_fast(self, code, trade_index=None): |
| | | 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: |
| | | trade_index = trade_info[0] |
| | | if trade_index is None: |
| | | return False, "没获取到成交进度位" |
| | | |
| | | # 判断是否具有真实的下单位置 |
| | | real_order_index_info = self.__get_real_order_index_cache(code) |
| | | if not real_order_index_info: |
| | | return False, "没找到真实下单位" |
| | | if real_order_index_info[1]: |
| | | return False, "真实下单位为默认" |
| | | if real_order_index_info[0] <= trade_index: |
| | | return False, "真实下单位在成交位之前" |
| | | real_order_index = real_order_index_info[0] |
| | | # 统计未撤订单的数量与金额 |
| | | total_datas = local_today_datas.get(code) |
| | | |
| | | # 是否是下单3分钟内 |
| | | if tool.trade_time_sub(tool.get_now_time_str(), total_datas[real_order_index]['val']['time']) > 3 * 60: |
| | | return False, "下单超过180s" |
| | | |
| | | THRESHOLD_COUNT = 3 |
| | | |
| | | total_left_count = 0 |
| | | total_left_num = 0 |
| | | # 成交位到真实下单位剩余的未成交的单 |
| | | for i in range(trade_index, real_order_index_info[0]): |
| | | data = total_datas[i] |
| | | val = data["val"] |
| | | if not L2DataUtil.is_limit_up_price_buy(val): |
| | | continue |
| | | if val["num"] * float(val["price"]) < 5000: |
| | | continue |
| | | left_count = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count_v2(code, |
| | | i, |
| | | total_datas, |
| | | local_today_canceled_buyno_map.get( |
| | | code)) |
| | | if left_count > 0: |
| | | total_left_count += left_count |
| | | total_left_num += val["num"] * left_count |
| | | if total_left_count > THRESHOLD_COUNT: |
| | | break |
| | | if trade_index == i: |
| | | dealing_info = HuaXinBuyOrderManager.get_dealing_order_info(code) |
| | | if dealing_info and str(dealing_info[0]) == str(val["orderNo"]): |
| | | total_left_num -= dealing_info[1] // 100 |
| | | limit_up_price = gpcode_manager.get_limit_up_price(code) |
| | | if total_left_count <= THRESHOLD_COUNT and limit_up_price and total_left_num * float(limit_up_price) < 300 * 100: |
| | | return True, f"剩余笔数({total_left_count})/金额({round(total_left_num * float(limit_up_price) * 100)})不足,成交进度:{trade_index},真实下单位置:{real_order_index}" |
| | | return False, "不满足撤单条件" |
| | | |
| | | # 距离太近,封单不足,有大单50w大单砸下来就撤 |
| | | def need_cancel_for_p(self, code, big_sell_order_info, order_begin_pos): |
| | | if not order_begin_pos or not order_begin_pos.buy_exec_index or order_begin_pos.buy_exec_index < 0: |
| | |
| | | return True, total_datas[cancel_half_index], f"B撤:撤单索引-{cancel_half_index}" |
| | | return False, None, "还有大单没撤单" |
| | | |
| | | |
| | | def place_order_success(self, code): |
| | | self.clear(code) |
| | | |
| | | |
| | | def cancel_success(self, code): |
| | | self.clear(code) |