admin
2025-04-09 e2ecb8701e756b72fe0481ee43eb68cc956c4532
L2级别的板上盯功能
4个文件已修改
79 ■■■■■ 已修改文件
main.py 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
strategy/data_cache.py 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
strategy/instant_time_market.py 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
strategy/selling_strategy.py 60 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main.py
@@ -17,7 +17,8 @@
# 引入瞬时分时行情模块
# 引入账户管理模块【进行资金和仓位管理】
from strategy import kpl_api, data_cache, check_timer, all_K_line, instant_time_market, account_management, \
    order_methods, local_data_management, kpl_data_manager, market_sentiment_analysis, plate_strength_analysis
    order_methods, local_data_management, kpl_data_manager, market_sentiment_analysis, plate_strength_analysis, \
    selling_strategy
from huaxin_client import l2_market_client, l2_client
from log_module import async_log_util
from trade import huaxin_trade_data_update, huaxin_trade_api
@@ -171,9 +172,12 @@
                if code in self.__last_price_dict:
                    if abs(limit_up_price - self.__last_price_dict[code]) < 0.0001 < abs(limit_up_price - price):
                        # TODO 处理炸板逻辑
                        # 炸板
                        logger_debug.info(f"炸板:{code}-({price},{time_str})")
                        # 监听了炸板了要做的函数
                        try:
                            selling_strategy.explosion_strategy(code)
                            # 炸板s
                        finally:
                            logger_debug.info(f"炸板:{code}-({price},{time_str})")
            finally:
                self.__last_price_dict[code] = price
strategy/data_cache.py
@@ -259,6 +259,11 @@
# 可以板上盯卖的代码
LIMIT_UP_SELL_CODES = set()
# L2炸板数据
L2_explosion_data = {}
# 最新的L1数据: {代码: L1数据}
current_l1_dict = {}
logging.info(f"全局初始化数据  完成《《《 - {os.getpid()}")
strategy/instant_time_market.py
@@ -58,6 +58,8 @@
# 调用所有以current信息为核心策略的函数
def strategic_thread_manager(current_info):
    if current_info is not None:
        symbol_code = current_info[0]
        data_cache.current_l1_dict[symbol_code] = current_info
        # 调用交易策略模块中的涨幅视界策略
        # 买入策略调用
        buying_strategy.growth_view_strategy(current_info)
strategy/selling_strategy.py
@@ -543,3 +543,63 @@
                                    order_methods.sell_order_by_part_volume(1, symbol, position_volume_yesterday,
                                                                            current_price,
                                                                            k_line_data[0]['sec_name'], index)
def explosion_strategy(code):
    if code not in data_cache.available_symbols_set:
        return
    current_info = data_cache.current_l1_dict.get(code)
    if not current_info:
        return
    # symbol = symbol_code
    symbol = basic_methods.format_stock_symbol(code)  # 转化为掘金数据来源的股票代码
    current_price = current_info[2]  # 获取当前最新价
    current_volume = current_info[3]  # 当日当时的总成交量
    current_quotes_sell = current_info[6]  # 卖5档数据
    k_line_data = data_cache.all_stocks_all_K_line_property_dict.get(symbol, None)
    position_info, index = None, None
    for i, element in enumerate(data_cache.account_positions_dict):
        if code == element['securityID']:  # 当循环到的持仓代码正好是current_data的代码时,即取得了持仓个股的行情快照数据
            position_info = element
            index = i
            break
    if not position_info:
        return
    position_volume_yesterday = position_info['availablePosition']  # 股份可用 (可用股份数量)  # 昨日持仓量(可用持仓量)
    if current_volume < k_line_data[0]['volume'] * 0.6:
        logger_info(
            f"【开盘临机】-【 炸板中!!且当日量不足】【{k_line_data[0]['sec_name']}】 卖一数量不等于0,设定委卖数量【十分之一仓】,当日当时量:{current_volume}")
        order_methods.sell_order_by_part_volume(0.1, symbol,
                                                position_volume_yesterday,
                                                current_price,
                                                k_line_data[0]['sec_name'],
                                                index)
    # 如果 卖二 量炸出来了,那么就是彻底炸开了。
    if current_quotes_sell[1][1] != 0:
        logger_info(
            f"【开盘临机】-【 炸板炸开了!!】【{k_line_data[0]['sec_name']}】 卖二数量不等于0,设定委卖数量【十分之二仓】,当日当时量:{current_volume}")
        order_methods.sell_order_by_part_volume(0.2, symbol,
                                                position_volume_yesterday,
                                                current_price,
                                                k_line_data[0]['sec_name'],
                                                index)
        if current_volume < k_line_data[0]['volume'] * 0.8:
            logger_info(
                f"【开盘临机】-【 炸板!!且当日量不足】【{k_line_data[0]['sec_name']}】 买盘小于1万 且 今日量小于昨日量的 0.8,当日当时量:{current_volume}")
            # 该股加入到板上盯卖的集合中  所以设定卖出全仓
            if symbol in data_cache.LIMIT_UP_SELL_CODES:
                logger_info(
                    f"【开盘临机】-【 炸板!!且当日量不足】【{k_line_data[0]['sec_name']}】 板上盯卖 |开启| 设定委卖【全仓】")
                order_methods.sell_order_by_part_volume(1, symbol,
                                                        position_volume_yesterday,
                                                        current_price,
                                                        k_line_data[0]['sec_name'],
                                                        index)
            else:
                logger_info(
                    f"【开盘临机】-【 炸板!!且当日量不足】【{k_line_data[0]['sec_name']}】 板上盯卖 |关闭| 设定委卖【十分之一仓】")
                order_methods.sell_order_by_part_volume(0.1, symbol,
                                                        position_volume_yesterday,
                                                        current_price,
                                                        k_line_data[0]['sec_name'],
                                                        index)