| | |
| | | if order_begin_pos.mode == OrderBeginPosInfo.MODE_FAST: |
| | | |
| | | threshold_money = order_begin_pos.threshold_money |
| | | new_buy_exec_index, buy_nums, buy_count, rebegin_buy_pos, threshold_money_new, not_buy_msg = cls.__sum_buy_num_for_order_fast( |
| | | new_buy_exec_index, buy_nums, buy_count, rebegin_buy_pos, threshold_money_new, max_num_set_new, not_buy_msg = cls.__sum_buy_num_for_order_fast( |
| | | code, |
| | | start_process_index, |
| | | compute_end_index, |
| | | order_begin_pos.num, |
| | | order_begin_pos.count, |
| | | threshold_money, |
| | | order_begin_pos.buy_single_index) |
| | | order_begin_pos.buy_single_index, order_begin_pos.max_num_set) |
| | | threshold_money = threshold_money_new |
| | | order_begin_pos.threshold_money = threshold_money |
| | | else: |
| | |
| | | return False, -1, "总卖为空" |
| | | if cls.__L2MarketSellManager.is_refer_sell_time_used(code, refer_sell_data[0]): |
| | | return False, -1, "总卖统计时间已被使用" |
| | | # 是否大于500万 |
| | | if refer_sell_data[1] <= 500 * 10000: |
| | | # 是否大于2000万 |
| | | if refer_sell_data[1] <= 2000 * 10000: |
| | | return False, -1, "总卖小于指定金额" |
| | | # 统计之前的卖 |
| | | threshold_money = refer_sell_data[1] |
| | |
| | | # 计算快速买入 |
| | | @classmethod |
| | | def __sum_buy_num_for_order_fast(cls, code, compute_start_index, compute_end_index, origin_num, origin_count, |
| | | threshold_money_origin, buy_single_index): |
| | | threshold_money_origin, buy_single_index, max_num_set): |
| | | _start_time = t.time() |
| | | total_datas = local_today_datas[code] |
| | | # is_first_code = gpcode_manager.FirstCodeManager().is_in_first_record_cache(code) |
| | |
| | | max_space_time_ms = 3 * 1000 |
| | | # 不下单的信息 |
| | | not_buy_msg = "" |
| | | max_buy_num_set = set(max_num_set) |
| | | place_order_count = trade_data_manager.PlaceOrderCountManager().get_place_order_count(code) |
| | | if place_order_count is None: |
| | | place_order_count = 0 |
| | | for i in range(compute_start_index, compute_end_index + 1): |
| | | data = total_datas[i] |
| | | _val = total_datas[i]["val"] |
| | |
| | | cls.__TradePointManager.delete_buy_point(code) |
| | | if i == compute_end_index: |
| | | # 数据处理完毕 |
| | | return None, buy_nums, buy_count, None, threshold_money, f"【{i}】信号不连续,囊括时间-{max_space_time_ms}ms" |
| | | return None, buy_nums, buy_count, None, threshold_money, max_buy_num_set, f"【{i}】信号不连续,囊括时间-{max_space_time_ms}ms" |
| | | else: |
| | | # 计算买入信号,不能同一时间开始计算 |
| | | for ii in range(buy_single_index + 1, compute_end_index + 1): |
| | | if total_datas[buy_single_index]["val"]["time"] != total_datas[ii]["val"]["time"]: |
| | | return None, buy_nums, buy_count, ii, threshold_money, f"【{i}】信号不连续,囊括时间-{max_space_time_ms}ms" |
| | | return None, buy_nums, buy_count, ii, threshold_money, max_buy_num_set, f"【{i}】信号不连续,囊括时间-{max_space_time_ms}ms" |
| | | if L2DataUtil.is_sell(_val): |
| | | threshold_money += _val["num"] * int(float(_val["price"]) * 100) |
| | | threshold_num = round(threshold_money / (limit_up_price * 100)) |
| | |
| | | threshold_num = round(threshold_money / (limit_up_price * 100)) |
| | | # 涨停买 |
| | | elif L2DataUtil.is_limit_up_price_buy(_val): |
| | | if l2_data_util.is_big_money(_val): |
| | | max_buy_num_set.add(i) |
| | | trigger_buy = True |
| | | # 只统计59万以上的金额 |
| | | buy_nums += int(_val["num"]) * int(total_datas[i]["re"]) |
| | |
| | | local_today_buyno_map.get( |
| | | code)) |
| | | if buy_index is not None: |
| | | |
| | | # 找到买撤数据的买入点 |
| | | if buy_index >= buy_single_index: |
| | | max_buy_num_set.discard(buy_index) |
| | | buy_nums -= int(_val["num"]) * int(data["re"]) |
| | | buy_count -= int(data["re"]) |
| | | l2_log.buy_debug(code, "{}数据在买入信号之后 撤买纯买手数:{} 目标手数:{}", i, buy_nums, threshold_num) |
| | |
| | | # 同一秒,当作买入信号之后处理 |
| | | buy_nums -= int(_val["num"]) * int(data["re"]) |
| | | buy_count -= int(data["re"]) |
| | | max_buy_num_set.discard(buy_index) |
| | | # 大单撤销 |
| | | l2_log.buy_debug(code, "{}数据买入位与预估买入位在同一秒", i) |
| | | else: |
| | |
| | | if buy_count < 5: |
| | | not_buy_msg = f"【{i}】安全笔数不足,{buy_count}/{5}" |
| | | continue |
| | | |
| | | if place_order_count == 0: |
| | | if len(max_buy_num_set) < 1: |
| | | not_buy_msg = f"【{i}】首次下单无大单" |
| | | continue |
| | | |
| | | try: |
| | | info = cls.__trade_log_placr_order_info_dict[code] |
| | | info.set_trade_factor(threshold_money, 0, []) |
| | | except Exception as e: |
| | | async_log_util.error(logger_l2_error, f"记录交易因子出错:{str(e)}") |
| | | |
| | | return i, buy_nums, buy_count, None, threshold_money, "可以下单" |
| | | return i, buy_nums, buy_count, None, threshold_money, max_buy_num_set, "可以下单" |
| | | |
| | | l2_log.buy_debug(code, "尚未获取到买入执行点(快速买入),起始计算位置:{} 统计纯买手数:{} 目标纯买手数:{} 统计纯买单数:{}", |
| | | compute_start_index, |
| | | buy_nums, |
| | | threshold_num, buy_count) |
| | | |
| | | return None, buy_nums, buy_count, None, threshold_money, not_buy_msg |
| | | return None, buy_nums, buy_count, None, threshold_money, max_buy_num_set, not_buy_msg |
| | | |
| | | |
| | | def test_trade_record(): |