| | |
| | | F_CANCEL_CACEL_RATE = 0.69 |
| | | |
| | | # G撤单 |
| | | G_CANCEL_RATE = 0.3 |
| | | G_CANCEL_RATE = 0.39 |
| | | |
| | | |
| | | # 华鑫L2的卡位数量 |
| | |
| | | from utils.tool import CodeDataCacheUtil |
| | | |
| | | |
| | | def set_real_place_position(code, index, buy_single_index=None): |
| | | def set_real_place_position(code, index, buy_single_index=None, is_default = True): |
| | | # DCancelBigNumComputer().set_real_order_index(code, index) |
| | | SecondCancelBigNumComputer().set_real_place_order_index(code, index) |
| | | LCancelBigNumComputer().set_real_place_order_index(code, index, buy_single_index=buy_single_index) |
| | | HourCancelBigNumComputer().set_real_place_order_index(code, index, buy_single_index) |
| | | GCancelBigNumComputer().set_real_place_order_index(code, index, buy_single_index) |
| | | GCancelBigNumComputer().set_real_place_order_index(code, index, buy_single_index, is_default) |
| | | FCancelBigNumComputer().set_real_order_index(code, index) |
| | | |
| | | |
| | |
| | | |
| | | # 计算L后还没成交的手数 |
| | | def __compute_total_l_down_not_deal_num(self, code): |
| | | # 只有真实获取到下单位置后才开始计算 |
| | | |
| | | |
| | | try: |
| | | if code in self.__total_l_down_not_deal_num_dict and time.time() - \ |
| | | self.__total_l_down_not_deal_num_dict[code][ |
| | |
| | | limit_up_price = float(gpcode_manager.get_limit_up_price(code)) |
| | | deal_money = limit_up_price * orgin_deal_data[0] |
| | | if deal_money >= constant.L_CANCEL_FAST_DEAL_MIN_MONEY: |
| | | return True, f"达到撤单比例:{rate}/{threshold_rate} 成交详情:{ orgin_deal_data[0]}/{total_l_down_not_deal_num[0]*100}" |
| | | return True, f"达到撤单比例:{rate}/{threshold_rate} 成交详情:{ orgin_deal_data}/{total_l_down_not_deal_num}" |
| | | else: |
| | | return False, f"已达到撤单比例,未达到撤单金额:{deal_money}" |
| | | else: |
| | |
| | | cls.__instance = super(GCancelBigNumComputer, cls).__new__(cls, *args, **kwargs) |
| | | return cls.__instance |
| | | |
| | | def set_real_place_order_index(self, code, index, buy_single_index): |
| | | self.__real_place_order_index_dict[code] = index |
| | | def set_real_place_order_index(self, code, index, buy_single_index, is_default): |
| | | self.__real_place_order_index_dict[code] = (index, is_default) |
| | | start_index = buy_single_index |
| | | if code in self.__trade_progress_index_dict: |
| | | start_index = self.__trade_progress_index_dict.get(code) |
| | | self.__commpute_watch_indexes(code, start_index, index, from_real_order_index_changed=True) |
| | | self.__commpute_watch_indexes(code, start_index, (index, is_default), from_real_order_index_changed=True) |
| | | |
| | | def clear(self, code=None): |
| | | if code: |
| | |
| | | self.__trade_progress_index_dict.clear() |
| | | self.__watch_indexes_by_dict.clear() |
| | | |
| | | def __commpute_watch_indexes(self, code, traded_index, real_order_index, from_real_order_index_changed=False): |
| | | if traded_index is None or real_order_index is None: |
| | | def __commpute_watch_indexes(self, code, traded_index, real_order_index_info, from_real_order_index_changed=False): |
| | | if traded_index is None or real_order_index_info is None: |
| | | return |
| | | real_order_index, is_default = real_order_index_info[0],real_order_index_info[1] |
| | | origin_watch_index = self.__watch_indexes_dict.get(code) |
| | | if origin_watch_index is None: |
| | | origin_watch_index = set() |
| | |
| | | # 在成交位置之后 |
| | | need_find_by = False |
| | | break |
| | | if need_find_by: |
| | | if need_find_by and not is_default: |
| | | l2_log.g_cancel_debug(code, f"启动小单备用监听:{start_index}-{real_order_index}") |
| | | temp_list = [] |
| | | for i in range(start_index, real_order_index): |
| | |
| | | def need_cancel(self, code, buy_exec_index, start_index, end_index): |
| | | if code not in self.__real_place_order_index_dict: |
| | | return False, None, "没有找到真实下单位" |
| | | real_place_order_index = self.__real_place_order_index_dict.get(code) |
| | | real_place_order_index, is_default = self.__real_place_order_index_dict.get(code) |
| | | total_datas = local_today_datas.get(code) |
| | | # 30s内有效 |
| | | if tool.trade_time_sub(total_datas[end_index]["val"]["time"], total_datas[buy_exec_index]["val"]["time"]) > 15: |
| | |
| | | buy_index in watch_indexes or buy_index in watch_indexes_by): |
| | | if buy_index in watch_indexes_by: |
| | | # 备用撤单,直接撤 |
| | | return True, data, "次大单撤" |
| | | return True, data, f"次大单撤:{buy_index}" |
| | | elif buy_index in watch_indexes: |
| | | # 大单撤需要重新计算大单撤单比例 |
| | | need_compute = True |
| | | break |
| | | if need_compute: |
| | | if need_compute and watch_indexes: |
| | | canceled_indexes = set() |
| | | for index in watch_indexes: |
| | | cancel_data = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_canceled_data_v2(code, index, |
| | |
| | | def set_real_place_order_index(cls, code, index, order_begin_pos: OrderBeginPosInfo): |
| | | trade_record_log_util.add_real_place_order_position_log(code, index, order_begin_pos.buy_single_index) |
| | | l2_log.debug(code, "设置真实下单位:{}", index) |
| | | cancel_buy_strategy.set_real_place_position(code, index, order_begin_pos.buy_single_index) |
| | | cancel_buy_strategy.set_real_place_position(code, index, order_begin_pos.buy_single_index,is_default = False) |
| | | |
| | | # 处理华鑫L2数据 |
| | | @classmethod |
| | |
| | | trade_result_manager.real_buy_success(code, cls.__TradePointManager) |
| | | l2_log.debug(code, "处理买入成功1") |
| | | cancel_buy_strategy.set_real_place_position(code, local_today_datas.get(code)[-1]["index"], |
| | | order_begin_pos.buy_single_index) |
| | | order_begin_pos.buy_single_index,is_default=True) |
| | | l2_log.debug(code, "处理买入成功2") |
| | | params_desc = cls.__l2PlaceOrderParamsManagerDict[code].get_buy_rank_desc() |
| | | l2_log.debug(code, params_desc) |
| | |
| | | # 独苗 |
| | | if not can_buy_result[0] and can_buy_result[1]: |
| | | msg_list.append("独苗") |
| | | if not is_best_zylt: |
| | | if not is_better_zylt: |
| | | # 如果没有辨识度才不买 |
| | | if not is_special: |
| | | return False, True, f"强势10分钟,无辨识度, 独苗({can_buy_result[4]})不下单({can_buy_result[4]})自由流通市值({zyltgb_as_yi})不是特优市值" |
| | |
| | | from msg import push_msg_manager |
| | | from trade import current_price_process_manager, trade_manager |
| | | from trade.deal_big_money_manager import DealOrderNoManager |
| | | from utils import tool |
| | | |
| | | |
| | | class HuaXinTransactionDatasProcessor: |
| | |
| | | except Exception as e: |
| | | async_log_util.error(hx_logger_l2_debug, str(e)) |
| | | try: |
| | | cresult = LCancelBigNumComputer().add_transaction_datas(code, datas) |
| | | if cresult[0]: |
| | | L2TradeDataProcessor.cancel_buy(code, f"L后成交太快撤单:{cresult[1]}") |
| | | order_begin_pos = None |
| | | # 下单2s后才开始生效 |
| | | if tool.trade_time_sub(total_datas[-1]["val"]["time"],total_datas[order_begin_pos.buy_exec_index]["val"]["time"]) > 2: |
| | | cresult = LCancelBigNumComputer().add_transaction_datas(code, datas) |
| | | if cresult[0]: |
| | | L2TradeDataProcessor.cancel_buy(code, f"L后成交太快撤单:{cresult[1]}") |
| | | order_begin_pos = None |
| | | except Exception as e: |
| | | async_log_util.error(hx_logger_l2_debug, str(e)) |
| | | |
| | |
| | | order.code) |
| | | cancel_buy_strategy.set_real_place_position(order.code, |
| | | new_place_order_index, |
| | | order_begin_pos.buy_single_index) |
| | | order_begin_pos.buy_single_index, is_default=True) |
| | | trade_record_log_util.add_real_place_order_position_log(order.code, |
| | | new_place_order_index, |
| | | order_begin_pos.buy_single_index) |
| | |
| | | if order_begin_pos is None or order_begin_pos.buy_exec_index is None or order_begin_pos.buy_exec_index < 0: |
| | | raise Exception("尚未下单") |
| | | cancel_buy_strategy.set_real_place_position(code, real_order_index, |
| | | buy_single_index=order_begin_pos.buy_single_index) |
| | | buy_single_index=order_begin_pos.buy_single_index,is_default=False) |
| | | result = {"code": 0, "data": {}} |
| | | self.send_response(result, client_id, request_id) |
| | | elif ctype == "get_positions": |