11个文件已修改
1个文件已添加
438 ■■■■ 已修改文件
api/outside_api_command_callback.py 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
code_attribute/gpcode_manager.py 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
constant.py 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
data_parser/transaction_big_order_parser.py 203 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
huaxin_client/l2_client_test.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/l2_data_manager.py 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/l2_data_manager_new.py 80 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2_data_parser.py 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
servers/huaxin_trade_server.py 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/buy_radical/radical_buy_data_manager.py 68 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/buy_radical/radical_buy_strategy.py 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/trade_result_manager.py 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/outside_api_command_callback.py
@@ -344,14 +344,14 @@
                    fresult = {"code": 0, "data": datas}
            elif code_list_type == outside_api_command_manager.CODE_LIST_WHITE:
                if operate == outside_api_command_manager.OPERRATE_SET:
                    gpcode_manager.WhiteListCodeManager().add_code(code)
                    gpcode_manager.WhiteListCodeManager().add_code(code, is_human=True)
                    name = gpcode_manager.get_code_name(code)
                    if not name:
                        results = HistoryKDatasUtils.get_gp_codes_names([code])
                        if results:
                            gpcode_manager.CodesNameManager.add_first_code_name(code, results[code])
                elif operate == outside_api_command_manager.OPERRATE_DELETE:
                    gpcode_manager.WhiteListCodeManager().remove_code(code)
                    gpcode_manager.WhiteListCodeManager().remove_code(code, is_human=True)
                elif operate == outside_api_command_manager.OPERRATE_GET:
                    codes = gpcode_manager.WhiteListCodeManager().list_codes_cache()
                    datas = []
@@ -1390,7 +1390,8 @@
                                    "top_block_count_by_market_strong": constant.RADICAL_BUY_TOP_IN_COUNT_BY_MARKET_STRONG,
                                    "special_codes_max_block_in_rank": constant.RADICAL_BUY_TOP_IN_INDEX_WITH_SPECIAL,
                                    "ignore_block_in_money_market_strong": constant.IGNORE_BLOCK_IN_MONEY_MARKET_STRONG,
                                    "buy_first_limit_up": 1 if constant.CAN_BUY_FIRST_LIMIT_UP else 0
                                    "buy_first_limit_up": 1 if constant.CAN_BUY_FIRST_LIMIT_UP else 0,
                                    "can_auto_add_white": 1 if constant.CAN_AUTO_ADD_WHITE else 0
                                    }}
                self.send_response({"code": 0, "data": data, "msg": f""},
                                   client_id,
@@ -1414,6 +1415,9 @@
                    if radical_buy.get('buy_first_limit_up') is not None:
                        constant.CAN_BUY_FIRST_LIMIT_UP = True if radical_buy.get(
                            'buy_first_limit_up') else False
                    if radical_buy.get('can_auto_add_white') is not None:
                        constant.CAN_AUTO_ADD_WHITE = True if radical_buy.get(
                            'can_auto_add_white') else False
                self.send_response({"code": 0, "data": {}, "msg": f""},
                                   client_id,
code_attribute/gpcode_manager.py
@@ -401,6 +401,7 @@
class WhiteListCodeManager:
    __instance = None
    __redis_manager = redis_manager.RedisManager(2)
    __human_remove_codes = set()
    def __new__(cls, *args, **kwargs):
        if not cls.__instance:
@@ -421,14 +422,21 @@
        if data:
            self.__white_codes_cache |= data
    def add_code(self, code):
    def add_code(self, code, is_human=False):
        if not is_human and code in self.__human_remove_codes:
            # 机器加白,且被人为移白了就不能再加白
            return
        self.__white_codes_cache.add(code)
        RedisUtils.sadd(self.__get_redis(), "white_list_codes", code)
        RedisUtils.expire(self.__get_redis(), "white_list_codes", tool.get_expire())
    def remove_code(self, code):
    def remove_code(self, code, is_human=False):
        self.__white_codes_cache.discard(code)
        RedisUtils.srem(self.__get_redis(), "white_list_codes", code)
        if is_human:
            self.human_remove(code)
    def is_in(self, code):
        return RedisUtils.sismember(self.__get_redis(), "white_list_codes", code)
@@ -446,6 +454,24 @@
        self.__white_codes_cache.clear()
        RedisUtils.delete(self.__get_redis(), "white_list_codes")
    def human_remove(self, code):
        """
        人为移白
        @param code:
        @return:
        """
        self.__human_remove_codes.add(code)
    def clear_huamn_info(self, code):
        """
        移除人为干预信息
        @param code:
        @return:
        """
        if code in self.__human_remove_codes:
            self.__human_remove_codes.discard(code)
class BlackListCodeManager:
    __instance = None
constant.py
@@ -236,4 +236,7 @@
# 是否可买首封
CAN_BUY_FIRST_LIMIT_UP = False
# 是否可以自动拉白
CAN_AUTO_ADD_WHITE = True
data_parser/transaction_big_order_parser.py
New file
@@ -0,0 +1,203 @@
"""
大单成交数据解析器
"""
import os
import re
from multiprocessing import Pool
import pandas as pd
from utils import tool
class BigOrderDealParser:
    @classmethod
    def str_to_float(cls, s):
        try:
            # 移除单位并转换
            return round(float(s.split("@")[0]), 2)
        except:
            return float("nan")
    @classmethod
    def code_format(cls, s):
        try:
            code = "{0:0>6}".format(s)
            return code
        except:
            return ''
def __pre_process_transactions_detail(args):
    def first_last(group):
        """
            获取第一条数据与最后一条
            @param group:
            @return:
            """
        return pd.Series({
            'TotalAmount': group['TradeAmount'].sum(),
            'TotalVolume': group['TradeVolume'].sum(),
            'StartTime': group['TradeTime'].iloc[0],
            'StartPrice': group['TradePrice'].iloc[0],
            'EndTime': group['TradeTime'].iloc[-1],
            'EndPrice': group['TradePrice'].iloc[-1]
        })
    chunk_index, chunk_data = args[0]
    csv_path = args[1]
    df = chunk_data.copy()
    index = chunk_index + 1
    children_dir = csv_path.replace(".csv", "")
    if not os.path.exists(children_dir):
        os.makedirs(children_dir)
    child_path = os.path.join(children_dir, f"{index}.csv")
    if os.path.exists(child_path):
        return
    print(f"处理Transaction第{index}批次", os.getpid())
    df["TradePrice"] = df["TradePrice"].apply(BigOrderDealParser.str_to_float)
    df["SecurityID"] = df["SecurityID"].apply(BigOrderDealParser.code_format)
    df = df[df["SecurityID"].str.startswith(("30", "00", "60"), na=False)]
    # 计算成交金额
    df['TradeAmount'] = df['TradePrice'] * df['TradeVolume']
    df = df[df["TradeAmount"] > 0]
    # 判断是否为空
    # print(df.empty)
    # 按SecurityID和BuyNo分组
    grouped = df.groupby(['SecurityID', 'BuyNo'])
    # 应用聚合函数
    chunk_result = grouped.apply(first_last)
    if not df.empty:
        chunk_result = chunk_result.reset_index()
    chunk_result.to_csv(child_path, index=False)
def pre_process_transactions(csv_path, process_count=4):
    chunk_size = 200000
    # 创建DataFrame
    chunks = pd.read_csv(csv_path, chunksize=chunk_size)
    indexed_data = list(enumerate(chunks))
    args = [(x, csv_path) for x in indexed_data]
    # 新写法
    with Pool(processes=process_count) as pool:
        pool.map(__pre_process_transactions_detail, args)
def __pre_process_ngtsticks(args):
    def first_last(group):
        return pd.Series({
            'TotalAmount': group['TradeMoney'].sum(),
            'TotalVolume': group['Volume'].sum(),
            'StartTime': group['TickTime'].iloc[0],
            'StartPrice': group['Price'].iloc[0],
            'EndTime': group['TickTime'].iloc[-1],
            'EndPrice': group['Price'].iloc[-1]
        })
    chunk_index, chunk_data = args[0]
    csv_path = args[1]
    df = chunk_data.copy()
    index = chunk_index + 1
    children_dir = csv_path.replace(".csv", "")
    if not os.path.exists(children_dir):
        os.makedirs(children_dir)
    child_path = os.path.join(children_dir, f"{index}.csv")
    if os.path.exists(child_path):
        return
    print(f"处理NGTSTick第{index}批次")
    df = df[df["TickType"] == 'T']
    df["Price"] = df["Price"].apply(BigOrderDealParser.str_to_float)
    df["SecurityID"] = df["SecurityID"].apply(BigOrderDealParser.code_format)
    df = df[df["SecurityID"].str.startswith(("30", "00", "60"), na=False)]
    # 计算成交金额
    df['TradeMoney'] = df["TradeMoney"].apply(BigOrderDealParser.str_to_float)
    # 按SecurityID和BuyNo分组
    grouped = df.groupby(['SecurityID', 'BuyNo'])
    # 应用聚合函数
    chunk_result = grouped.apply(first_last)
    if not df.empty:
        chunk_result = chunk_result.reset_index()
    chunk_result.to_csv(child_path, index=False)
def pre_process_ngtsticks(csv_path, process_count=4):
    chunk_size = 200000
    # 创建DataFrame
    chunks = pd.read_csv(csv_path, chunksize=chunk_size)
    indexed_data = list(enumerate(chunks))
    args = [(x, csv_path) for x in indexed_data]
    # 新写法
    with Pool(processes=process_count) as pool:
        pool.map(__pre_process_ngtsticks, args)
def __concat_pre_datas(dir_path):
    """
    拼接数据
    @param dir_path:
    @return:
    """
    combined_path = os.path.join(dir_path, 'combined.csv')
    if os.path.exists(combined_path):
        print("合并的目标文件已存在")
        return
    file_list = os.listdir(dir_path)
    file_list.sort(key=lambda x: int(re.findall(r'\d+', x)[0]))
    df_list = []
    for file in file_list:
        df = pd.read_csv(os.path.join(dir_path, file))
        if df.empty:
            continue
        df["SecurityID"] = df["SecurityID"].apply(BigOrderDealParser.code_format)
        df_list.append(df)
    print("准备合并的文件数量:", len(df_list))
    combined_df = pd.concat(df_list, ignore_index=True)
    print("合并完成,准备写入文件!")
    # 保存结果
    combined_df.to_csv(combined_path, index=False)
    print("写入文件完成!")
def concat_pre_transactions(dir_path):
    __concat_pre_datas(dir_path)
def concat_pre_ngtsticks(dir_path):
    __concat_pre_datas(dir_path)
def process_combined_transaction(dir_path):
    """
    处理拼接起来的数据
    @param dir_path:
    @return:
    """
    combined_path = os.path.join(dir_path, 'combined.csv')
    if not os.path.exists(combined_path):
        print("拼接数据不存在")
        return
    df = pd.read_csv(combined_path)
    df_copy = df.copy()
    grouped = df_copy.groupby(["SecurityID"])
    # 应用聚合函数
    chunk_result = grouped.apply(pd.Series({}))
    # chunk_result["SecurityID"] = chunk_result["SecurityID"].apply(BigOrderDealParser.code_format)
    print(chunk_result.to_string(
        index=False,  # 不显示索引
        justify='left',  # 左对齐
        float_format='%.3f'  # 浮点数格式
    ))
if __name__ == "__main__":
    # pre_process_transactions("E:/测试数据/Transaction_Test.csv")
    # pre_process_ngtsticks("E:/测试数据/NGTSTick_Test.csv")
    # concat_pre_transactions("E:/测试数据/Transaction_Test")
    process_combined_transaction("E:/测试数据/Transaction_Test")
huaxin_client/l2_client_test.py
@@ -160,7 +160,7 @@
        order_time = item[4]
        if self.accurate_buy:
            self.add_transaction_data_for_accurate(item, big_order_money_threshold=big_order_money_threshold)
            self.add_transaction_data_for_accurate(item, big_order_money_threshold=50e4)
        if not self.__latest_buy_order:
            # (买单号, 量, 金额, 时间, 最新成交价格)
l2/l2_data_manager.py
@@ -23,7 +23,7 @@
    # mode: 0-普通交易  1-快速交易
    def __init__(self, buy_single_index=None, buy_exec_index=-1, buy_compute_index=None, num=0, count=0,
                 max_num_set=None, buy_volume_rate=None, sell_info=None, threshold_money=None, mode=0, mode_desc=None,
                 at_limit_up=False, first_limit_up_buy=False):
                 at_limit_up=False, first_limit_up_buy=False, min_order_no = None):
        self.buy_single_index = buy_single_index
        self.buy_exec_index = buy_exec_index
        self.buy_compute_index = buy_compute_index
@@ -42,6 +42,8 @@
        self.at_limit_up = at_limit_up
        # 是否为首封买
        self.first_limit_up_buy = first_limit_up_buy
        # 统计批次大单成交的最小订单号
        self.min_order_no = min_order_no
    def get_max_num_set(self):
        if self.max_num_set:
l2/l2_data_manager_new.py
@@ -262,6 +262,7 @@
        """
        if code in cls.__human_radical_buy_mark_info:
            return True
        return False
    @classmethod
    def is_valid(cls, code, data):
@@ -273,9 +274,11 @@
        if code not in cls.__human_radical_buy_mark_info:
            return False, "没有人买入信号"
        single_time_ms, space_time_ms, expire_time_ms, _ = cls.__human_radical_buy_mark_info[code]
        if tool.trade_time_sub_with_ms(L2DataUtil.get_time_with_ms(data["val"]),
        now_time_ms = L2DataUtil.get_time_with_ms(data["val"])
        if tool.trade_time_sub_with_ms(now_time_ms,
                                       expire_time_ms) > 0:
            cls.__human_radical_buy_mark_info.pop(code)
            async_log_util.info(logger_l2_not_buy_reasons, f"{code}#大单足够,人为下单: 超过信号生效时间-{now_time_ms}/{expire_time_ms}")
            return False, "超过信号生效时间"
        return True, cls.__human_radical_buy_mark_info[code]
@@ -1519,31 +1522,35 @@
        _start_time = tool.get_now_timestamp()
        total_datas = local_today_datas[code]
        if not HumanRadicalBuySingleManager.has_single(code):
            # ---------计算激进买入的信号---------
            radical_result = cls.__compute_radical_order_begin_pos(code, compute_start_index, compute_end_index)
        else:
            human_radical_result = cls.__compute_human_radical_order_begin_pos(code, compute_start_index,
                                                                               compute_end_index)
            if human_radical_result[0]:
                radical_result = list(human_radical_result[2])
                # 改变执行位置
                radical_result[1] = human_radical_result[1]["index"]
            else:
                radical_result = None
        # 不需要根据人为下单来下单
        # if not HumanRadicalBuySingleManager.has_single(code):
        #     # ---------计算激进买入的信号---------
        #     radical_result = cls.__compute_radical_order_begin_pos(code, compute_start_index, compute_end_index)
        # else:
        #     human_radical_result = cls.__compute_human_radical_order_begin_pos(code, compute_start_index,
        #                                                                        compute_end_index)
        #     l2_log.debug(code, f"大单足够,人为下单计算结果({compute_start_index}-{compute_end_index}):{human_radical_result}")
        #     if human_radical_result[0]:
        #         radical_result = list(human_radical_result[2])
        #         # 改变执行位置
        #         radical_result[1] = human_radical_result[1]["index"]
        #     else:
        #         radical_result = None
        radical_result = cls.__compute_radical_order_begin_pos(code, compute_start_index, compute_end_index)
        if radical_result and radical_result[0]:
            if not HumanRadicalBuySingleManager.has_single(code):
                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), 0)
                if big_order_deal_enough_result[6] <= 0:
                    HumanRadicalBuySingleManager.add_single(code, total_datas[-1], radical_result)
                    async_log_util.info(logger_l2_not_buy_reasons, f"{code}#大单足够,需要根据人为下单")
                    return
            # 下单前一步,移除人为下单信号
            is_human_radical_buy = HumanRadicalBuySingleManager.has_single(code)
            HumanRadicalBuySingleManager.remove_single(code)
            # if not HumanRadicalBuySingleManager.has_single(code):
            #     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), 0)
            #     if big_order_deal_enough_result[6] <= 0:
            #         HumanRadicalBuySingleManager.add_single(code, total_datas[-1], radical_result)
            #         async_log_util.info(logger_l2_not_buy_reasons, f"{code}#大单足够,需要根据人为下单({compute_start_index}-{compute_end_index}):{radical_result[1]}")
            #         return
            # #下单前一步,移除人为下单信号
            # is_human_radical_buy = HumanRadicalBuySingleManager.has_single(code)
            # HumanRadicalBuySingleManager.remove_single(code)
            buy_single_index, buy_exec_index = radical_result[1], radical_result[1]
            buy_volume_rate = cls.volume_rate_info[code][0]
@@ -1562,9 +1569,11 @@
                                                     max_num_set=set(),
                                                     buy_volume_rate=buy_volume_rate,
                                                     mode=OrderBeginPosInfo.MODE_RADICAL,
                                                     mode_desc=f"大单不足扫入:{radical_result[2]} 是否跟人买入-{is_human_radical_buy}",
                                                     mode_desc=f"大单不足扫入:{radical_result[2]}",
                                                     sell_info=sell_info,
                                                     threshold_money=threshold_money)
                                                     threshold_money=threshold_money,
                                                     min_order_no=radical_result[5]
                                                     )
            order_begin_pos_info.at_limit_up = cls.__is_at_limit_up_buy(code)
            ordered = cls.__process_with_find_exec_index(code, order_begin_pos_info, compute_end_index,
                                                         block_info=radical_result[3])
@@ -2017,11 +2026,10 @@
        @param code:
        @param start_index:
        @param end_index:
        @return: (是否获取到信号, 信号位置, 扫入板块/消息, 扫入板块大单流入信息, 需要监听的大单)
        @return: (是否获取到信号, 信号位置, 扫入板块/消息, 扫入板块大单流入信息, 需要监听的大单, 统计上板大单成交的最小订单号)
        """
        # 激进买信号的时间
        def __can_order():
            # 判断是否是板上放量
            # if cls.__is_at_limit_up_buy(code, start_index):
@@ -2122,8 +2130,13 @@
                    single_index = i
                    break
            if single_index is not None:
                return True, single_index, f"有大单,大单情况:{big_order_deal_enough_result[1]}", watch_indexes
            return False, None, f"大单不足:{trade_index}-{end_index}  缺少的大单-{max(current_lack_money, total_lack_money)}  大单情况:{big_order_deal_enough_result[1]}", watch_indexes
                every_time_big_orders = EveryLimitupBigDealOrderManager.list_big_buy_deal_orders(code)
                if every_time_big_orders:
                    min_order_no = min(min(every_time_big_orders, key=lambda e: e[0])[0], radical_data[1])
                else:
                    min_order_no = radical_data[1]
                return True, single_index, f"有大单,大单情况:{big_order_deal_enough_result[1]}", watch_indexes, min_order_no
            return False, None, f"大单不足:{trade_index}-{end_index}  缺少的大单-{max(current_lack_money, total_lack_money)}  大单情况:{big_order_deal_enough_result[1]}", watch_indexes, None
        radical_data = RadicalBuyDealCodesManager.buy_by_l2_delegate_expire_time_dict.get(code)
        record_codes = radical_buy_data_manager.BlockPlaceOrderRecordManager().get_codes()
@@ -2167,7 +2180,7 @@
            # 如果板上放量不可买入就需要删除信号
            if not constant.CAN_RADICAL_BUY_AT_LIMIT_UP and code in RadicalBuyDealCodesManager.buy_by_l2_delegate_expire_time_dict:
                RadicalBuyDealCodesManager.buy_by_l2_delegate_expire_time_dict.pop(code)
            return True, result[1], radical_data[2], radical_data[4], result[3]
            return True, result[1], radical_data[2], radical_data[4], result[3], result[4]
        else:
            async_log_util.info(logger_l2_not_buy_reasons, f"{code}#{result[2]}")
        return result
@@ -2213,7 +2226,8 @@
                return False, None, "超过信号生效时间"
            is_valid = False
            # 判断距离上个50w买单的时间是否超过了space_time_ms
            for ii in range(i - 1, -1, -1):
            buy_exec_index = radical_result[1]
            for ii in range(i - 1, buy_exec_index, -1):
                data_child = total_datas[ii]
                val_child = data_child["val"]
                if not L2DataUtil.is_limit_up_price_buy(val_child):
@@ -2240,6 +2254,8 @@
        @param end_index:
        @return: 信号信息(信号位,执行位), 消息, 可买入的板块
        """
        if True:
            return None, "此条不生效", None
        if not tool.is_sz_code(code):
            return None, "非深证的票", None
        # 判断抛压是否大于5000w
l2_data_parser.py
@@ -9,6 +9,7 @@
import pandas as pd
from data_parser import transaction_big_order_parser
from db import mysql_data_delegate as mysql_data
from huaxin_client.l2_client_test import L2TransactionDataManager
from log_module import log_export
@@ -358,13 +359,13 @@
    print(f"处理完毕,总共{index}批")
if __name__ == '__main__':
if __name__ == '__main__1':
    # df = pd.read_csv(f"E:/测试数据/Transaction_Test.csv")
    pre_process_transactions()
# 命令模式  /home/userzjj/app/gp-server/l2_data_parser Transaction  2025-05-08
# 解析大单: /home/userzjj/app/gp-server/l2_data_parser ExtractDealBigOrder 2025-05-09 /home/userzjj/最终成交数据20250509.txt 000555
if __name__ == '__main__1':
if __name__ == '__main__':
    if len(sys.argv) > 1:
        params = sys.argv[1:]
        print("接收的参数", params)
@@ -383,9 +384,17 @@
        elif _type == 'MarketData':
            parse_market_data(day)
        elif _type == 'Transaction_New':
            pre_process_transactions(f"/home/userzjj/ftp/{day}/Transaction.csv")
            transaction_big_order_parser.pre_process_transactions(f"/home/userzjj/ftp/{day}/Transaction.csv")
            transaction_big_order_parser.concat_pre_transactions(f"/home/userzjj/ftp/{day}/Transaction")
        elif _type == 'NGTSTick_New':
            pre_process_ngtstick(f"/home/userzjj/ftp/{day}/NGTSTick.csv")
            transaction_big_order_parser.pre_process_ngtsticks(f"/home/userzjj/ftp/{day}/NGTSTick.csv")
            transaction_big_order_parser.concat_pre_ngtsticks(f"/home/userzjj/ftp/{day}/NGTSTick")
        elif _type == 'Transaction_Concat':
            transaction_big_order_parser.concat_pre_transactions(f"/home/userzjj/ftp/{day}/Transaction")
        elif _type == 'NGTSTick_Concat':
            transaction_big_order_parser.concat_pre_ngtsticks(f"/home/userzjj/ftp/{day}/NGTSTick")
        elif _type == 'ExtractDealBigOrder':
            # 提取所有成交的大单
            if len(params) > 2:
servers/huaxin_trade_server.py
@@ -839,6 +839,12 @@
                            if refer_sell_data:
                                sell_info = (refer_sell_data[0], refer_sell_data[1])
                            threshold_money = 0
                            every_deal_orders = EveryLimitupBigDealOrderManager.list_big_buy_deal_orders(code)
                            if every_deal_orders:
                                min_order_no = min(every_deal_orders, lambda x: x[0])[0]
                            else:
                                min_order_no = transaction_datas[-1][6]
                            order_begin_pos_info = OrderBeginPosInfo(buy_single_index=buy_single_index,
                                                                     buy_exec_index=buy_exec_index,
                                                                     buy_compute_index=buy_exec_index,
@@ -846,9 +852,11 @@
                                                                     max_num_set=set(),
                                                                     buy_volume_rate=buy_volume_rate,
                                                                     mode=OrderBeginPosInfo.MODE_RADICAL,
                                                                     mode_desc=f"扫入买入:{buy_blocks}",
                                                                     mode_desc=f"扫入买入:{buy_blocks}, 大单成交最小订单号:{min_order_no}",
                                                                     sell_info=sell_info,
                                                                     threshold_money=threshold_money)
                                                                     threshold_money=threshold_money,
                                                                     min_order_no= min_order_no
                                                                     )
                            L2TradeDataProcessor.save_order_begin_data(code, order_begin_pos_info)
                            buy_result = L2TradeDataProcessor.start_buy(code, total_datas[-1], total_datas[-1]["index"],
                                                                        True, block_info=buy_blocks_with_money)
trade/buy_radical/radical_buy_data_manager.py
@@ -11,7 +11,7 @@
import constant
import l2_data_util
from code_attribute.code_volumn_manager import CodeVolumeManager
from l2 import l2_data_util as l2_data_util_new, l2_log
from l2 import l2_data_util as l2_data_util_new, l2_log, l2_data_manager
from code_attribute import code_nature_analyse, code_volumn_manager, gpcode_manager
from code_attribute.code_l1_data_manager import L1DataManager
from code_attribute.gpcode_manager import WantBuyCodesManager
@@ -560,6 +560,7 @@
        @param count:
        @return:
        """
        cls.__process_add_white(code)
        if gpcode_manager.MustBuyCodesManager().is_in_cache(code):
            return
        total_deal_big_order_result = get_total_deal_big_order_info(code,
@@ -570,15 +571,56 @@
    @classmethod
    def place_order_success(cls, code):
        # 如果是加想,且成交大单足够就加红
        total_deal_big_order_result = get_total_deal_big_order_info(code,
                                                                    gpcode_manager.get_limit_up_price_as_num(code))
        if WantBuyCodesManager().is_in_cache(code):
            big_order_deal_enough_result = is_big_order_deal_enough(code,
                                                                    code_volumn_manager.CodeVolumeManager().get_volume_rate_refer_in_5days(
                                                                        code),
                                                                    0)
            if big_order_deal_enough_result[6] <= 0:
            if total_deal_big_order_result[0] <= 0:
                # 累计大单足够需要加红
                gpcode_manager.MustBuyCodesManager().add_code(code)
                trade_record_log_util.add_must_buy(code, "累计成交大单足够")
        cls.__process_add_white(code)
    @classmethod
    def __process_add_white(cls, code):
        """
        处理加白
        @param code:
        @return:
        """
        if not constant.CAN_AUTO_ADD_WHITE:
            return
        if gpcode_manager.WhiteListCodeManager().is_in_cache(code):
            return
        try:
            total_deal_big_order_result = get_total_deal_big_order_info(code,
                                                                        gpcode_manager.get_limit_up_price_as_num(code))
            if total_deal_big_order_result[0] <= 0 and total_deal_big_order_result[2] >= 1e8:
                # 1个亿以上的且本批次成交的大单金额大于2倍大单金额就加白
                order_begin_pos = TradePointManager().get_buy_compute_start_data_cache(code)
                is_placed_order = l2_data_manager.TradePointManager.is_placed_order(order_begin_pos)
                if not is_placed_order:
                    # 没有下过单
                    return
                if order_begin_pos and order_begin_pos.min_order_no is not None:
                    # 在 min_order_no 之后成交的大单金额
                    total_buy_data_list = BigOrderDealManager().get_total_buy_data_list(code)
                    min_order_no = order_begin_pos.min_order_no
                    if min_order_no is None:
                        async_log_util.warning(logger_debug, "处理成交大单足够加白: 最小订单号为空")
                        return
                    bigger_money = l2_data_util.get_big_money_val(gpcode_manager.get_limit_up_price_as_num(code),
                                                                  tool.is_ge_code(code))
                    deal_money = sum(
                        [x[2] for x in total_buy_data_list if x[0] >= min_order_no and x[2] >= bigger_money])
                    # 获取均大单
                    THRESHOLD_MONEY, is_temp_threshold_money = BeforeSubDealBigOrderManager().get_big_order_threshold_info(
                        code)
                    if deal_money >= 2 * THRESHOLD_MONEY:
                        gpcode_manager.WhiteListCodeManager().add_code(code)
                        trade_record_log_util.add_common_msg(code, "加白",  f"{code}大单成交足够加白, 本批次成交金额-{deal_money}/{THRESHOLD_MONEY * 2}  累计大单金额:{total_deal_big_order_result[1]}/{total_deal_big_order_result[2]}")
        except Exception as e:
            logger_debug.exception(e)
            async_log_util.info(logger_debug, f"处理成交大单足够加白的问题:{str(e)}")
    @classmethod
    def market_info_change(cls, code):
@@ -1854,11 +1896,25 @@
    @classmethod
    def get_big_buy_deal_order_money_info(cls, code):
        """
        获取成交大单的信息
        @param code:
        @return: (总共大单成交金额, 最近成交大单的最后成交时间)
        """
        if cls.__deal_big_order_infos_dict.get(code):
            return sum([x[1] for x in cls.__deal_big_order_infos_dict[code]]), l2_huaxin_util.convert_time(
                cls.__deal_big_order_infos_dict[code][-1][2])
        return None
    @classmethod
    def list_big_buy_deal_orders(cls, code):
        """
        @param code:
        @return:[(订单号,金额, 最后成交时间)]
        """
        return cls.__deal_big_order_infos_dict.get(code, [])
class EveryLimitupBigDelegateOrderManager:
    """
trade/buy_radical/radical_buy_strategy.py
@@ -165,8 +165,8 @@
    left_limit_up_sell_money = selling_num * price
    # 每次上板的大单与金额
    big_order_count = radical_buy_data_manager.EveryLimitupBigDealOrderManager().get_big_buy_deal_order_count(code)
    big_order_money = radical_buy_data_manager.EveryLimitupBigDealOrderManager().get_big_buy_deal_order_money(code)
    big_order_count = radical_buy_data_manager.EveryLimitupBigDealOrderManager.get_big_buy_deal_order_count(code)
    big_order_money = radical_buy_data_manager.EveryLimitupBigDealOrderManager.get_big_buy_deal_order_money(code)
    if big_order_count >= 2:
        average_big_order_money = int(big_order_money / big_order_count)
        # 如果均价涨幅小于7%均大单等于299w
trade/trade_result_manager.py
@@ -4,7 +4,8 @@
from cancel_strategy.s_l_h_cancel_strategy import HourCancelBigNumComputer
from cancel_strategy.s_l_h_cancel_strategy import LCancelBigNumComputer
from cancel_strategy.s_l_h_cancel_strategy import SCancelBigNumComputer
from code_attribute.gpcode_manager import MustBuyCodesManager, GreenListCodeManager, WantBuyCodesManager
from code_attribute.gpcode_manager import MustBuyCodesManager, GreenListCodeManager, WantBuyCodesManager, \
    WhiteListCodeManager
from l2 import l2_data_manager, place_order_single_data_manager
from l2.cancel_buy_strategy import FCancelBigNumComputer, \
    NewGCancelBigNumComputer, JCancelBigNumComputer, NBCancelBigNumComputer
@@ -111,6 +112,8 @@
    # 如果是扫入下单,下单之后就加红
    if order_begin_pos.mode == OrderBeginPosInfo.MODE_RADICAL:
        # 移除人为移白
        WhiteListCodeManager().clear_huamn_info(code)
        RadicalBuyDataManager.place_order_success(code)
    # 清除下单信号