Administrator
4 天以前 48fb7a00951f91bdc707e5dd2d196e5bccb752c3
msg/buy_order_msg_manager.py
@@ -1,15 +1,21 @@
# 即将成交
from code_attribute import gpcode_manager
from l2 import l2_data_source_util, l2_data_util
import l2
import l2_data_util
from l2.l2_data_util import L2DataUtil
from log_module import async_log_util
from log_module.log import logger_kp_msg
from msg import push_msg_manager
from utils import output_util, tool
# 即将成交
def almost_deal(code, real_order_index, trade_index, total_datas):
def almost_deal(code, real_order_index, trade_index):
    total_datas = l2.l2_data_util.local_today_datas.get(code)
    if trade_index > real_order_index:
        return
    # 下单3s过后再提醒
    if tool.trade_time_sub(total_datas[-1]["val"]["time"], total_datas[real_order_index]["val"]["time"]) <= 3:
    if tool.trade_time_sub(total_datas[-1]["val"]["time"], total_datas[real_order_index]["val"]["time"]) <= 5:
        return
    total_left_count = 0
    total_left_money = 0
@@ -20,11 +26,11 @@
            continue
        if val["num"] * float(val["price"]) < 5000:
            continue
        left_count = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count_v2(code,
                                                                                                 i,
                                                                                                 total_datas,
                                                                                                 l2_data_util.local_today_canceled_buyno_map.get(
                                                                                                     code))
        left_count = l2.l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count_v2(code,
                                                                                                    i,
                                                                                                    total_datas,
                                                                                                    l2.l2_data_util.local_today_canceled_buyno_map.get(
                                                                                                        code))
        if left_count > 0:
            total_left_count += left_count
            total_left_money += val["num"] * left_count * float(val["price"]) * 100
@@ -32,19 +38,28 @@
    if total_left_count <= 10:
        push_msg_manager.push_order_almost_deal(code, code_name, real_order_index, f"剩余:{total_left_count}笔",
                                                ctype="count")
        async_log_util.info(logger_kp_msg,
                            f"{code}即将成交:trade_index-{trade_index},real_order_index-{real_order_index},剩余:{total_left_count}笔,结尾:{total_datas[-1]['index']}")
    elif total_left_money < 1500 * 10000:
        push_msg_manager.push_order_almost_deal(code, code_name, real_order_index,
                                                f"剩余:{output_util.money_desc(total_left_money)}", ctype="money")
        async_log_util.info(logger_kp_msg,
                            f"{code}即将成交:trade_index-{trade_index},real_order_index-{real_order_index},剩余:{total_left_money}元,结尾:{total_datas[-1]['index']}")
# 真实下单位后面跟单不足
def follow_not_enough(code, buy_exec_index, real_order_index, total_datas):
def follow_not_enough(code, buy_exec_index, real_order_index):
    if buy_exec_index > real_order_index:
        return
    total_datas = l2.l2_data_util.local_today_datas.get(code)
    # 下单3s过后再提醒
    if tool.trade_time_sub(total_datas[-1]["val"]["time"], total_datas[buy_exec_index]["val"]["time"]) <= 3:
    if tool.trade_time_sub(total_datas[-1]["val"]["time"], total_datas[buy_exec_index]["val"]["time"]) <= 5:
        return
    real_place_order_after_count = 0
    real_place_order_after_money = 0
    is_ge_code = tool.is_ge_code(code)
    # 统计真实下单位置后面未撤的金额
    for i in range(real_order_index, total_datas[-1]["index"]):
@@ -52,14 +67,14 @@
        if not L2DataUtil.is_limit_up_price_buy(val):
            continue
        # 是不是大单
        if not l2_data_util.is_big_money(val):
        if not l2_data_util.is_big_money(val, is_ge_code):
            continue
        canceled_data = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_canceled_data_v2(code,
                                                                                                i,
                                                                                                total_datas,
                                                                                                l2_data_util.local_today_canceled_buyno_map.get(
                                                                                                    code))
        canceled_data = l2.l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_canceled_data_v2(code,
                                                                                                   i,
                                                                                                   total_datas,
                                                                                                   l2.l2_data_util.local_today_canceled_buyno_map.get(
                                                                                                       code))
        if not canceled_data:
            real_place_order_after_count += 1
            real_place_order_after_money += val["num"] * float(val["price"]) * 100
@@ -69,7 +84,12 @@
        push_msg_manager.push_delegate_order_danger(code, code_name, buy_exec_index,
                                                    f"剩余:{real_place_order_after_count}笔",
                                                    ctype="count")
        async_log_util.info(logger_kp_msg,
                            f"{code}封单不足:buy_exec_index-{buy_exec_index},real_order_index-{real_order_index},剩余:{real_place_order_after_count}笔,结尾:{total_datas[-1]['index']}")
    if real_place_order_after_money <= 1500 * 10000:
        push_msg_manager.push_delegate_order_danger(code, code_name, buy_exec_index,
                                                    f"剩余:{output_util.money_desc(real_place_order_after_money)}",
                                                    ctype="money")
        async_log_util.info(logger_kp_msg,
                            f"{code}封单不足:buy_exec_index-{buy_exec_index},real_order_index-{real_order_index},剩余:{real_place_order_after_money}元,结尾:{total_datas[-1]['index']}")