Administrator
2025-02-12 1cc94691202a82c8f0cbe6586de648985f1fd58f
l2/l2_limitup_sell_data_manager.py
@@ -45,7 +45,7 @@
                val = d["val"]
                if L2DataUtil.is_limit_up_price_sell(val):
                    # 卖
                    order_no, price, volume = val["orderNo"], val["price"], val["num"]*100
                    order_no, price, volume = val["orderNo"], val["price"], val["num"] * 100
                    cls.__order_no_data_map_dict[code][order_no] = (order_no, price, volume)
                    cls.__order_no_set_dict[code].add(order_no)
                    cls.__delegating_sell_num_dict[code] += volume
@@ -80,18 +80,17 @@
        """
        try:
            limit_up_price = gpcode_manager.get_limit_up_price_as_num(code)
            has_limit_up_active_buy = False
            order_no_set = cls.__order_no_set_dict.get(code)
            if order_no_set is None:
                order_no_set = set()
            limit_up_active_buy_datas = []
            for d in datas:
                if d[1] != limit_up_price:
                    continue
                # 是否有涨停主动买成交
                if d[6] < d[7]:
                    continue
                has_limit_up_active_buy = True
                break
                limit_up_active_buy_datas.append(d)
            total_deal_volume = 0
            if code in cls.__delegating_sell_num_dict:
                for d in datas:
@@ -100,7 +99,9 @@
                        total_deal_volume += d[2]
                cls.__delegating_sell_num_dict[code] -= total_deal_volume
            if has_limit_up_active_buy:
            if len(limit_up_active_buy_datas):
                async_log_util.l2_data_log.info(hx_logger_l2_sell_deal,
                                                f"涨停主动买成交:{limit_up_active_buy_datas}")
                # 打印日志
                async_log_util.l2_data_log.info(hx_logger_l2_sell_deal,
                                                f"有涨停主动卖:{code}-{datas[-1][3]}-{cls.__delegating_sell_num_dict.get(code)}, 成交量-{total_deal_volume}")
@@ -127,22 +128,32 @@
if __name__ == "__main__":
    code = "300479"
    # 测试涨停总卖吃掉的情况
    code = "000887"
    datas = log_export.load_huaxin_l2_sell_deal(code).get(code)
    print(datas)
    deal_datas = []
    deal_order_no = set()
    for i in range(len(datas)):
        if tool.trade_time_sub(datas[i][0], "09:44:00") > 0:
            datas = datas[:i]
            break
    total_volume = sum([x[1] for x in datas])
    print("涨停卖成交", total_volume)
        if 102245 <= int(datas[i][0].replace(":", "")) <= 102318:
            deal_datas.append(datas[i])
    total_deal_volume = sum([x[1] for x in deal_datas])
    print("涨停卖成交量", total_deal_volume)
    datas = log_export.load_huaxin_l2_sell_delegate(code).get(code)
    fdatas = []
    for x in datas:
        if int("093206") < int(x[0].replace(":", "")) < int("094254"):
            fdatas.append(x)
    total_delegate = sum([x[2][2] for x in fdatas])
        if int("102245") < int(x[0].replace(":", "")) < int("102318"):
            if x[2][0]>=21531404:
                fdatas.append(x)
    total_delegate = 0
    for x in fdatas:
        if x[1] == '卖':
            total_delegate += x[2][2]
        elif x[1] == '卖撤':
            total_delegate -= x[2][2]
    print(fdatas)
    for d in fdatas:
        print(d)
    print("总委托", total_delegate, total_delegate * 20.41)
    print("总成交", total_deal_volume, total_deal_volume * 17.28)
    print("总委托", total_delegate, total_delegate * 17.28)
    print("委托剩余", total_delegate-total_deal_volume, (total_delegate-total_deal_volume) * 17.28)