Administrator
2025-05-22 10e175f0b00ba76fc84e1478489bdce78f1a40ec
下单sinfo修改/加想的票累计大单成交足够后加红
5个文件已修改
93 ■■■■■ 已修改文件
huaxin_client/huaxin_trade_api.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/l2_data_manager_new.py 60 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2_data_parser.py 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/buy_radical/radical_buy_data_manager.py 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/huaxin/huaxin_trade_api.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
huaxin_client/huaxin_trade_api.py
@@ -179,7 +179,7 @@
                                    "code": code,
                                    "volume": volume,
                                    "price_type": price_type,
                                    "price": price, "sinfo": f"b_{code}_{round(time.time() * 1000)}"})
                                    "price": price, "sinfo": f"ba_{code}_{round(time.time() * 1000)}"})
    return __read_response(client, request_id, blocking)
l2/l2_data_manager_new.py
@@ -190,7 +190,8 @@
            # 如果是涨停买撤信号需要看数据位置是否比开始处理时间早
            if L2DataUtil.is_limit_up_price_buy_cancel(data["val"]):
                # 获取买入信号
                buy_index = l2_data_source_util.L2DataSourceUtils.get_buy_index_with_cancel_data_v2(total_datas[i], buyno_map)
                buy_index = l2_data_source_util.L2DataSourceUtils.get_buy_index_with_cancel_data_v2(total_datas[i],
                                                                                                    buyno_map)
                if buy_index is not None and buy_index < begin_pos:
                    continue
@@ -328,9 +329,11 @@
    def set_real_place_order_index(cls, code, index, order_begin_pos: OrderBeginPosInfo, last_data):
        trade_record_log_util.add_real_place_order_position_log(code, index, order_begin_pos.buy_single_index)
        total_datas = local_today_datas.get(code)
        use_time = tool.trade_time_sub_with_ms(L2DataUtil.get_time_with_ms(total_datas[index]["val"]) , L2DataUtil.get_time_with_ms(
            total_datas[order_begin_pos.buy_exec_index]["val"]))
        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}")
        use_time = tool.trade_time_sub_with_ms(L2DataUtil.get_time_with_ms(total_datas[index]["val"]),
                                               L2DataUtil.get_time_with_ms(
                                                   total_datas[order_begin_pos.buy_exec_index]["val"]))
        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)
        # 获取真实下单位置之后需要判断F撤
@@ -1943,7 +1946,8 @@
            total_datas = local_today_datas[code]
            limit_up_price = gpcode_manager.get_limit_up_price_as_num(code)
            bigger_money = l2_data_util.get_big_money_val(limit_up_price, tool.is_ge_code(code))
            min_num = int(bigger_money / limit_up_price / 100)
            bigger_money_num, current_min_num, total_min_num = int(bigger_money / limit_up_price / 100), int(
                bigger_money / limit_up_price / 100), int(5000 / limit_up_price)
            refer_sell_data = L2MarketSellManager().get_refer_sell_data(code, radical_data[3])
            # 参考总卖额
@@ -1959,7 +1963,8 @@
                                                                                             is_almost_open_limit_up=
                                                                                             radical_data[5])
            # 缺乏的大单金额
            lack_money = big_order_deal_enough_result[3]
            current_lack_money = int(big_order_deal_enough_result[5])
            total_lack_money = int(big_order_deal_enough_result[6])
            # 如果有大单成交就不需要看大单
            if constant.CAN_RADICAL_BUY_NEED_BIG_ORDER_EVERYTIME:
                # 每次下单都需要大单
@@ -1970,10 +1975,11 @@
                    # 60s以上就不下单了
                    return False, None, "距离上次统计大单时间过去60s", set()
            if lack_money == 0:
                if not tool.is_sh_code(code):
                    # 非上证的票看50w
                    min_num = int(5000 / limit_up_price)
            if max(current_lack_money, total_lack_money) <= 0:
                # 已经不缺少大单了
                # if not tool.is_sh_code(code):
                # 非上证的票看50w
                current_min_num = int(5000 / limit_up_price)
            # 如果累计大单成交足够,只需看50w
            # if big_order_deal_enough_result[4]:
            #     min_num = int(5000 / limit_up_price)
@@ -1992,8 +1998,6 @@
                val = data["val"]
                if not L2DataUtil.is_limit_up_price_buy(val):
                    continue
                if val["num"] < min_num:
                    continue
                # 撤单不算
                left_count = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count_v2(code, i,
                                                                                                         total_datas,
@@ -2008,23 +2012,35 @@
                        # 判断是否为大单
                        order_money = dealing_active_order_info[2] + round(val["price"], 2) * val["num"] * 100
                        if order_money >= bigger_money:
                            lack_money -= order_money
                            watch_indexes.add(i)
                            if lack_money < 0:
                            if val["num"] >= bigger_money_num:
                                watch_indexes.add(i)
                            if val["num"] >= current_min_num:
                                current_lack_money -= order_money
                            if val["num"] >= total_min_num:
                                total_lack_money -= order_money
                            if max(current_lack_money, total_lack_money) < 0:
                                single_index = i
                                break
                if int(val["orderNo"]) <= radical_data[1]:
                    # 主动买单后的数据不算
                    continue
                watch_indexes.add(i)
                lack_money -= round(val["price"], 2) * val["num"] * 100
                if lack_money < 0:
                if val["num"] >= bigger_money_num:
                    watch_indexes.add(i)
                if val["num"] >= current_min_num:
                    current_lack_money -= round(val["price"], 2) * val["num"] * 100
                if val["num"] >= total_min_num:
                    total_lack_money -= round(val["price"], 2) * val["num"] * 100
                if max(current_lack_money, total_lack_money) < 0:
                    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}  缺少的大单-{lack_money}  大单情况:{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
        radical_data = RadicalBuyDealCodesManager.buy_by_l2_delegate_expire_time_dict.get(code)
        record_codes = radical_buy_data_manager.BlockPlaceOrderRecordManager().get_codes()
@@ -2245,7 +2261,8 @@
                                f"{code}获取到买入执行点(快速买入):{i} 统计纯买手数:{buy_nums} 目标纯买手数:{threshold_num} 统计纯买单数:{buy_count}")
            elif L2DataUtil.is_limit_up_price_buy_cancel(_val):
                # 判断买入位置是否在买入信号之前
                buy_index = l2_data_source_util.L2DataSourceUtils.get_buy_index_with_cancel_data_v2(total_datas[i], buy_no_map)
                buy_index = l2_data_source_util.L2DataSourceUtils.get_buy_index_with_cancel_data_v2(total_datas[i],
                                                                                                    buy_no_map)
                if buy_index is not None:
                    # 找到买撤数据的买入点
                    if buy_index >= buy_single_index:
@@ -2385,7 +2402,8 @@
                                f"{code}获取到买入执行点(积极下单):{i} 统计纯买手数:{buy_nums} 目标纯买手数:{threshold_num} 统计纯买单数:{buy_count}")
            elif L2DataUtil.is_limit_up_price_buy_cancel(_val):
                # 判断买入位置是否在买入信号之前
                buy_index = l2_data_source_util.L2DataSourceUtils.get_buy_index_with_cancel_data_v2(total_datas[i], buyno_map)
                buy_index = l2_data_source_util.L2DataSourceUtils.get_buy_index_with_cancel_data_v2(total_datas[i],
                                                                                                    buyno_map)
                if buy_index is not None:
                    # 找到买撤数据的买入点
l2_data_parser.py
@@ -5,6 +5,7 @@
import os
import sys
import time
import pandas as pd
from db import mysql_data_delegate as mysql_data
from huaxin_client.l2_client_test import L2TransactionDataManager
@@ -47,6 +48,16 @@
    target_codes = __get_target_codes(day)
    base_path = f"/home/userzjj/ftp/{day}"
    fdatas = []
    df = pd.read_csv(f"{base_path}/Transaction.csv")
    category_revenue = df.groupby('BuyNo')['TradeVolume'].sum()
    total_count = 0
    for chunk in chunks:
        total_count += len(chunk)
    for chunk in chunks:
        total_count += len(chunk)
    with open(f"{base_path}/Transaction.csv", 'r', encoding='utf-8') as file:
        csv_reader = csv.reader(file)
        total_lines = csv_reader.line_num
trade/buy_radical/radical_buy_data_manager.py
@@ -569,8 +569,16 @@
    @classmethod
    def place_order_success(cls, code):
        # 如果有大单成交就加红
        pass
        # 如果是加想,且成交大单足够就加红
        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:
                # 累计大单足够需要加红
                gpcode_manager.MustBuyCodesManager().add_code(code)
                trade_record_log_util.add_must_buy(code, "累计成交大单足够")
    @classmethod
    def market_info_change(cls, code):
@@ -1710,7 +1718,7 @@
    @param code:
    @param volume_rate:
    @param for_buy: 是否是下单
    @return: 大单是否足够, 原因, 是否是短时生效, 还差的金额, 累计大单是否足够
    @return: 大单是否足够, 原因, 是否是短时生效, 还差的金额, 累计大单是否足够, 当前批次缺少的大单, 累计缺少的大单
    """
    limit_up_price = gpcode_manager.get_limit_up_price_as_num(code)
    refer_volume = code_volumn_manager.CodeVolumeManager().get_radical_buy_refer_volume(code, limit_up_price)
@@ -1788,9 +1796,9 @@
        if total_lack_money < 0:
            total_lack_money = 0
    if current_lack_money == 0 and total_lack_money == 0:
        return True, f"量比-{volume_rate}, 瞬时大单成交-({current_big_order_deal_money}/{current_threshold_money}),总大单成交-({total_lack_money_info[1]}/{total_lack_money_info[2]})", before_time, 0, total_lack_money <= 0
        return True, f"量比-{volume_rate}, 瞬时大单成交-({current_big_order_deal_money}/{current_threshold_money}),总大单成交-({total_lack_money_info[1]}/{total_lack_money_info[2]})", before_time, 0, total_lack_money <= 0, current_lack_money, total_lack_money
    return False, f"量比-{volume_rate}, 瞬时大单成交-({current_big_order_deal_money}/{current_threshold_money}),总大单成交-({total_lack_money_info[1]}/{total_lack_money_info[2]})", before_time, max(
        current_lack_money, total_lack_money), total_lack_money <= 0
        current_lack_money, total_lack_money), total_lack_money <= 0, current_lack_money, total_lack_money
class EveryLimitupBigDealOrderManager:
trade/huaxin/huaxin_trade_api.py
@@ -545,7 +545,7 @@
    """
    timestamp = round(time.time() * 1000)
    if not sinfo:
        sinfo = f"b_{code}_{timestamp}"
        sinfo = f"ba_{code}_{timestamp}"
    if not request_id:
        request_id = __get_request_id(ClientSocketManager.CLIENT_TYPE_TRADE)
    for i in range(1):