Administrator
2024-05-16 0b6850cb641bf704b7feb050a6e481553f639e06
S重砸修改/大单重新定义
9个文件已修改
152 ■■■■ 已修改文件
l2/cancel_buy_strategy.py 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/l2_data_manager_new.py 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/l2_data_util.py 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/l2_transaction_data_processor.py 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2_data_util.py 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
msg/buy_order_msg_manager.py 30 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
output/l2_output_util.py 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/current_price_process_manager.py 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/huaxin/huaxin_trade_server.py 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/cancel_buy_strategy.py
@@ -418,10 +418,10 @@
        zyltgb_unit_y = round(zyltgb / 100000000, 1)
        limit_up_price = gpcode_manager.get_limit_up_price(code)
        limit_up_price = round(float(limit_up_price), 2)
        # 有超大单砸
        # 有超大单砸 S重砸
        threshold_big_deal = (2 * zyltgb_unit_y + 339) * 10000
        if total_deal_money >= threshold_big_deal:
            # S撤重砸必撤的金额满足以后,以前是无脑撤。现在优化一下,看成交进度位---真实下单位的区间额≤重砸金额*5倍,就撤。
            # S重砸必撤的金额满足以后,以前是无脑撤。现在优化一下,看成交进度位---真实下单位的区间额≤重砸金额*3.3倍,就撤。
            try:
                need_compute = False
                trade_index, is_default = TradeBuyQueue().get_traded_index(code)
@@ -434,7 +434,8 @@
                    total_count, total_num = L2DataComputeUtil.compute_left_buy_order(code, trade_index,
                                                                                      real_order_index_info[0],
                                                                                      limit_up_price)
                    if total_num * limit_up_price * 100 < 5 * total_deal_money:
                    if total_deal_money / (total_num * limit_up_price * 100) >= 0.3:
                        # 大单成交额占总剩余总囊括的30%
                        return True, f"1s内大于{threshold_big_deal}大卖单({total_deal_money})"
                else:
                    return True, f"1s内大于{threshold_big_deal}大卖单({total_deal_money})"
l2/l2_data_manager_new.py
@@ -988,18 +988,22 @@
            # 1.当前成交价为涨停价
            # 2.总卖额为0
            if abs(float(limit_up_price) - float(trade_price)) < 0.001:
                sell_data = cls.__L2MarketSellManager.get_current_total_sell_data(code)
                if sell_data and sell_data[1] <= 0:
                    # 板上放量,判断是否有放量,放量才会下单
                    # 获取最近1s的主动卖金额
                    min_time = total_data[order_begin_pos.buy_single_index]['val']['time']
                    min_time = tool.trade_time_add_second(min_time, -1)
                    sell_orders = HuaXinSellOrderStatisticManager.get_latest_transaction_datas(code,
                                                                                               min_deal_time=min_time)
                    sell_order_num = sum([x[1] for x in sell_orders])
                    sell_money = int(float(limit_up_price) * sell_order_num)
                    if sell_money < 200000:
                        return False, True, f"板上放量金额不足,近1s总卖:{sell_money}小于20w"
                # 获取最近的非涨停价成交时间
                not_limit_up_info = current_price_process_manager.get_trade_not_limit_up_info(code)
                if not not_limit_up_info or tool.trade_time_sub( total_data[-1]['val']['time'], not_limit_up_info[1])>10:
                    # 非涨停价成交10s后才有可能判断为板上放量
                    sell_data = cls.__L2MarketSellManager.get_current_total_sell_data(code)
                    if sell_data and sell_data[1] <= 0:
                        # 板上放量,判断是否有放量,放量才会下单
                        # 获取最近1s的主动卖金额
                        min_time = total_data[order_begin_pos.buy_single_index]['val']['time']
                        min_time = tool.trade_time_add_second(min_time, -1)
                        sell_orders = HuaXinSellOrderStatisticManager.get_latest_transaction_datas(code,
                                                                                                   min_deal_time=min_time)
                        sell_order_num = sum([x[1] for x in sell_orders])
                        sell_money = int(float(limit_up_price) * sell_order_num)
                        if sell_money < 200000:
                            return False, True, f"板上放量金额不足,近1s总卖:{sell_money}小于20w"
            # 判断成交进度是否距离我们的位置很近
            trade_index, is_default = cls.__TradeBuyQueue.get_traded_index(code)
            if False and not is_default and trade_index:
l2/l2_data_util.py
@@ -295,23 +295,6 @@
    return False
# 是否为大单
def is_big_money(val):
    price = float(val["price"])
    money = price * int(val["num"])
    if price > 3.0:
        if money >= 29900:
            return True
        else:
            return False
    else:
        max_money = price * 10000
        if money >= max_money * 0.95:
            return True
        else:
            return False
class L2DataUtil:
    @classmethod
    def is_same_time(cls, time1, time2):
l2/l2_transaction_data_processor.py
@@ -74,8 +74,14 @@
    @classmethod
    def process_huaxin_transaction_datas(cls, code, datas):
        __start_time = time.time()
        limit_up_price = gpcode_manager.get_limit_up_price(code)
        if limit_up_price:
            limit_up_price = round(float(limit_up_price), 2)
        # 设置成交价
        current_price_process_manager.set_trade_price(code, datas[-1][1])
        try:
            current_price_process_manager.set_trade_price(code, datas[-1][1], l2_huaxin_util.convert_time( datas[-1][3]), limit_up_price)
        except:
            pass
        total_datas = l2_data_util.local_today_datas.get(code)
        use_time_list = []
        try:
@@ -89,9 +95,7 @@
            big_sell_order_info = None
            try:
                limit_up_price = gpcode_manager.get_limit_up_price(code)
                if limit_up_price:
                    limit_up_price = round(float(limit_up_price), 2)
                # 统计卖单
                big_sell_order_info = HuaXinSellOrderStatisticManager.add_transaction_datas(code, datas, limit_up_price)
l2_data_util.py
@@ -32,7 +32,7 @@
    price = float(val["price"])
    money = price * val["num"]
    if price > 3.0:
        if money >= 29900:
        if money >= 29900 or val["num"] >= 7999:
            return True
        else:
            return False
@@ -47,7 +47,7 @@
# 获取大资金的金额
def get_big_money_val(limit_up_price):
    if limit_up_price > 3.0:
        return 299 * 10000
        return min(299 * 10000, round(limit_up_price * 7999))
    else:
        max_money = limit_up_price * 10000
        return max_money * 0.95
@@ -179,7 +179,8 @@
        if abs(get_time_as_seconds(time_str) - get_time_as_seconds(time_)) > 3:
            continue
        if same_time_nums[time_] > 20:
            RedisUtils.setex(l2_data_manager._redisManager.getRedis(), "big_data-{}-{}".format(code, int(round(time.time() * 1000))), tool.get_expire(),
            RedisUtils.setex(l2_data_manager._redisManager.getRedis(),
                             "big_data-{}-{}".format(code, int(round(time.time() * 1000))), tool.get_expire(),
                             d1)
            break
@@ -192,7 +193,7 @@
# 获取最新数据条数
def get_l2_latest_data_number(code):
    num =RedisUtils.get(l2_data_manager._redisManager.getRedis(), "l2_latest_data_num-{}".format(code))
    num = RedisUtils.get(l2_data_manager._redisManager.getRedis(), "l2_latest_data_num-{}".format(code))
    if num is not None:
        return int(num)
    return None
msg/buy_order_msg_manager.py
@@ -1,6 +1,7 @@
# 即将成交
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
@@ -10,7 +11,7 @@
# 即将成交
def almost_deal(code, real_order_index, trade_index):
    total_datas = l2_data_util.local_today_datas.get(code)
    total_datas = l2.l2_data_util.local_today_datas.get(code)
    if trade_index > real_order_index:
        return
    # 下单3s过后再提醒
@@ -25,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
@@ -37,7 +38,8 @@
    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']}")
        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,
@@ -50,7 +52,7 @@
def follow_not_enough(code, buy_exec_index, real_order_index):
    if buy_exec_index > real_order_index:
        return
    total_datas = l2_data_util.local_today_datas.get(code)
    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"]) <= 5:
        return
@@ -67,11 +69,11 @@
        if not l2_data_util.is_big_money(val):
            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
output/l2_output_util.py
@@ -55,9 +55,12 @@
        trade_index = 0
    threshold_before_count = max_count // 2
    fresults = __get_trade_queue(code, real_place_order_index, trade_index - 1,real_place_order_index, threshold_before_count, -1)
    fresults = __get_trade_queue(code, real_place_order_index, trade_index - 1, real_place_order_index,
                                 threshold_before_count, -1)
    fresults.reverse()
    fresults.extend(__get_trade_queue(code, real_place_order_index+1,  total_datas[-1]['index'] + 1, real_place_order_index, max_count - threshold_before_count, 1))
    fresults.extend(
        __get_trade_queue(code, real_place_order_index + 1, total_datas[-1]['index'] + 1, real_place_order_index,
                          max_count - threshold_before_count, 1))
    return fresults
@@ -75,9 +78,6 @@
        trade_index = 0
    # 前面最多取5条数据
    fresults = []
    fresults.extend(__get_trade_queue(code, trade_index,  total_datas[-1]['index'] + 1,real_place_order_index,  max_count, 1))
    fresults.extend(
        __get_trade_queue(code, trade_index, total_datas[-1]['index'] + 1, real_place_order_index, max_count, 1))
    return fresults
trade/current_price_process_manager.py
@@ -190,12 +190,28 @@
__trade_price_dict = {}
# 最近的非涨停价成交的信息,数据结构:{code:(价格,时间)}
__trade_price_not_limit_up_info_dict = {}
# 设置成交价
def set_trade_price(code, price):
def set_trade_price(code, price, time_str, limit_up_price):
    __trade_price_dict[code] = price
    # 需要记录最近一次非涨停价成交的时间
    if limit_up_price and abs(limit_up_price - price) > 0.001:
        # 非涨停价成交
        __trade_price_not_limit_up_info_dict[code] = (price, time_str)
# 获取成交价
def get_trade_price(code):
    return __trade_price_dict.get(code)
def get_trade_not_limit_up_info(code):
    """
    获取最近的非涨停价成交的信息
    @param code:
    @return:(价格,时间)
    """
    return __trade_price_not_limit_up_info_dict.get(code)
trade/huaxin/huaxin_trade_server.py
@@ -55,7 +55,7 @@
from third_data.kpl_util import KPLDataType
from trade import trade_manager, l2_trade_util, \
    l2_trade_factor, trade_data_manager
from trade.deal_big_money_manager import DealOrderNoManager
import l2_data_util as l2_data_util_old
from trade.huaxin import huaxin_trade_api as trade_api, huaxin_trade_api, huaxin_trade_data_update, \
    huaxin_trade_record_manager, huaxin_trade_order_processor, huaxin_sell_util
@@ -1444,7 +1444,7 @@
                                if not L2DataUtil.is_limit_up_price_buy(val):
                                    continue
                                # 是不是大单
                                if not l2_data_util.is_big_money(val):
                                if not l2_data_util_old.is_big_money(val):
                                    continue
                                canceled_data = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_canceled_data_v2(
@@ -1468,7 +1468,7 @@
                                if not L2DataUtil.is_limit_up_price_buy(val):
                                    continue
                                # 是不是大单
                                if not l2_data_util.is_big_money(val):
                                if not l2_data_util_old.is_big_money(val):
                                    continue
                                canceled_data = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_canceled_data_v2(
@@ -1502,7 +1502,7 @@
                                if not L2DataUtil.is_limit_up_price_buy(val):
                                    continue
                                # 是不是大单
                                if not l2_data_util.is_big_money(val):
                                if not l2_data_util_old.is_big_money(val):
                                    continue
                                canceled_data = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_canceled_data_v2(
@@ -1592,7 +1592,7 @@
                                if real_place_order_index is not None:
                                    trade_queue = l2_output_util.get_trade_queue_at_near_place_order(code,
                                                                                                     real_place_order_index,
                                                                                                     11)
                                                                                                     9)
                                    fdata['trade_queue'] = trade_queue
                            except:
                                pass
@@ -1680,11 +1680,8 @@
                if count is None:
                    count = 100
                real_place_order_index = SCancelBigNumComputer().get_real_place_order_index_cache(code)
                if real_place_order_index is not None:
                    trade_queue = l2_output_util.get_trade_queue(code, real_place_order_index, count)
                    self.send_response({"code": 0, "data": trade_queue}, client_id, request_id)
                else:
                    raise Exception("没获取到真实下单位")
                trade_queue = l2_output_util.get_trade_queue(code, real_place_order_index, count)
                self.send_response({"code": 0, "data": trade_queue}, client_id, request_id)
        except Exception as e:
            logging.exception(e)
            self.send_response({"code": 1, "msg": f"数据处理出错:{e}"}, client_id, request_id)