Administrator
2024-04-01 b664371ed6ee1da20af2e132426d70b3bfc66566
bug修复
4个文件已修改
40 ■■■■■ 已修改文件
constant.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/l2_data_manager.py 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/l2_transaction_data_manager.py 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/l2_transaction_data_processor.py 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
constant.py
@@ -157,7 +157,7 @@
########华鑫配置########
if not is_windows() or True:
    # 下单1手
    BUY_MONEY_PER_CODE = 500 if constant.IS_A else 20000
    BUY_MONEY_PER_CODE = 500 if constant.IS_A else 500
    L2_SOURCE_TYPE = L2_SOURCE_TYPE_HUAXIN
    JUEJIN_LOCAL_API = False
    TRADE_WAY = TRADE_WAY_HUAXIN
l2/l2_data_manager.py
@@ -149,6 +149,11 @@
        CodeDataCacheUtil.set_cache(self.__buy_compute_index_info_cache, code, data_)
        RedisUtils.setex_async(self.__db, _key, expire, data_.to_json_str())
    # 是否已经下单
    @classmethod
    def is_placed_order(cls, order_begin_pos: OrderBeginPosInfo):
        return order_begin_pos and order_begin_pos.buy_exec_index is not None and order_begin_pos.buy_exec_index > -1
# 清除l2数据
def clear_l2_data(code):
l2/l2_transaction_data_manager.py
@@ -7,7 +7,7 @@
from db.redis_manager_delegate import RedisUtils
from l2 import l2_log
from l2.huaxin import l2_huaxin_util
from l2.l2_data_util import local_today_sellno_map
from l2.l2_data_util import local_today_sellno_map, local_today_datas
from log_module import async_log_util
from log_module.log import hx_logger_l2_transaction_desc, hx_logger_l2_transaction_sell_order
@@ -104,7 +104,7 @@
    # 返回最近1s的大单卖:(总卖金额,[(卖单号,总手数,价格,('开始时间',买单号),('结束时间',买单号)),...])
    @classmethod
    def add_transaction_datas(cls, code, datas):
    def add_transaction_datas(cls, code, datas, buy_exec_index=None):
        # q.append((data['SecurityID'], data['TradePrice'], data['TradeVolume'],
        #           data['OrderTime'], data['MainSeq'], data['SubSeq'], data['BuyNo'],
        #           data['SellNo'], data['ExecType']))
@@ -119,11 +119,10 @@
            cls.__big_sell_order_info_list_dict[code] = []
        sell_no_map = local_today_sellno_map.get(code)
        total_datas = local_today_datas.get(code)
        if not sell_no_map:
            sell_no_map = {}
        for d in datas:
            if f"{d[7]}" in sell_no_map:
                continue
            cls.__latest_sell_order_info_list_dict[code].append(d)
            if code not in cls.__latest_sell_order_dict:
                cls.__latest_sell_order_dict[code] = [d[7], d[2], d[1], (d[3], d[6]), (d[3], d[6])]
@@ -139,10 +138,13 @@
                    # 大于50w的卖单才会保存
                    # 大于50w加入卖单
                    if info[1] * info[2] >= 500000:
                        l2_log.info(code, hx_logger_l2_transaction_sell_order, f"{cls.__latest_sell_order_dict[code]}")
                        cls.__big_sell_order_ids_dict[code].add(info[0])
                        cls.__big_sell_order_info_dict[code][info[0]] = info
                        cls.__big_sell_order_info_list_dict[code].append(info)
                        if f"{info[0]}"  not in sell_no_map or (buy_exec_index is not None and info[0] > int(
                                total_datas[buy_exec_index]["val"]["orderNo"])):
                            l2_log.info(code, hx_logger_l2_transaction_sell_order,
                                        f"{cls.__latest_sell_order_dict[code]}")
                            cls.__big_sell_order_ids_dict[code].add(info[0])
                            cls.__big_sell_order_info_dict[code][info[0]] = info
                            cls.__big_sell_order_info_list_dict[code].append(info)
                    cls.__latest_sell_order_dict[code] = [d[7], d[2], d[1], (d[3], d[6]), (d[3], d[6])]
        latest_time = l2_huaxin_util.convert_time(datas[-1][3], with_ms=True)
@@ -185,10 +187,12 @@
        # 统计最近的大单
        if latest_sell_order_info[1] * latest_sell_order_info[2] >= 500000:
            if latest_sell_order_info[0] not in temp_sell_order_ids:
                big_sell_orders.append(latest_sell_order_info)
                temp_sell_order_ids.add(latest_sell_order_info[0])
                total_sell_info[0] += int(latest_sell_order_info[1] * latest_sell_order_info[2])
                if f"{latest_sell_order_info[0]}" not in sell_no_map or (
                        buy_exec_index is not None and latest_sell_order_info[0] > int(
                        total_datas[buy_exec_index]["val"]["orderNo"])):
                    big_sell_orders.append(latest_sell_order_info)
                    temp_sell_order_ids.add(latest_sell_order_info[0])
                    total_sell_info[0] += int(latest_sell_order_info[1] * latest_sell_order_info[2])
        big_sell_orders.reverse()
        total_sell_info[1] = big_sell_orders
        return total_sell_info
l2/l2_transaction_data_processor.py
@@ -46,11 +46,14 @@
                buyno_map = {}
            order_begin_pos = l2_data_manager.TradePointManager().get_buy_compute_start_data_cache(code)
            # 是否已经下单
            is_placed_order = l2_data_manager.TradePointManager.is_placed_order(order_begin_pos)
            big_sell_order_info = None
            try:
                # 统计卖单
                big_sell_order_info = HuaXinSellOrderStatisticManager.add_transaction_datas(code, datas)
                big_sell_order_info = HuaXinSellOrderStatisticManager.add_transaction_datas(code, datas,
                                                                                            order_begin_pos.buy_exec_index if is_placed_order else None)
                need_cancel, cancel_msg = SCancelBigNumComputer().set_big_sell_order_info_for_cancel(code,
                                                                                                     big_sell_order_info,
                                                                                                     order_begin_pos)