| | |
| | | __l2PlaceOrderParamsManagerDict = {} |
| | | __last_buy_single_dict = {} |
| | | __TradeBuyQueue = transaction_progress.TradeBuyQueue() |
| | | __latest_process_unique_keys = {} |
| | | |
| | | # 获取代码评分 |
| | | @classmethod |
| | |
| | | place_order_index = huaxin_delegate_postion_manager.get_l2_place_order_position(code, datas) |
| | | if place_order_index: |
| | | logger_l2_process.info("code:{} 获取到下单真实位置:{}", code, place_order_index) |
| | | DCancelBigNumComputer.set_real_order_index(code, place_order_index) |
| | | DCancelBigNumComputer().set_real_order_index(code, place_order_index) |
| | | __start_time = round(t.time() * 1000) |
| | | if len(datas) > 0: |
| | | cls.process_add_datas(code, datas, 0, __start_time) |
| | |
| | | # 处理已挂单 |
| | | @classmethod |
| | | def __process_order(cls, code, start_index, end_index, capture_time, is_first_code, new_add=True): |
| | | # 增加推出机制 |
| | | unique_key = f"{start_index}-{end_index}" |
| | | if cls.__latest_process_unique_keys.get(code) == unique_key: |
| | | logger_l2_error.error(f"重复处理数据:code-{code} start_index-{start_index} end_index-{end_index}") |
| | | return |
| | | cls.__latest_process_unique_keys[code] = unique_key |
| | | |
| | | # 计算安全笔数 |
| | | @dask.delayed |
| | | def compute_safe_count(): |
| | |
| | | _start_time = round(t.time() * 1000) |
| | | # S撤单计算,看秒级大单撤单 |
| | | try: |
| | | b_need_cancel, b_cancel_data = SecondCancelBigNumComputer.need_cancel(code, buy_single_index, |
| | | buy_exec_index, start_index, |
| | | end_index, total_data, |
| | | code_volumn_manager.get_volume_rate_index( |
| | | buy_volume_rate), |
| | | cls.volume_rate_info[code][1], |
| | | is_first_code) |
| | | b_need_cancel, b_cancel_data = SecondCancelBigNumComputer().need_cancel(code, buy_single_index, |
| | | buy_exec_index, start_index, |
| | | end_index, total_data, |
| | | code_volumn_manager.get_volume_rate_index( |
| | | buy_volume_rate), |
| | | cls.volume_rate_info[code][1], |
| | | is_first_code) |
| | | if b_need_cancel: |
| | | return b_cancel_data, "S大单撤销比例触发阈值" |
| | | except Exception as e: |
| | |
| | | def h_cancel(): |
| | | _start_time = round(t.time() * 1000) |
| | | try: |
| | | b_need_cancel, b_cancel_data = HourCancelBigNumComputer.need_cancel(code, buy_single_index, |
| | | b_need_cancel, b_cancel_data = HourCancelBigNumComputer().need_cancel(code, buy_single_index, |
| | | buy_exec_index, start_index, |
| | | end_index, total_data, |
| | | local_today_num_operate_map.get( |
| | |
| | | def l_cancel(): |
| | | _start_time = round(t.time() * 1000) |
| | | try: |
| | | b_need_cancel, b_cancel_data = LCancelBigNumComputer.need_cancel(code, |
| | | b_need_cancel, b_cancel_data = LCancelBigNumComputer().need_cancel(code, |
| | | buy_exec_index, start_index, |
| | | end_index, total_data, |
| | | local_today_num_operate_map.get( |
| | |
| | | trade_price = current_price_process_manager.get_trade_price(code) |
| | | if trade_price is None: |
| | | return False, True, f"尚未获取到当前成交价" |
| | | if float(limit_up_price) - float(trade_price) > 0.02001: |
| | | return False, False, f"当前成交价({trade_price})尚未在2档及以内" |
| | | if float(limit_up_price) - float(trade_price) > 0.04001: |
| | | return False, False, f"当前成交价({trade_price})尚未在4档及以内" |
| | | |
| | | # 判断成交进度是否距离我们的位置很近 |
| | | total_data = local_today_datas.get(code) |
| | |
| | | # 之前没有涨停过 |
| | | # 统计买入信号位到当前位置没有撤的大单金额 |
| | | min_money_w = l2_data_util.get_big_money_val(float(total_data[buy_single_index]["val"]["price"])) // 10000 |
| | | left_big_num = l2.cancel_buy_strategy.SecondCancelBigNumComputer.compute_left_big_num(code, |
| | | buy_single_index, |
| | | buy_exec_index, |
| | | total_data[-1][ |
| | | "index"], |
| | | total_data, |
| | | 0, min_money_w) |
| | | left_big_num = l2.cancel_buy_strategy.SecondCancelBigNumComputer().compute_left_big_num(code, |
| | | buy_single_index, |
| | | buy_exec_index, |
| | | total_data[-1][ |
| | | "index"], |
| | | total_data, |
| | | 0, min_money_w) |
| | | if left_big_num > 0: |
| | | # 重新获取分数与分数索引 |
| | | limit_up_time = limit_up_time_manager.LimitUpTimeManager().get_limit_up_time_cache(code) |
| | |
| | | |
| | | # 数据是否处理完毕 |
| | | if compute_index >= compute_end_index: |
| | | need_cancel, cancel_data = SecondCancelBigNumComputer.need_cancel(code, buy_single_index, |
| | | compute_index, |
| | | buy_single_index, compute_index, |
| | | total_datas, is_first_code, |
| | | cls.volume_rate_info[code][1], |
| | | cls.volume_rate_info[code][1], |
| | | True) |
| | | need_cancel, cancel_data = SecondCancelBigNumComputer().need_cancel(code, buy_single_index, |
| | | compute_index, |
| | | buy_single_index, compute_index, |
| | | total_datas, is_first_code, |
| | | cls.volume_rate_info[code][1], |
| | | cls.volume_rate_info[code][1], |
| | | True) |
| | | _start_time = l2_data_log.l2_time(code, tool.get_now_timestamp() - _start_time, |
| | | "S级大单处理耗时", force=True) |
| | | l2_log.debug(code, "数据处理完毕,下单, 数据截图时间-{}", capture_time) |
| | |
| | | else: |
| | | cls.__buy(code, capture_time, total_datas[compute_index], compute_index, is_first_code) |
| | | else: |
| | | SecondCancelBigNumComputer.need_cancel(code, buy_single_index, compute_index, buy_single_index, |
| | | compute_index, total_datas, is_first_code, |
| | | cls.volume_rate_info[code][1], |
| | | cls.volume_rate_info[code][1], False) |
| | | SecondCancelBigNumComputer().need_cancel(code, buy_single_index, compute_index, buy_single_index, |
| | | compute_index, total_datas, is_first_code, |
| | | cls.volume_rate_info[code][1], |
| | | cls.volume_rate_info[code][1], False) |
| | | |
| | | _start_time = l2_data_log.l2_time(code, tool.get_now_timestamp() - _start_time, |
| | | "S级大单处理耗时", force=True) |