Administrator
2023-11-20 cf67d073d96ab1349ac74ac5caf7dab40f214226
板上卖算入大单成交
4个文件已修改
65 ■■■■ 已修改文件
l2/cancel_buy_strategy.py 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/l2_data_manager_new.py 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/l2_data_util.py 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/l2_transaction_data_manager.py 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/cancel_buy_strategy.py
@@ -16,7 +16,9 @@
from db import redis_manager_delegate as redis_manager
from db.redis_manager_delegate import RedisUtils
from l2.l2_data_manager import OrderBeginPosInfo
from l2.l2_sell_manager import L2LimitUpSellManager
from log_module import async_log_util
from trade.deal_big_money_manager import DealOrderNoManager
from utils import tool
from l2.transaction_progress import TradeBuyQueue
from trade import trade_queue_manager, l2_trade_factor, trade_record_log_util
@@ -869,6 +871,27 @@
        cls.__big_num_deal_rate_dict[code] = rate
        l2_log.l_cancel_debug(code, f"设置大单成交金额比值:{rate}")
    @classmethod
    def compute_big_num_deal_rate(cls, code):
        total_datas = local_today_datas.get(code)
        # 获取成交大单手数
        total_deal_nums = DealOrderNoManager().get_deal_nums(code, local_today_buyno_map.get(code))
        # 获取板上卖手数
        total_sell_nums = 0
        sell_indexs = L2LimitUpSellManager().get_limit_up_sell_indexes(code)
        if sell_indexs:
            for index in sell_indexs:
                total_sell_nums += total_datas[index]["val"]["num"]
        l2_log.l_cancel_debug(code, f"大单买-{total_deal_nums} 板上卖-{total_sell_nums}")
        total_deal_nums -= total_sell_nums
        if total_deal_nums < 0:
            total_deal_nums = 0
        thresh_hold_money = l2_trade_factor.L2PlaceOrderParamsManager.get_base_m_val(code)
        limit_up_price = gpcode_manager.get_limit_up_price(code)
        if limit_up_price:
            rate = round(total_deal_nums / (thresh_hold_money // (float(limit_up_price) * 100)), 2)
            cls.set_big_num_deal_rate(code, rate)
# 计算成交位置之后的大单(特定笔数)的撤单比例
class LCancelBigNumComputer:
l2/l2_data_manager_new.py
@@ -9,7 +9,7 @@
from code_attribute.code_nature_analyse import HighIncreaseCodeManager
from db.redis_manager_delegate import RedisUtils
from l2.huaxin import l2_huaxin_util, huaxin_delegate_postion_manager
from l2.l2_sell_manager import L2MarketSellManager
from l2.l2_sell_manager import L2MarketSellManager, L2LimitUpSellManager
from l2.transaction_progress import TradeBuyQueue
from log_module import async_log_util, log_export
from third_data import kpl_data_manager, block_info
@@ -22,7 +22,7 @@
from l2 import l2_data_manager, l2_log, l2_data_source_util, code_price_manager, \
    transaction_progress, cancel_buy_strategy, l2_data_log
from l2.cancel_buy_strategy import SecondCancelBigNumComputer, HourCancelBigNumComputer, DCancelBigNumComputer, \
    LCancelBigNumComputer, LatestCancelIndexManager, FastCancelBigNumComputer
    LCancelBigNumComputer, LatestCancelIndexManager, FastCancelBigNumComputer, LCancelRateManager
from l2.l2_data_manager import L2DataException, OrderBeginPosInfo
from l2.l2_data_util import local_today_datas, L2DataUtil, local_today_num_operate_map, local_today_buyno_map, \
    local_latest_datas, local_today_canceled_buyno_map
@@ -235,6 +235,7 @@
    __TradeOrderIdManager = trade_huaxin.TradeOrderIdManager()
    __LatestCancelIndexManager = LatestCancelIndexManager()
    __L2MarketSellManager = L2MarketSellManager()
    __L2LimitUpSellManager = L2LimitUpSellManager()
    # 获取代码评分
    @classmethod
@@ -403,6 +404,21 @@
            #                                    "l2数据准备时间")
            # 时间差不能太大才能处理
            if not l2_trade_util.is_in_forbidden_trade_codes(code):
                # 计算板上卖,当数据少时才计算,否则不计算
                try:
                    if len(add_datas) < 20:
                        has_limit_up_sell = False
                        for d in add_datas:
                            if L2DataUtil.is_limit_up_price_sell(d["val"]):
                                cls.__L2LimitUpSellManager.add_limit_up_sell(code, d["index"])
                                has_limit_up_sell = True
                        if has_limit_up_sell:
                            LCancelRateManager.compute_big_num_deal_rate(code)
                        # elif L2DataUtil.is_limit_up_price_sell_cancel(d["val"]):
                        #     cls.__L2LimitUpSellManager.add_limit_up_sell(code, d["index"])
                except Exception as e:
                    async_log_util.error(logger_l2_error, f"计算板上卖出错:{str(e)}")
                # 判断是否已经挂单
                state = cls.__CodesTradeStateManager.get_trade_state_cache(code)
                start_index = len(total_datas) - len(add_datas)
l2/l2_data_util.py
@@ -408,11 +408,16 @@
        if int(val["operateType"]) != 2:
            return False
        return True
        price = float(val["price"])
        num = int(val["num"])
        # if price * num * 100 < 50 * 10000:
        #     return False
    # 涨停卖撤
    @classmethod
    def is_limit_up_price_sell_cancel(cls, val):
        if int(val["limitPrice"]) != 1:
            return False
        if int(val["operateType"]) != 3:
            return False
        return True
    # 是否涨停买撤
l2/l2_transaction_data_manager.py
@@ -130,14 +130,7 @@
                    # L后是否有成交,如果有成交就需要除去当前笔数,然后重新囊括一笔
                    LCancelBigNumComputer().add_deal_index(code, data["index"], order_begin_pos.buy_single_index)
            if big_money_count > 0:
                # 统计大单/m值成交比
                total_deal_nums = DealOrderNoManager().get_deal_nums(code, buyno_map)
                thresh_hold_money = l2_trade_factor.L2PlaceOrderParamsManager.get_base_m_val(code)
                limit_up_price = gpcode_manager.get_limit_up_price(code)
                if limit_up_price:
                    rate = round(total_deal_nums / (thresh_hold_money // (float(limit_up_price) * 100)), 2)
                    LCancelRateManager().set_big_num_deal_rate(code, rate)
                    # 获取执行位时间
                LCancelRateManager.compute_big_num_deal_rate(code)
            buy_progress_index = self.__compute_latest_trade_progress(code, buyno_map, datas)
            if buy_progress_index is not None: