L后重新囊括条件修改/真实下单位修改/下单的拆单方式修改
| | |
| | | from log_module import async_log_util |
| | | from third_data import code_plate_key_manager |
| | | from trade.buy_radical import radical_buy_data_manager |
| | | from trade.buy_radical.radical_buy_data_manager import BeforeSubDealBigOrderManager |
| | | |
| | | from utils import tool |
| | | from l2.transaction_progress import TradeBuyQueue |
| | |
| | | cancel_result = self.__need_cancel_for_slow_sell(code, total_datas) |
| | | if cancel_result[0]: |
| | | return True, f"S慢砸:{cancel_result[1]}" |
| | | |
| | | if total_deal_money >= 100 * 10000: |
| | | # 卖金额>=均大单才触发重新囊括 |
| | | THRESHOLD_MONEY, is_temp_threshold_money = BeforeSubDealBigOrderManager().get_big_order_threshold_info(code) |
| | | if total_deal_money >= THRESHOLD_MONEY: |
| | | l2_log.s_cancel_debug(code, "准备更新L后囊括") |
| | | start_order_no = big_sell_order_info[1][-1][4][1] |
| | | latest_deal_time_ms = l2_huaxin_util.convert_time(big_sell_order_info[1][-1][4][0], with_ms=True) |
| | |
| | | @classmethod |
| | | def __compute_real_place_order_position(cls, code, exec_data, oredr_info_list, add_datas): |
| | | THRESHOLD_MS = 20 if tool.is_sz_code(code) else 100 |
| | | exec_time_with_ms = L2DataUtil.get_time_with_ms(exec_data["val"]) |
| | | # 获取下单的量 |
| | | target_volumes = [x[0] // 100 for x in oredr_info_list] |
| | | volumes_info_list = [] |
| | | |
| | | current_delegates = huaxin_trade_record_manager.DelegateRecordManager().list_current_delegates(code) |
| | | # 下单量对应的委托时间 |
| | | current_delegate_place_order_time_dict = {} |
| | |
| | | if max_sub_time > THRESHOLD_MS: |
| | | continue |
| | | # 最大的时间差,最大的索引差, 数据 |
| | | match_list.append((max_sub_time, max_sub_index, temp_volumes_info_list[0][2])) |
| | | # 深证与执行位置相差时间>=10ms以上,上证与执行位置相差时间>=100ms以上 |
| | | data_ = temp_volumes_info_list[0][2] |
| | | MIN_SPCE_MS = 100 if tool.is_sh_code(code) else 10 |
| | | if tool.trade_time_sub_with_ms(L2DataUtil.get_time_with_ms(data_["val"]), exec_time_with_ms) < MIN_SPCE_MS: |
| | | continue |
| | | match_list.append((max_sub_time, max_sub_index, data_)) |
| | | if not match_list: |
| | | # 没有找到真实下单位 |
| | | return None |
| | |
| | | from l2.place_order_single_data_manager import L2TradeSingleDataProcessor |
| | | from log_module import async_log_util, log_export |
| | | from third_data import kpl_data_manager, block_info |
| | | from third_data.kpl_data_constant import LimitUpDataConstant |
| | | from trade.buy_radical.radical_buy_data_manager import EveryLimitupBigDealOrderManager |
| | | from utils import global_util, tool, buy_condition_util, buy_strategy_util, trade_util |
| | | import l2_data_util |
| | |
| | | average_rate = cls.__Buy1PriceManager.get_average_rate(code) |
| | | if average_rate : |
| | | if tool.is_ge_code(code): |
| | | if average_rate <= 0.1: |
| | | return False, True, f"均价涨幅({average_rate})小于10%", True |
| | | if average_rate <= 0.07: |
| | | return False, True, f"均价涨幅({average_rate})小于7%", True |
| | | else: |
| | | if average_rate <= 0.05: |
| | | return False, True, f"均价涨幅({average_rate})小于5%", True |
| | | |
| | | if average_rate <= 0.03: |
| | | return False, True, f"均价涨幅({average_rate})小于3%", True |
| | | return True, False, f"", False |
| | | |
| | | @classmethod |
| | |
| | | def __buy(cls, code, capture_timestamp, last_data, last_data_index, is_first_code, block_info=None): |
| | | pre_result = cls.__is_pre_can_buy(code) |
| | | if not pre_result[0]: |
| | | l2_log.debug(code, "不可以下单,原因:{}", pre_result[2]) |
| | | return False |
| | | # 添加买入锁 |
| | | if code not in cls.__buy_lock_dict: |
| | |
| | | if refer_sell_data: |
| | | refer_sell_money = refer_sell_data[1] |
| | | # 大单判断结果 |
| | | history_limit_up_codes = LimitUpDataConstant.get_history_limit_up_codes() |
| | | if history_limit_up_codes is None: |
| | | history_limit_up_codes = set() |
| | | 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) |
| | | for_buy=True, is_first_limit_up = code not in history_limit_up_codes) |
| | | # 缺乏的大单金额 |
| | | lack_money = big_order_deal_enough_result[3] |
| | | # 如果有大单成交就不需要看大单 |
| | |
| | | rate = int((volumes_data[0]["close"] - min_price) * 100 / min_price) |
| | | cls.__k_max_rate[code] = rate |
| | | return cls.__k_datas.get(code) |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | | datas = LatestLimitUpBlockManager().statistics_limit_up_block_infos() |
| | | print(datas) |
| | |
| | | if total_volume_unit_100 % 2 == 0: |
| | | return 100 * (total_volume_unit_100 // 2 - 1), 100 * (total_volume_unit_100 // 2 + 1) |
| | | else: |
| | | return 100 * (total_volume_unit_100 // 2), 100 * (total_volume_unit_100 // 2 + 1) |
| | | # 防止与同花顺等交易平台拆单相似 |
| | | return 100 * (total_volume_unit_100 // 2 - 1), 100 * (total_volume_unit_100 // 2 + 1 + 1) |
| | | |
| | | |
| | | if __name__ == '__main__': |
| | |
| | | return total_lack_money, deal_big_order_money, TOTAL_BIG_DEAL_MONEY_THRESHOLD_MONEY |
| | | |
| | | |
| | | def is_big_order_deal_enough(code, volume_rate, refer_total_sell_money, for_buy=False): |
| | | def is_big_order_deal_enough(code, volume_rate, refer_total_sell_money, for_buy=False, is_first_limit_up=False): |
| | | """ |
| | | 大单成交是否足够 |
| | | @param refer_total_sell_money: 引用的总卖额 |
| | | @param code: |
| | | @param volume_rate: |
| | | @param for_buy: 是否是下单 |
| | | @param is_first_limit_up: 是否是首封下单 |
| | | @return: 大单是否足够, 原因, 是否是短时生效, 还差的金额 |
| | | """ |
| | | limit_up_price = gpcode_manager.get_limit_up_price_as_num(code) |
| | |
| | | current_lack_money = max(0, int(current_threshold_money - current_big_order_deal_money)) |
| | | if for_buy and not tool.is_ge_code(code): |
| | | # 要下单的且不是创业版的目标代码大单数量打8折 |
| | | total_lack_money = int(total_threshold_money * 0.8 - total_deal_money) |
| | | if is_first_limit_up: |
| | | # 首封不打折 |
| | | total_lack_money = int(total_threshold_money - total_deal_money) |
| | | else: |
| | | total_lack_money = int(total_threshold_money * 0.8 - total_deal_money) |
| | | if total_lack_money < 0: |
| | | total_lack_money = 0 |
| | | if current_lack_money == 0 and total_lack_money == 0: |