Administrator
2023-12-05 e024032194fc44350fea977cd8d82b6ab898f9ea
修改交易记录添加数据/U撤修改
8个文件已修改
104 ■■■■■ 已修改文件
huaxin_client/l2_client.py 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/cancel_buy_strategy.py 28 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/l2_data_manager_new.py 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/l2_transaction_data_manager.py 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
output/code_info_output.py 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
third_data/code_plate_key_manager.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/huaxin/huaxin_trade_server.py 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/trade_record_log_util.py 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
huaxin_client/l2_client.py
@@ -122,7 +122,7 @@
            result = self.__api.SubscribeMarketData(sz, lev2mdapi.TORA_TSTP_EXD_SZSE)
            logger_local_huaxin_l2_subscript.info(f"市场订阅结果sz:{result}")
    def __process_codes_data(self, codes_data, from_cache=False, delay=0):
    def __process_codes_data(self, codes_data, from_cache=False, delay=0.0):
        if not self.is_login and not constant.TEST:
            raise Exception("L2尚未登录")
@@ -213,11 +213,9 @@
            print("----L2行情登录成功----")
            self.is_login = True
            # 初始设置值
            t1 = threading.Thread(
                target=lambda: self.__process_codes_data(self.__get_latest_datas(), from_cache=True, delay=6),
                daemon=True)
            # 后台运行
            t1.start()
            threading.Thread(
                target=lambda: self.__process_codes_data(self.__get_latest_datas(), from_cache=True, delay=6.0),
                daemon=True).start()
    def OnRspSubMarketData(self, pSpecificSecurity, pRspInfo, nRequestID, bIsLast):
        print("OnRspSubMarketData")
l2/cancel_buy_strategy.py
@@ -1688,6 +1688,7 @@
    __db = 0
    __redis_manager = redis_manager.RedisManager(0)
    __cancel_real_order_index_cache = {}
    __SecondCancelBigNumComputer = SecondCancelBigNumComputer()
    __instance = None
@@ -1706,7 +1707,8 @@
        return cls.__redis_manager.getRedis()
    # 是否可以撤单
    def need_cancel(self, code, order_begin_pos: OrderBeginPosInfo, current_limit_up_block_codes_dict, volume_rate):
    def need_cancel(self, code, transaction_index, order_begin_pos: OrderBeginPosInfo,
                    current_limit_up_block_codes_dict, volume_rate):
        if not order_begin_pos or not order_begin_pos.buy_exec_index or order_begin_pos.buy_exec_index < 0:
            return False, "尚未下单"
        if not current_limit_up_block_codes_dict:
@@ -1724,9 +1726,27 @@
        total_datas = local_today_datas.get(code)
        time_sub = tool.trade_time_sub(tool.get_now_time_str(),
                                       total_datas[order_begin_pos.buy_exec_index]["val"]["time"])
        # if time_sub > 15 * 60:
        #     if len(current_limit_up_block_codes_dict[block]) == 1:
        #         return True, "独苗下单15分钟无后排"
        if 2 < time_sub < 30 * 60:
            real_place_order_index = self.__SecondCancelBigNumComputer.get_real_place_order_index_cache(code)
            if not real_place_order_index:
                return False, "尚未找到真实下单位置"
            total_left_count = 0
            for i in range(transaction_index, real_place_order_index):
                data = total_datas[i]
                val = data["val"]
                if float(val['price']) * val['num'] < 50 * 100:
                    continue
                left_count = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count_v2(code, i,
                                                                                                         total_datas,
                                                                                                         local_today_canceled_buyno_map.get(
                                                                                                             code))
                if left_count > 0:
                    total_left_count += 1
                    if total_left_count > 5:
                        break
            # 成交进度变化
            if len(current_limit_up_block_codes_dict[block]) == 1 and volume_rate < 0.6 and total_left_count <= 5:
                return True, "独苗下单30分钟无后排且成交位离我们很近且量小于60%"
        # if time_sub > 10 * 60:
        #     if len(current_limit_up_block_codes_dict[block]) == 1 and volume_rate < 0.7:
        #         return True, f"独苗下单10分钟无后排且量({volume_rate})小于70%"
l2/l2_data_manager_new.py
@@ -647,7 +647,9 @@
                        info.set_kpl_blocks(list(jx_blocks_by))
                    else:
                        info.set_kpl_blocks([])
                    can_buy_result = CodePlateKeyBuyManager.can_buy(code)
                    if can_buy_result:
                        info.set_kpl_match_blocks(can_buy_result[0])
                    trade_record_log_util.add_place_order_log(code, info)
                except Exception as e:
                    async_log_util.error(logger_l2_error, f"加入买入记录日志出错:{str(e)}")
@@ -858,8 +860,12 @@
        if HighIncreaseCodeManager().is_in(code) and cls.volume_rate_info[code][0] < 0.6:
            return False, True, f"股价涨得过高,当日量比({cls.volume_rate_info[code][0]})小于0.6"
        if cls.volume_rate_info[code][0] < 0.2:
            return False, True, f"当日量比({cls.volume_rate_info[code][0]})小于0.2"
        if int(tool.get_now_time_str().replace(":", "")) <= int("100000"):
            if cls.volume_rate_info[code][0] < 0.1:
                return False, True, f"当日量比({cls.volume_rate_info[code][0]})小于0.1"
        else:
            if cls.volume_rate_info[code][0] < 0.2:
                return False, True, f"当日量比({cls.volume_rate_info[code][0]})小于0.2"
        k_format = code_nature_analyse.CodeNatureRecordManager().get_k_format_cache(code)
        if k_format and (k_format[1][0] or k_format[3][0]):
            # 股价创新高或者逼近前高
@@ -870,7 +876,6 @@
            if cls.volume_rate_info[code][0] < 0.6:
                # HighIncreaseCodeManager().add_code(code)
                return False, True, f"近日出现最大量,当日量比({cls.volume_rate_info[code][0]})小于0.6"
        total_data = local_today_datas.get(code)
        if constant.L2_SOURCE_TYPE == constant.L2_SOURCE_TYPE_HUAXIN:
l2/l2_transaction_data_manager.py
@@ -10,11 +10,13 @@
from db.redis_manager_delegate import RedisUtils
from l2 import l2_data_util, l2_data_manager, transaction_progress
from l2.cancel_buy_strategy import LCancelRateManager, LCancelBigNumComputer, \
    SecondCancelBigNumComputer, HourCancelBigNumComputer, FastCancelBigNumComputer
    SecondCancelBigNumComputer, HourCancelBigNumComputer, FastCancelBigNumComputer, UCancelBigNumComputer
from l2.l2_data_manager_new import L2TradeDataProcessor
from l2.l2_data_util import L2DataUtil
from log_module import async_log_util
from log_module.log import logger_l2_trade_buy_queue, hx_logger_l2_upload, hx_logger_l2_debug, \
    hx_logger_l2_transaction_desc
    hx_logger_l2_transaction_desc, logger_debug
from third_data import kpl_data_manager
from trade import current_price_process_manager, trade_manager, l2_trade_factor
from trade.deal_big_money_manager import DealOrderNoManager
from utils import tool
@@ -148,6 +150,20 @@
                if order_begin_pos and order_begin_pos.buy_exec_index and order_begin_pos.buy_exec_index > -1:
                    HourCancelBigNumComputer().set_transaction_index(code, order_begin_pos.buy_single_index,
                                                                     buy_progress_index)
                    # ---------------------------------判断板块是否跟上来了-------------------------------
                    try:
                        order_begin_pos = l2_data_manager.TradePointManager().get_buy_compute_start_data_cache(code)
                        volume_rate = 0
                        volume_info = L2TradeDataProcessor.volume_rate_info.get(code)
                        if volume_info:
                            volume_rate = volume_info[0]
                        need_cancel, msg = UCancelBigNumComputer().need_cancel(code, buy_progress_index, order_begin_pos,
                                                                               kpl_data_manager.KPLLimitUpDataRecordManager.get_current_reason_codes_dict(),
                                                                               volume_rate)
                        if need_cancel:
                            L2TradeDataProcessor.cancel_buy(code, msg)
                    except Exception as e:
                        logger_debug.exception(e)
            else:
                pass
            if order_begin_pos and order_begin_pos.buy_exec_index and order_begin_pos.buy_exec_index > -1:
output/code_info_output.py
@@ -315,7 +315,6 @@
    index = 0
    if records:
        try:
            latest_cancel_watch_index_dict = {}
            for record in records:
                time_ = record[0]
@@ -325,6 +324,15 @@
                    records_new_data.append((time_, "开盘啦推荐原因",
                                             f"{'、'.join([k[1] for k in data['kpl_blocks']])}",
                                             None))
                    if "kpl_match_blocks" in data:
                        if data["kpl_match_blocks"]:
                            records_new_data.append((time_, "匹配原因",
                                                     f"{'、'.join(data['kpl_match_blocks'])}",
                                                     None))
                        else:
                            records_new_data.append((time_, "匹配原因",
                                                     f"独苗",
                                                     None))
                    extra_datas = []
                    if data['big_num_indexes']:
                        big_num_desc = []
third_data/code_plate_key_manager.py
@@ -630,7 +630,7 @@
        return fresults
    # 是否可以下单
    # 返回:是否可以下单,消息,板块类型
    # 返回:可以买的板块,是否独苗,消息
    @classmethod
    def can_buy(cls, code):
        if constant.TEST:
trade/huaxin/huaxin_trade_server.py
@@ -433,21 +433,6 @@
                                # 买1封单额平稳
                                LCancelBigNumComputer().re_compute_l_down_watch_indexes(code)
            # ---------------------------------判断板块是否跟上来了-------------------------------
            try:
                order_begin_pos = l2_data_manager.TradePointManager().get_buy_compute_start_data_cache(code)
                volume_rate = 0
                volume_info = l2_data_manager_new.L2TradeDataProcessor.volume_rate_info.get(code)
                if volume_info:
                    volume_rate = volume_info[0]
                need_cancel, msg = UCancelBigNumComputer().need_cancel(code, order_begin_pos,
                                                                       kpl_data_manager.KPLLimitUpDataRecordManager.get_current_reason_codes_dict(),
                                                                       volume_rate)
                if need_cancel:
                    l2_data_manager_new.L2TradeDataProcessor.cancel_buy(code, msg)
            except Exception as e:
                logger_debug.exception(e)
            # ----------------------------------板块相关------------------------------
            cls.__KPLCodeJXBlockManager.load_jx_blocks(code, buy_1_price, limit_up_price,
                                                       kpl_data_manager.KPLLimitUpDataRecordManager.get_current_reasons())
trade/trade_record_log_util.py
@@ -18,13 +18,14 @@
class PlaceOrderInfo(object):
    def __init__(self, buy_single_index=None, buy_exec_index=None, m_val=None, safe_count=None, big_num_indexes=None,
                 kpl_blocks=None, mode=None):
                 kpl_blocks=None, kpl_match_blocks=None, mode=None):
        self.buy_single_index = buy_single_index
        self.buy_exec_index = buy_exec_index
        self.m_val = m_val
        self.safe_count = safe_count
        self.big_num_indexes = big_num_indexes
        self.kpl_blocks = kpl_blocks
        self.kpl_match_blocks = kpl_match_blocks
        self.mode = mode
    def set_buy_index(self, buy_single_index, buy_exec_index):
@@ -39,6 +40,9 @@
    def set_kpl_blocks(self, kpl_blocks):
        self.kpl_blocks = kpl_blocks
    def set_kpl_match_blocks(self, kpl_blocks):
        self.kpl_match_blocks = kpl_blocks
    def to_json_str(self):
        return json.dumps(vars(self))