L后不足5笔撤单/建比>=40%时才采用新的下单方式
| | |
| | | |
| | | # 设置真实下单位置 |
| | | def set_real_place_order_index(self, code, index, buy_single_index=None, is_default=False): |
| | | """ |
| | | 设置真实下单位置 |
| | | @param code: |
| | | @param index: |
| | | @param buy_single_index: |
| | | @param is_default: |
| | | @return: 是否需要撤单, 撤单原因 |
| | | """ |
| | | l2_log.l_cancel_debug(code, f"设置真实下单位-{index},buy_single_index-{buy_single_index}") |
| | | self.__real_place_order_index_dict[code] = (index, is_default) |
| | | RedisUtils.setex_async(self.__db, f"l_cancel_real_place_order_index-{code}", tool.get_expire(), |
| | |
| | | if buy_single_index is not None: |
| | | # L后撤从成交进度位开始计算 |
| | | self.compute_watch_index(code, buy_single_index, trade_index, index) |
| | | self.__compute_trade_progress_near_by_indexes(code, buy_single_index, trade_index, index) |
| | | # 设置非默认的真实下单位时,下单1分钟内,L后不足5笔就撤单 |
| | | if not is_default: |
| | | total_datas = local_today_datas.get(code) |
| | | if tool.trade_time_sub(total_datas[-1]['val']['time'], total_datas[index]['val']['time']) < 60: |
| | | watch_index_info = self.__cancel_watch_index_info_cache.get(code) |
| | | if watch_index_info and len(watch_index_info) >= 3 and len(watch_index_info[2]) < 5: |
| | | # 撤单 |
| | | return True, "L后囊括不足5笔" |
| | | return False, "" |
| | | |
| | | # 重新计算L前 |
| | | def re_compute_l_up_watch_indexes(self, code, buy_single_index): |
| | |
| | | |
| | | from utils import tool, trade_util |
| | | from l2.transaction_progress import TradeBuyQueue |
| | | from trade import trade_queue_manager, l2_trade_factor, trade_manager, trade_data_manager |
| | | from trade import trade_queue_manager, l2_trade_factor, trade_manager, trade_data_manager, trade_constant |
| | | from l2 import l2_log, l2_data_source_util, code_price_manager |
| | | from l2.l2_data_util import L2DataUtil, local_today_num_operate_map, local_today_datas, local_today_buyno_map, \ |
| | | local_today_canceled_buyno_map |
| | |
| | | |
| | | |
| | | def set_real_place_position(code, index, buy_single_index=None, is_default=True): |
| | | """ |
| | | 设置真实下单位置 |
| | | @param code: |
| | | @param index: |
| | | @param buy_single_index: |
| | | @param is_default: |
| | | @return: 撤单类型, 撤单原因 |
| | | """ |
| | | # DCancelBigNumComputer().set_real_order_index(code, index) |
| | | s_l_h_cancel_strategy.SCancelBigNumComputer().set_real_place_order_index(code, index, is_default) |
| | | s_l_h_cancel_strategy.LCancelBigNumComputer().set_real_place_order_index(code, index, |
| | | buy_single_index=buy_single_index, |
| | | is_default=is_default) |
| | | need_cancel, cancel_msg = s_l_h_cancel_strategy.LCancelBigNumComputer().set_real_place_order_index(code, index, |
| | | buy_single_index=buy_single_index, |
| | | is_default=is_default) |
| | | if need_cancel: |
| | | return trade_constant.CANCEL_TYPE_L, cancel_msg |
| | | s_l_h_cancel_strategy.HourCancelBigNumComputer().set_real_place_order_index(code, index, buy_single_index) |
| | | NewGCancelBigNumComputer().set_real_place_order_index(code, index, buy_single_index, is_default) |
| | | FCancelBigNumComputer().set_real_order_index(code, index, is_default) |
| | | JCancelBigNumComputer().set_real_place_order_index(code, index, buy_single_index, is_default) |
| | | NBCancelBigNumComputer().set_real_place_order_index(code, index, buy_single_index, is_default) |
| | | RDCancelBigNumComputer().set_real_place_order_index(code, index, buy_single_index, is_default) |
| | | return None, '' |
| | | |
| | | |
| | | class BaseCancel: |
| | |
| | | if total_datas[index]["val"]["orderNo"] not in deal_order_nos: |
| | | return True |
| | | return False |
| | | |
| | | |
| | | # ---------------------------------RD撤------------------------------- |
| | | # 扫入下单大单撤 |
| | |
| | | |
| | | max_info = LatestLimitUpMaxBuy1MoneyInfoManager().get_latest_info(code) |
| | | if max_info and max_info[1]: |
| | | THRESHOLD_MONEY = max(max_info[1][0]*max_info[1][1]*0.8*0.1, THRESHOLD_MONEY) |
| | | THRESHOLD_MONEY = max(max_info[1][0] * max_info[1][1] * 0.8 * 0.1, THRESHOLD_MONEY) |
| | | total_left_count = 0 |
| | | total_left_num = 0 |
| | | # 成交位到真实下单位剩余的未成交的单 |
| | |
| | | from trade.buy_radical import radical_buy_data_manager, radical_buy_strategy |
| | | from l2 import l2_data_manager, l2_log, l2_data_source_util, code_price_manager, \ |
| | | transaction_progress, cancel_buy_strategy, place_order_single_data_manager |
| | | from l2.cancel_buy_strategy import LatestCancelIndexManager, NewGCancelBigNumComputer, JCancelBigNumComputer, L2DataComputeUtil, RDCancelBigNumComputer |
| | | from l2.cancel_buy_strategy import LatestCancelIndexManager, NewGCancelBigNumComputer, JCancelBigNumComputer, \ |
| | | L2DataComputeUtil, RDCancelBigNumComputer |
| | | from l2.l2_data_manager import L2DataException, OrderBeginPosInfo |
| | | from l2.l2_data_util import local_today_datas, L2DataUtil, local_today_num_operate_map, local_today_buyno_map, \ |
| | | local_latest_datas, local_today_canceled_buyno_map, local_today_sellno_map |
| | |
| | | trade_record_log_util.add_place_order_use_time(code, |
| | | f"执行位时间:{L2DataUtil.get_time_with_ms(total_datas[order_begin_pos.buy_exec_index]['val'])} 耗时:{use_time}") |
| | | l2_log.debug(code, "设置真实下单位:{}", index) |
| | | cancel_buy_strategy.set_real_place_position(code, index, order_begin_pos.buy_single_index, is_default=False) |
| | | cancel_type, cancel_msg = cancel_buy_strategy.set_real_place_position(code, index, order_begin_pos.buy_single_index, is_default=False) |
| | | # 获取真实下单位置之后需要判断F撤 |
| | | try: |
| | | cancel_result = cancel_buy_strategy.FCancelBigNumComputer().need_cancel_for_deal_fast(code) |
| | | cancel_result = False, '', None |
| | | if cancel_type: |
| | | # 要撤单 |
| | | cancel_result = True, f"{cancel_msg}", cancel_type |
| | | if not cancel_result[0]: |
| | | cancel_result = cancel_buy_strategy.FCancelBigNumComputer().need_cancel_for_deal_fast(code) |
| | | if cancel_result[0]: |
| | | cancel_result = True, f"F撤:{cancel_result[1]}", trade_constant.CANCEL_TYPE_F |
| | | if cancel_result[0]: |
| | | L2TradeDataProcessor.cancel_buy(code, f"F撤:{cancel_result[1]}", |
| | | cancel_type=trade_constant.CANCEL_TYPE_F) |
| | | L2TradeDataProcessor.cancel_buy(code, cancel_result[1], |
| | | cancel_type=cancel_result[2]) |
| | | return |
| | | else: |
| | | l2_log.f_cancel_debug(code, f"获取真实成交位的F撤未生效:{cancel_result[1]}") |
| | |
| | | return False, True, f"09:32之前不能交易", True |
| | | if 125950 < now_time_int < 130100: |
| | | # 判断大单是否足够 |
| | | deal_big_order_info = radical_buy_data_manager.get_total_deal_big_order_info(code, gpcode_manager.get_limit_up_price_as_num(code)) |
| | | deal_big_order_info = radical_buy_data_manager.get_total_deal_big_order_info(code, |
| | | gpcode_manager.get_limit_up_price_as_num( |
| | | code)) |
| | | if 5000e4 <= deal_big_order_info[5] < deal_big_order_info[1]: |
| | | pass |
| | | else: |
| | |
| | | current_deal_order_ids = big_order_deal_enough_result[7] |
| | | total_lack_money = int(big_order_deal_enough_result[6]) |
| | | |
| | | |
| | | # 如果有大单成交就不需要看大单 |
| | | if constant.CAN_RADICAL_BUY_NEED_BIG_ORDER_EVERYTIME: |
| | | # 每次下单都需要大单 |
| | |
| | | if t.time() > radical_data[0]: |
| | | return False, None, "超过生效时间" |
| | | |
| | | result = __can_order_v2() |
| | | # 根据建比来决定下单方式 |
| | | deal_big_money_info = radical_buy_data_manager.get_total_deal_big_order_info( |
| | | code, gpcode_manager.get_limit_up_price_as_num(code)) |
| | | if deal_big_money_info: |
| | | temp_rate = deal_big_money_info[1] / deal_big_money_info[5] |
| | | if temp_rate >= 0.4: |
| | | result = __can_order_v2() |
| | | else: |
| | | result = __can_order() |
| | | else: |
| | | result = __can_order() |
| | | |
| | | l2_log.debug(code, f"L2扫入判断({start_index}-{end_index}):{result}") |
| | | if result[0]: |
| | | # 已经扫入下过单且允许板上放量扫入的就需要判断板上放量的距离 |