admin
2025-04-11 1e29252aa811815f202a4d31f264b19c8d76def3
L1数据处理流程优化
5个文件已修改
827 ■■■■ 已修改文件
main.py 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
strategy/buying_strategy.py 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
strategy/instant_time_market.py 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
strategy/market_sentiment_analysis.py 58 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
strategy/selling_strategy.py 750 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main.py
@@ -20,7 +20,7 @@
    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 log_module import async_log_util, log
from trade import huaxin_trade_data_update, huaxin_trade_api
from utils import hx_qc_value_util, huaxin_util, juejin_api, tool
@@ -225,6 +225,7 @@
# 第三步:执行策略的初始设置
if __name__ == '__main__':
    log.close_print()
    class MyMarketDataCallback(l2_market_client.L2MarketDataCallback):
        def on_markets(self, datas):
            """
@@ -233,8 +234,6 @@
            :return:
            """
            data_cache.latest_code_market_info_dict = {x[0]: x for x in datas}
            if datas:
                print(datas[0])
            if constant.is_windows():
                instant_time_market.get_current_info()
            else:
strategy/buying_strategy.py
@@ -203,8 +203,9 @@
                # 查询当前个股的代码是否在板块强度个股列表中(低吸优选目标)
                strength_list_have_it = False  # 为查询结果赋初值
                strength_plate = []
                market_sift_plate_stock_dict = data_cache.market_sift_plate_stock_dict
                # 遍历字典的每个键值对
                for key, values in data_cache.market_sift_plate_stock_dict.items():
                for key, values in market_sift_plate_stock_dict.items():
                    # 遍历每个键对应的列表中的列表
                    for stock_list in values:
                        if len(stock_list) > 1 and symbol_code in stock_list[1]:
strategy/instant_time_market.py
@@ -58,8 +58,6 @@
# 调用所有以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)
@@ -296,6 +294,11 @@
            #         print(f"i===={i}")
            get_all_stocks_current_open(current_infos)
            get_all_stocks_current_high_and_low(current_infos)
            # 保存现价
            for current_info in current_infos:
                data_cache.current_l1_dict[current_info[0]] = current_info
            for current_info in current_infos:
                try:
                    if current_info is not None:
@@ -343,6 +346,10 @@
        get_all_stocks_current_open(current_infos)
        get_all_stocks_current_high_and_low(current_infos)
        if current_infos:
            # 保存现价
            for current_info in current_infos:
                data_cache.current_l1_dict[current_info[0]] = current_info
            # 分批处理数据
            ds = []
            total_count = len(current_infos)
strategy/market_sentiment_analysis.py
@@ -465,14 +465,10 @@
        """计算市场关键指标因子"""
        factors = {}
        # 总票数
        total_stocks = zero + rise_one + rise_two + rise_three + rise_four + rise_five + rise_six + rise_seven + rise_eight + rise_nine + rise_ten + fall_one + fall_two + fall_three + fall_four + fall_five + fall_six + fall_seven + fall_eight + fall_nine + fall_ten
        print(f"total_stocks = {total_stocks}")
        factors['total_stocks'] = total_stocks
        # 涨跌统计(排除0%)
        rise = rise_one + rise_two + rise_three + rise_four + rise_five + rise_six + rise_seven + rise_eight + rise_nine + rise_ten
        fall = fall_one + fall_two + fall_three + fall_four + fall_five + fall_six + fall_seven + fall_eight + fall_nine + fall_ten
        # 涨跌统计
        calm_dirt = {
            'zero': zero
        }
        rise_dirt = {
            'rise_one': rise_one,
            'rise_two': rise_two,
@@ -497,21 +493,38 @@
            'fall_nine': fall_nine,
            'fall_ten': fall_ten,
        }
        # 计算所有值的总和
        total_sum = sum(rise_dirt.values())
        # 计算每个键的值占总和的百分比
        percentages = {key: round((value / total_sum) * 100, 2) for key, value in rise_dirt.items()}
        rise_and_fall_dirt = {}
        rise_and_fall_dirt.update(calm_dirt)
        rise_and_fall_dirt.update(rise_dirt)
        rise_and_fall_dirt.update(fall_dirt)
        # 计算涨跌统计所有股票数量总和
        rise_and_fall_sum = sum(rise_and_fall_dirt.values())
        # 总票数
        factors['total_stocks'] = rise_and_fall_sum
        # 计算上涨股票数量的和
        rise_sum = sum(rise_dirt.values())
        # 计算上涨股票数量的和
        fall_sum = sum(fall_dirt.values())
        # 计算每个键(每个幅段)的值占总和的百分比
        percentages = {key: round((value / rise_and_fall_sum) * 100, 2) for key, value in rise_and_fall_dirt.items()}
        # # 计算每个键(每个涨幅段)的值占总和的百分比
        # rise_percentages = {key: round((value / total_sum) * 100, 2) for key, value in rise_dirt.items()}
        # # 计算每个键(每个涨幅段)的值占总和的百分比
        # fall_percentages = {key: round((value / total_sum) * 100, 2) for key, value in fall_dirt.items()}
        # 找到最大值对应的键
        max_key = max(rise_dirt, key=rise_dirt.get)
        max_key = max(rise_and_fall_dirt, key=rise_and_fall_dirt.get)
        # 找到最小值对应的键
        min_key = min(rise_dirt, key=rise_dirt.get)
        min_key = min(rise_and_fall_dirt, key=rise_and_fall_dirt.get)
        # 涨跌比因子 ---------------------------------------------------
        factors['rise_vs_fall'] = {
            'rise_vs_fall_ratio': rise / fall if fall > 0 else 0,  # 涨跌比
            'rise_vs_fall_ratio': round(rise_sum / fall_sum, 2) if fall_sum > 0 else 0,  # 涨跌比
            'rise_gather_area': max_key,  # 找到最大值
            'rise_scattered_area': min_key,  # 找到最小值
            'percentages': percentages,  # 找到最小值
            'percentages': percentages,  # 各个涨幅段的股票分布比例
            # 'rise_percentages': rise_percentages,  # 各个涨幅段的股票分布比例
            # 'fall_percentages': fall_percentages,  # 各个跌幅段的股票分布比例
            'rise_and_fall_sum': rise_and_fall_sum
        }
        # 资金流向因子 --------------------------------------------------
@@ -523,16 +536,16 @@
        # 市场情绪因子 --------------------------------------------------
        factors['sentiment'] = {
            'zt_ratio': data['ZT'] / total_stocks,  # 涨停占总比
            'zt_ratio': data['ZT'] / rise_and_fall_sum,  # 涨停占总比
            'zt_vs_dt_ratio': data['ZT'] / data['DT'],  # 涨停跌停比
            'sign': 1 if '较好' in data['sign'] else 0,  # 情绪标签量化
            'rise_vs_all_stocks_ratio': data['SZJS'] / total_stocks,  # 活跃股占比
            'rise_vs_all_stocks_ratio': data['SZJS'] / rise_and_fall_sum,  # 活跃股占比
            'rise_vs_fall_ratio': data['SZJS'] / data['SZJS'],  # 活跃股占比
            'extreme_ratio': (data['ZT'] + data['DT']) / total_stocks,  # 极端波动(涨停+跌停占总比)
            'extreme_ratio': (data['ZT'] + data['DT']) / rise_and_fall_sum,  # 极端波动(涨停+跌停占总比)
        }
        return factors
#
# # ====================== 策略信号生成 ======================
def generate_signals(factors):
    """生成多维度交易信号"""
@@ -671,8 +684,9 @@
    print(f"资金净流入(元): {factors['capital_flow']['net']:,}")
    print(f"涨停股占比: {factors['sentiment']['zt_ratio']:.2%}")
    print(f"市场情绪量化: {'积极' if factors['sentiment']['sign'] else '谨慎'}")
    print(f"上涨聚集区域:{factors['rise_vs_fall']['rise_gather_area']}")
    print(f"上涨零散区域:{factors['rise_vs_fall']['percentages']}")
    print(f"聚集区域:{factors['rise_vs_fall']['rise_gather_area']}")
    print(f"零散区域:{factors['rise_vs_fall']['rise_scattered_area']}")
    print(f"涨跌因子字典={factors['rise_vs_fall']}")
    print("\n========== 策略信号 ==========")
    for i, signal in enumerate(signals, 1):
strategy/selling_strategy.py
@@ -138,411 +138,415 @@
    # :return: {'code': 0, 'data': [{'investorID': '00044396', 'tradingDay': '20250109', 'securityName': '海得控制', 'securityID': '002184', 'historyPos': 0, 'historyPosFrozen': 0, 'todayBSPos': 1000, 'todayBSPosFrozen': 0, 'historyPosPrice': 0.0, 'totalPosCost': 20316.176271, 'prePosition': 0, 'availablePosition': 0, 'currentPosition': 1000, 'openPosCost': 20310.0, 'todayCommission': 6.176271, 'todayTotalBuyAmount': 20310.0, 'todayTotalSellAmount': 0.0}, {'investorID': '00044396', 'tradingDay': '20250109', 'securityName': '省广集团', 'securityID': '002400', 'historyPos': 0, 'historyPosFrozen': 0, 'todayBSPos': 0, 'todayBSPosFrozen': 0, 'historyPosPrice': 0.0, 'totalPosCost': 0.0, 'prePosition': 0, 'availablePosition': 0, 'currentPosition': 0, 'openPosCost': 0.0, 'todayCommission': 0.0, 'todayTotalBuyAmount': 8230.0, 'todayTotalSellAmount': 0.0}]}
    # print(f"data_cache.account_positions_dict==={data_cache.account_positions_dict}")
    if data_cache.account_positions_dict is not None:
        for index, element in enumerate(data_cache.account_positions_dict):
    account_positions_dict = data_cache.account_positions_dict
    if account_positions_dict is not None:
        for index, element in enumerate(account_positions_dict):
            # print(f"index=={index}")
            # print(f"element=={element}")
            element_symbol = basic_methods.format_stock_symbol(element['securityID'])
            if symbol_code == element['securityID']:  # 当循环到的持仓代码正好是current_data的代码时,即取得了持仓个股的行情快照数据
                # logger_info(f"index = {index}")
                # logger_info(f"element = {element}")
                account_positions_symbol = element_symbol  # 当前循环到的持仓个股代码
                # print(f"account_positions_symbol==={account_positions_symbol}")
                # available_now = element['available_now']  # 当前个股可用金额
                # price = d['price']   #当前行情价,,,非最新价,没有实际意义不要用!!!
                vwap = element['historyPosPrice']  # 当前个股持仓均价/成本价
                position_volume = element['currentPosition']  # 当前个股持仓总量
                position_volume_today = element['todayTotalBuyAmount']  # 今日持仓量
                position_volume_yesterday = element['availablePosition']  # 股份可用 (可用股份数量)  # 昨日持仓量(可用持仓量)
                # print(symbol,available_now, price, vwap)
                # print(f"current_open=={current_open}")
                # print(f"current_price=={current_price}")
                # print(f"current_high=={current_high}")
                # print(f"current_low=={current_low}")
                # print(f"current_amount 总成交额 ==={round(current_amount / 10000, 2)} 万")
                # print(f"current_volume 总成交量 ==={round(current_volume / 10000, 2)} 万")
                # # print(f"current_last_volume 上一刻 总成交量 === {round(current_last_volume/10000, 2)} 万")
                # print(f"last_volume  瞬时成交量==={round(current_last_volume, 2)}")
                # print(f"current_quotes_buy=={current_quotes_buy}")
                # print(f"current_quotes_sell=={current_quotes_sell}")
            if symbol_code != element['securityID']:
                continue
            # 当循环到的持仓代码正好是current_data的代码时,即取得了持仓个股的行情快照数据
            # logger_info(f"index = {index}")
            # logger_info(f"element = {element}")
            account_positions_symbol = element_symbol  # 当前循环到的持仓个股代码
            # print(f"account_positions_symbol==={account_positions_symbol}")
            # available_now = element['available_now']  # 当前个股可用金额
            # price = d['price']   #当前行情价,,,非最新价,没有实际意义不要用!!!
            vwap = element['historyPosPrice']  # 当前个股持仓均价/成本价
            position_volume = element['currentPosition']  # 当前个股持仓总量
            position_volume_today = element['todayTotalBuyAmount']  # 今日持仓量
            position_volume_yesterday = element['availablePosition']  # 股份可用 (可用股份数量)  # 昨日持仓量(可用持仓量)
            # print(symbol,available_now, price, vwap)
            # print(f"current_open=={current_open}")
            # print(f"current_price=={current_price}")
            # print(f"current_high=={current_high}")
            # print(f"current_low=={current_low}")
            # print(f"current_amount 总成交额 ==={round(current_amount / 10000, 2)} 万")
            # print(f"current_volume 总成交量 ==={round(current_volume / 10000, 2)} 万")
            # # print(f"current_last_volume 上一刻 总成交量 === {round(current_last_volume/10000, 2)} 万")
            # print(f"last_volume  瞬时成交量==={round(current_last_volume, 2)}")
            # print(f"current_quotes_buy=={current_quotes_buy}")
            # print(f"current_quotes_sell=={current_quotes_sell}")
                # 在字典K线下的查询当前个股的K线并赋值以便使用
                k_line_data = data_cache.all_stocks_all_K_line_property_dict.get(account_positions_symbol, None)
            # 在字典K线下的查询当前个股的K线并赋值以便使用
            k_line_data = data_cache.all_stocks_all_K_line_property_dict.get(account_positions_symbol, None)
                # 处理行情订阅中持仓金额>0的个股(或者直接把先把指数的数据过滤掉放进来)
                if position_volume_yesterday > 0:  # 如果可用资金不等于0 且 持仓数量大于0 (不知名原因导致有些票会获取到零值导致后续公式报错,阻止intraday_growth函数正常运行)
                    # 进入集合竞价前和收盘前作持仓可用交易,在此时间为不生效
                    if data_cache.BEFORE_OPEN_BIDDING_TIME < now_time < data_cache.AFTER_CLOSING_TIME:
                        # logger_info(f"account_positions_element = 【{k_line_data[0]['sec_name']}】  代码:{element['symbol']}  股持仓均价:{element['vwap']}    持仓量:{element['volume']} ")
                        # print(f"available_now_index===={index}")
                        # 调用涨幅公式计算对应的股票tick瞬时涨幅
                        tick_growth = basic_methods.tick_growth(symbol, current_price)
                        # 计算当日当时涨幅
                        today_growth = basic_methods.intraday_growth(current_price, k_line_data[0]['close'])
                        # 计算当日开盘涨幅(如果计算时获取到的最新价为0,进入容错模式,只有当开盘价不为0时才正常计算,如果为0,那么将开盘涨幅设置为0.01【因为如果设置为0,昨日未涨停的票大概率会默认抛掉】)
                        if current_open != 0:
                            today_open_growth = basic_methods.intraday_growth(current_open, k_line_data[0]['close'])
                        else:
                            today_open_growth = 0.01
                        # 计算当时浮动盈亏
                        floating_profit_and_loss = basic_methods.intraday_growth(current_price, vwap)
                        # 计算昨日涨停价 目前函数中的pre_close应该传入前天的收盘价,而非昨天的
                        # yesterday_limit_up_price = basic_methods.limit_up_price(k_line_data[1]['close'])
                        # 计算今日涨停价
                        today_limit_up_price = basic_methods.limit_up_price(k_line_data[0]['close'])
                        # 计算今日跌停价
                        today_limit_down_price = basic_methods.limit_down_price(k_line_data[0]['close'])
                        # print(
                        #     f"今日可用持仓股票数量=================================================================【{len(data_cache.available_symbols_set)}】")
                        # print(f"持仓可用股{symbol}")
                        # print(
                        #     f"【{k_line_data[0]['sec_name']}】上个交易日 最高{history_data[1]['high']},收盘{history_data[1]['close']}")
            # 处理行情订阅中持仓金额>0的个股(或者直接把先把指数的数据过滤掉放进来)
            if position_volume_yesterday > 0:  # 如果可用资金不等于0 且 持仓数量大于0 (不知名原因导致有些票会获取到零值导致后续公式报错,阻止intraday_growth函数正常运行)
                # 进入集合竞价前和收盘前作持仓可用交易,在此时间为不生效
                if data_cache.BEFORE_OPEN_BIDDING_TIME < now_time < data_cache.AFTER_CLOSING_TIME:
                    # logger_info(f"account_positions_element = 【{k_line_data[0]['sec_name']}】  代码:{element['symbol']}  股持仓均价:{element['vwap']}    持仓量:{element['volume']} ")
                    # print(f"available_now_index===={index}")
                    # 调用涨幅公式计算对应的股票tick瞬时涨幅
                    tick_growth = basic_methods.tick_growth(symbol, current_price)
                    # 计算当日当时涨幅
                    today_growth = basic_methods.intraday_growth(current_price, k_line_data[0]['close'])
                    # 计算当日开盘涨幅(如果计算时获取到的最新价为0,进入容错模式,只有当开盘价不为0时才正常计算,如果为0,那么将开盘涨幅设置为0.01【因为如果设置为0,昨日未涨停的票大概率会默认抛掉】)
                    if current_open != 0:
                        today_open_growth = basic_methods.intraday_growth(current_open, k_line_data[0]['close'])
                    else:
                        today_open_growth = 0.01
                    # 计算当时浮动盈亏
                    floating_profit_and_loss = basic_methods.intraday_growth(current_price, vwap)
                    # 计算昨日涨停价 目前函数中的pre_close应该传入前天的收盘价,而非昨天的
                    # yesterday_limit_up_price = basic_methods.limit_up_price(k_line_data[1]['close'])
                    # 计算今日涨停价
                    today_limit_up_price = basic_methods.limit_up_price(k_line_data[0]['close'])
                    # 计算今日跌停价
                    today_limit_down_price = basic_methods.limit_down_price(k_line_data[0]['close'])
                    # print(
                    #     f"今日可用持仓股票数量=================================================================【{len(data_cache.available_symbols_set)}】")
                    # print(f"持仓可用股{symbol}")
                    # print(
                    #     f"【{k_line_data[0]['sec_name']}】上个交易日 最高{history_data[1]['high']},收盘{history_data[1]['close']}")
                        # 由于会存在分时L1数据中最新价为0导致current_low==0的情况,所以当出现这一情况时,将它直接赋值为昨收价(目前没有办法根本解决)
                        if current_low == 0:
                            current_low = k_line_data[0]['close']
                    # 由于会存在分时L1数据中最新价为0导致current_low==0的情况,所以当出现这一情况时,将它直接赋值为昨收价(目前没有办法根本解决)
                    if current_low == 0:
                        current_low = k_line_data[0]['close']
                        '''
                        集合竞价阶段决断(只判断一次)
                        '''
                        #  09:25:06---09:30:00
                        if data_cache.LATER_OPEN_BIDDING_TIME < now_time < data_cache.OPENING_TIME and data_cache.execution_times < len(
                                data_cache.available_symbols_set):
                            # 每进入该条件分支一次就把进入次数自加1
                            data_cache.execution_times += 1
                            logger_info(f"这个分支逻辑已经执行次数:{data_cache.execution_times}")
                            logger_info(
                                f"【集合竞价】【{k_line_data[0]['sec_name']}】,开盘涨幅:{today_open_growth}%,当日当时涨幅:{today_growth},瞬时涨幅{tick_growth},当日当时浮动盈亏{floating_profit_and_loss}。当日开盘价:{current_open},昨日收盘价:{k_line_data[0]['close']}")
                            # 昨日起飞失败
                            if k_line_data[0]['attribute'] not in (
                                    data_cache.limit_up_type + data_cache.frying_plate_type + data_cache.limit_down_type):
                                if floating_profit_and_loss > 0:
                                    if today_open_growth < -1:
                    '''
                    集合竞价阶段决断(只判断一次)
                    '''
                    #  09:25:06---09:30:00
                    if data_cache.LATER_OPEN_BIDDING_TIME < now_time < data_cache.OPENING_TIME and data_cache.execution_times < len(
                            data_cache.available_symbols_set):
                        # 每进入该条件分支一次就把进入次数自加1
                        data_cache.execution_times += 1
                        logger_info(f"这个分支逻辑已经执行次数:{data_cache.execution_times}")
                        logger_info(
                            f"【集合竞价】【{k_line_data[0]['sec_name']}】,开盘涨幅:{today_open_growth}%,当日当时涨幅:{today_growth},瞬时涨幅{tick_growth},当日当时浮动盈亏{floating_profit_and_loss}。当日开盘价:{current_open},昨日收盘价:{k_line_data[0]['close']}")
                        # 昨日起飞失败
                        if k_line_data[0]['attribute'] not in (
                                data_cache.limit_up_type + data_cache.frying_plate_type + data_cache.limit_down_type):
                            if floating_profit_and_loss > 0:
                                if today_open_growth < -1:
                                    logger_info(
                                        f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日起飞失败】【浮盈】【低开】,低开:{today_open_growth}%,设定委卖数量【十分之一仓】")
                                    order_methods.sell_order_by_part_volume(0.1, symbol, position_volume_yesterday,
                                                                            current_price,
                                                                            k_line_data[0]['sec_name'],
                                                                            index)
                            if floating_profit_and_loss <= 0:
                                # 中高开/大高开视界
                                if today_open_growth >= 4:
                                    logger_info(
                                        f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日起飞失败】【浮亏】【中高开/大高开】,高开:{today_open_growth}%,设定委卖数量【十分之五仓】")
                                    order_methods.sell_order_by_part_volume(0.5, symbol, position_volume_yesterday,
                                                                            current_price,
                                                                            k_line_data[0]['sec_name'], index)
                                # 小高开视界
                                if 4 > today_open_growth >= 1:
                                    logger_info(
                                        f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日起飞失败】【浮亏】【小高开】,高开:{today_open_growth}%,设定委卖数量【十分之三仓】")
                                    order_methods.sell_order_by_part_volume(0.3, symbol, position_volume_yesterday,
                                                                            current_price,
                                                                            k_line_data[0]['sec_name'],
                                                                            index)
                                # 平开视界 +- 1
                                if -1 < today_open_growth < 1:
                                    logger_info(
                                        f"【集合竞价】【平开】【{k_line_data[0]['sec_name']}】【昨日起飞失败】【浮亏】【平开】,平开:{today_open_growth}%,设定委卖数量【十分之五仓】")
                                    order_methods.sell_order_by_part_volume(0.5, symbol, position_volume_yesterday,
                                                                            current_price,
                                                                            k_line_data[0]['sec_name'],
                                                                            index)
                                # 低开视界
                                if today_open_growth <= -1:
                                    logger_info(
                                        f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日起飞失败】【浮亏】【小低开】,低开:{today_open_growth}%,设定委卖数量【全仓】")
                                    order_methods.sell_order_by_part_volume(1, symbol, position_volume_yesterday,
                                                                            current_price,
                                                                            k_line_data[0]['sec_name'], index)
                        # 昨日涨停视界
                        if k_line_data[0]['attribute'] in data_cache.limit_up_type:
                            if floating_profit_and_loss > 0:
                                pass
                            if floating_profit_and_loss <= 0:
                                # 平开视界 < ±1%
                                if -1 < today_open_growth < 1:
                                    logger_info(
                                        f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日涨停】【浮亏】【平开】,平开:{today_open_growth}%,设定委卖数量【无,集合竞价阶段不决策】")
                                # 低开视界
                                if today_open_growth <= -1:
                                    # 小低开视界
                                    if -4 < today_open_growth <= -1:
                                        logger_info(
                                            f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日起飞失败】【浮盈】【低开】,低开:{today_open_growth}%,设定委卖数量【十分之一仓】")
                                        order_methods.sell_order_by_part_volume(0.1, symbol, position_volume_yesterday,
                                                                                current_price,
                                                                                k_line_data[0]['sec_name'],
                                                                                index)
                                if floating_profit_and_loss <= 0:
                                    # 中高开/大高开视界
                                    if today_open_growth >= 4:
                                        logger_info(
                                            f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日起飞失败】【浮亏】【中高开/大高开】,高开:{today_open_growth}%,设定委卖数量【十分之五仓】")
                                        order_methods.sell_order_by_part_volume(0.5, symbol, position_volume_yesterday,
                                            f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日涨停】【浮亏】【小低开】,低开:{today_open_growth}%,设定委卖数量【十分之五仓】")
                                        order_methods.sell_order_by_part_volume(0.5, symbol,
                                                                                position_volume_yesterday,
                                                                                current_price,
                                                                                k_line_data[0]['sec_name'], index)
                                    # 小高开视界
                                    if 4 > today_open_growth >= 1:
                                    # 中低开/大低开视界
                                    if today_open_growth <= -4:
                                        logger_info(
                                            f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日起飞失败】【浮亏】【小高开】,高开:{today_open_growth}%,设定委卖数量【十分之三仓】")
                                        order_methods.sell_order_by_part_volume(0.3, symbol, position_volume_yesterday,
                                            f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日涨停】【浮亏】【中低开/大低开】,低开:{today_open_growth}%,设定委卖数量【全仓】")
                                        order_methods.sell_order_by_part_volume(1, symbol,
                                                                                position_volume_yesterday,
                                                                                current_price,
                                                                                k_line_data[0]['sec_name'],
                                                                                index)
                                    # 平开视界 +- 1
                                    if -1 < today_open_growth < 1:
                                                                                k_line_data[0]['sec_name'], index)
                            #  如果昨日集合竞价最后时刻炸板的股票【开盘啦昨日炸板但通过K线数据计算涨停的股票代码列表】
                            if symbol in data_cache.yesterday_frying_plate_last_minute_list:
                                # 开盘涨幅小于9.6%
                                if today_open_growth < 9.6:
                                    logger_info(
                                        f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日K线涨停,开盘啦炸板】【非触摸板状态】,开盘涨幅:{today_open_growth}%,设定委卖数量【全仓】")
                                    order_methods.sell_order_by_part_volume(1, symbol, position_volume_yesterday,
                                                                            current_price,
                                                                            k_line_data[0]['sec_name'], index)
                        # 昨日炸板视界
                        if k_line_data[0]['attribute'] in data_cache.frying_plate_type:
                            if floating_profit_and_loss > 0:
                                # 中高开/大高开视界
                                if today_open_growth >= 4:
                                    logger_info(
                                        f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日炸板】【浮盈】【中高开/大高开】,高开:{today_open_growth}%,设定委卖数量【二十分之一仓】")
                                    order_methods.sell_order_by_part_volume(0.05, symbol, position_volume_yesterday,
                                                                            current_price,
                                                                            k_line_data[0]['sec_name'], index)
                                # 小高开视界
                                if 4 > today_open_growth >= 1:
                                    logger_info(
                                        f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日炸板】【浮盈】【小高开】,高开:{today_open_growth}%,设定委卖数量【十分之一仓】")
                                    order_methods.sell_order_by_part_volume(0.1, symbol, position_volume_yesterday,
                                                                            current_price,
                                                                            k_line_data[0]['sec_name'], index)
                                # 平开视界 < ±1%
                                if -1 < today_open_growth < 1:
                                    logger_info(
                                        f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日炸板】【浮盈】【平开】,平开:{today_open_growth}%,设定委卖数量【四分之一仓】")
                                    order_methods.sell_order_by_part_volume(0.25, symbol, position_volume_yesterday,
                                                                            current_price,
                                                                            k_line_data[0]['sec_name'], index)
                                # 小低开视界
                                if -4 < today_open_growth <= -1:
                                    logger_info(
                                        f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日炸板】【浮盈】【小低开】,低开:{today_open_growth}%,设定委卖数量【十分之三仓】")
                                    order_methods.sell_order_by_part_volume(0.3, symbol, position_volume_yesterday,
                                                                            current_price,
                                                                            k_line_data[0]['sec_name'], index)
                                # 中低开/大低开视界
                                if today_open_growth <= -4:
                                    logger_info(
                                        f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日炸板】【中低开/大低开】,低开:{today_open_growth}%,设定委卖数量【半仓】")
                                    order_methods.sell_order_by_part_volume(0.5, symbol, position_volume_yesterday,
                                                                            current_price,
                                                                            k_line_data[0]['sec_name'], index)
                            if floating_profit_and_loss <= 0:
                                # 中高开/大高开视界
                                if today_open_growth >= 4:
                                    logger_info(
                                        f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日炸板】【浮亏】【中高开/大高开】,高开:{today_open_growth}%,设定委卖数量【十分之二仓】")
                                    order_methods.sell_order_by_part_volume(0.2, symbol, position_volume_yesterday,
                                                                            current_price,
                                                                            k_line_data[0]['sec_name'], index)
                                # 小高开视界
                                if 4 > today_open_growth >= 1:
                                    logger_info(
                                        f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日炸板】【浮亏】【小高开】,高开:{today_open_growth}%,设定委卖数量【十分之五仓】")
                                    order_methods.sell_order_by_part_volume(0.5, symbol, position_volume_yesterday,
                                                                            current_price,
                                                                            k_line_data[0]['sec_name'], index)
                                # 平开视界 < ±1%
                                if -1 < today_open_growth < 1:
                                    logger_info(
                                        f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日炸板】【浮亏】【平开】,平开:{today_open_growth}%,设定委卖数量【十分之五仓】")
                                    order_methods.sell_order_by_part_volume(0.5, symbol, position_volume_yesterday,
                                                                            current_price,
                                                                            k_line_data[0]['sec_name'], index)
                                # 小低开视界
                                if -4 < today_open_growth <= -1:
                                    logger_info(
                                        f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日炸板】【浮亏】【小低开】,低开:{today_open_growth}%,设定委卖数量【十分之七仓】")
                                    order_methods.sell_order_by_part_volume(0.7, symbol, position_volume_yesterday,
                                                                            current_price,
                                                                            k_line_data[0]['sec_name'], index)
                                # 中低开/大低开视界
                                if today_open_growth <= -4:
                                    logger_info(
                                        f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日炸板】【浮亏】【中低开/大低开】,低开:{today_open_growth}%,设定委卖数量【全仓】")
                                    order_methods.sell_order_by_part_volume(1, symbol, position_volume_yesterday,
                                                                            current_price,
                                                                            k_line_data[0]['sec_name'], index)
                        # 昨日跌停视界
                        if k_line_data[0]['attribute'] in data_cache.limit_down_type:
                            logger_info(
                                f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日跌停】【无论开盘涨幅多少!!!】,开盘涨幅:{today_open_growth}%,设定委卖数量【全仓】")
                            order_methods.sell_order_by_part_volume(1, symbol, position_volume_yesterday,
                                                                    current_price,
                                                                    k_line_data[0]['sec_name'], index)
                    '''
                    开盘阶段临机决策
                    '''
                    if data_cache.OPENING_TIME < now_time < data_cache.AFTER_CLOSING_TIME:
                        # 当日未涨停视界
                        if today_limit_up_price != current_high:
                            # 昨日起飞失败视界
                            if k_line_data[0]['attribute'] not in (
                                    data_cache.limit_up_type + data_cache.frying_plate_type + data_cache.limit_down_type):
                                # 浮动盈亏【亏】
                                if floating_profit_and_loss < 0:
                                    if tick_growth < -0.1 and current_price <= current_low:
                                        logger_info(
                                            f"【集合竞价】【平开】【{k_line_data[0]['sec_name']}】【昨日起飞失败】【浮亏】【平开】,平开:{today_open_growth}%,设定委卖数量【十分之五仓】")
                                        order_methods.sell_order_by_part_volume(0.5, symbol, position_volume_yesterday,
                                            f"【开盘临机】【浮动盈亏当前亏】【瞬时跌幅 <-0.1%】【当日新低】【{k_line_data[0]['sec_name']}】,设定委卖数量【十分之一仓】,【瞬时跌幅:{round(tick_growth, 2)}%】,当日当时涨幅:{today_growth}。最新价::{current_price},昨日收盘价:{k_line_data[0]['close']}")
                                        order_methods.sell_order_by_part_volume(0.1, symbol,
                                                                                position_volume_yesterday,
                                                                                current_price,
                                                                                k_line_data[0]['sec_name'],
                                                                                index)
                                    # 低开视界
                                    if today_open_growth <= -1:
                                                                                k_line_data[0]['sec_name'], index)
                                    if tick_growth < -1 and today_growth < 0 and current_price <= current_low:
                                        logger_info(
                                            f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日起飞失败】【浮亏】【小低开】,低开:{today_open_growth}%,设定委卖数量【全仓】")
                                        order_methods.sell_order_by_part_volume(1, symbol, position_volume_yesterday,
                                            f"【开盘临机】【浮动盈亏当前亏】【瞬时跌幅 <-1%】【当日当时涨幅 <0%】【当日新低】【{k_line_data[0]['sec_name']}】,设定委卖数量【全仓】,【瞬时跌幅:{round(tick_growth, 2)}%】,当日当时涨幅:{today_growth}。最新价::{current_price},昨日收盘价:{k_line_data[0]['close']}")
                                        order_methods.sell_order_by_part_volume(1, symbol,
                                                                                position_volume_yesterday,
                                                                                current_price,
                                                                                k_line_data[0]['sec_name'], index)
                            # 昨日涨停视界
                            if k_line_data[0]['attribute'] in data_cache.limit_up_type:
                                if floating_profit_and_loss > 0:
                                    pass
                                if floating_profit_and_loss <= 0:
                                    # 平开视界 < ±1%
                                    if -1 < today_open_growth < 1:
                                # 浮动盈亏【亏】
                                if floating_profit_and_loss < 0:
                                    if tick_growth < -0.1 and today_growth < -4:
                                        logger_info(
                                            f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日涨停】【浮亏】【平开】,平开:{today_open_growth}%,设定委卖数量【无,集合竞价阶段不决策】")
                                    # 低开视界
                                    if today_open_growth <= -1:
                                        # 小低开视界
                                        if -4 < today_open_growth <= -1:
                                            logger_info(
                                                f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日涨停】【浮亏】【小低开】,低开:{today_open_growth}%,设定委卖数量【十分之五仓】")
                                            order_methods.sell_order_by_part_volume(0.5, symbol,
                                                                                    position_volume_yesterday,
                                                                                    current_price,
                                                                                    k_line_data[0]['sec_name'], index)
                                        # 中低开/大低开视界
                                        if today_open_growth <= -4:
                                            logger_info(
                                                f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日涨停】【浮亏】【中低开/大低开】,低开:{today_open_growth}%,设定委卖数量【全仓】")
                                            order_methods.sell_order_by_part_volume(1, symbol,
                                                                                    position_volume_yesterday,
                                                                                    current_price,
                                                                                    k_line_data[0]['sec_name'], index)
                                #  如果昨日集合竞价最后时刻炸板的股票【开盘啦昨日炸板但通过K线数据计算涨停的股票代码列表】
                                if symbol in data_cache.yesterday_frying_plate_last_minute_list:
                                    # 开盘涨幅小于9.6%
                                    if today_open_growth < 9.6:
                                        logger_info(
                                            f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日K线涨停,开盘啦炸板】【非触摸板状态】,开盘涨幅:{today_open_growth}%,设定委卖数量【全仓】")
                                        order_methods.sell_order_by_part_volume(1, symbol, position_volume_yesterday,
                                            f"【开盘临机】【浮动盈亏当前亏】【瞬时跌幅 <-1%】【当日当时涨幅 <-4%】【{k_line_data[0]['sec_name']}】,设定委卖数量【十分之一仓】,【瞬时跌幅:{round(tick_growth, 2)}%】,当日当时涨幅:{today_growth}。最新价::{current_price},昨日收盘价:{k_line_data[0]['close']}")
                                        order_methods.sell_order_by_part_volume(0.1, symbol,
                                                                                position_volume_yesterday,
                                                                                current_price,
                                                                                k_line_data[0]['sec_name'], index)
                                                                                k_line_data[0]['sec_name'],
                                                                                index)
                                    if tick_growth < -0.1 and today_growth < 0 and current_price <= current_low:
                                        logger_info(
                                            f"【开盘临机】【浮动盈亏当前亏】【瞬时跌幅 <-1%】【当日当时涨幅小于0%】【当日新低】【{k_line_data[0]['sec_name']}】,设定委卖数量【全仓】,【瞬时跌幅:{round(tick_growth, 2)}%】,当日当时涨幅:{today_growth}。最新价::{current_price},昨日收盘价:{k_line_data[0]['close']}")
                                        order_methods.sell_order_by_part_volume(1, symbol,
                                                                                position_volume_yesterday,
                                                                                current_price,
                                                                                k_line_data[0]['sec_name'],
                                                                                index)
                            # 昨日炸板视界
                            if k_line_data[0]['attribute'] in data_cache.frying_plate_type:
                                if floating_profit_and_loss > 0:
                                    # 中高开/大高开视界
                                    if today_open_growth >= 4:
                                        logger_info(
                                            f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日炸板】【浮盈】【中高开/大高开】,高开:{today_open_growth}%,设定委卖数量【二十分之一仓】")
                                        order_methods.sell_order_by_part_volume(0.05, symbol, position_volume_yesterday,
                            if k_line_data[0]['attribute'] in data_cache.limit_up_type:
                                # 浮动盈亏【盈】
                                if floating_profit_and_loss < 0:
                                    if tick_growth < -1 and today_growth < 0 and current_price <= current_low:
                                        order_methods.sell_order_by_part_volume(1, symbol,
                                                                                position_volume_yesterday,
                                                                                current_price,
                                                                                k_line_data[0]['sec_name'], index)
                                    # 小高开视界
                                    if 4 > today_open_growth >= 1:
                                                                                k_line_data[0]['sec_name'],
                                                                                index)
                                # 浮动盈亏【亏】
                                if floating_profit_and_loss < 0:
                                    if tick_growth < -0.1 and current_price <= current_low:
                                        logger_info(
                                            f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日炸板】【浮盈】【小高开】,高开:{today_open_growth}%,设定委卖数量【十分之一仓】")
                                        order_methods.sell_order_by_part_volume(0.1, symbol, position_volume_yesterday,
                                            f"【开盘临机】【浮动盈亏当前亏】【瞬时跌幅 <-0.1%】【当日新低】【{k_line_data[0]['sec_name']}】,设定委卖数量【十分之一仓】,【瞬时跌幅:{round(tick_growth, 2)}%】,当日当时涨幅:{today_growth}。最新价::{current_price},昨日收盘价:{k_line_data[0]['close']}")
                                        order_methods.sell_order_by_part_volume(0.1, symbol,
                                                                                position_volume_yesterday,
                                                                                current_price,
                                                                                k_line_data[0]['sec_name'], index)
                                    # 平开视界 < ±1%
                                    if -1 < today_open_growth < 1:
                                                                                k_line_data[0]['sec_name'],
                                                                                index)
                                    if tick_growth < -1 and today_growth < 0 and current_price <= current_low:
                                        logger_info(
                                            f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日炸板】【浮盈】【平开】,平开:{today_open_growth}%,设定委卖数量【四分之一仓】")
                                        order_methods.sell_order_by_part_volume(0.25, symbol, position_volume_yesterday,
                                            f"【开盘临机】【浮动盈亏当前亏】【瞬时跌幅 <-1%】【当日当时涨幅小于0%】【当日新低】【{k_line_data[0]['sec_name']}】,设定委卖数量【全仓】,【瞬时跌幅:{round(tick_growth, 2)}%】,当日当时涨幅:{today_growth}。最新价::{current_price},昨日收盘价:{k_line_data[0]['close']}")
                                        order_methods.sell_order_by_part_volume(1, symbol,
                                                                                position_volume_yesterday,
                                                                                current_price,
                                                                                k_line_data[0]['sec_name'], index)
                                    # 小低开视界
                                    if -4 < today_open_growth <= -1:
                                        logger_info(
                                            f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日炸板】【浮盈】【小低开】,低开:{today_open_growth}%,设定委卖数量【十分之三仓】")
                                        order_methods.sell_order_by_part_volume(0.3, symbol, position_volume_yesterday,
                                                                                current_price,
                                                                                k_line_data[0]['sec_name'], index)
                                    # 中低开/大低开视界
                                    if today_open_growth <= -4:
                                        logger_info(
                                            f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日炸板】【中低开/大低开】,低开:{today_open_growth}%,设定委卖数量【半仓】")
                                        order_methods.sell_order_by_part_volume(0.5, symbol, position_volume_yesterday,
                                                                                current_price,
                                                                                k_line_data[0]['sec_name'], index)
                                if floating_profit_and_loss <= 0:
                                    # 中高开/大高开视界
                                    if today_open_growth >= 4:
                                        logger_info(
                                            f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日炸板】【浮亏】【中高开/大高开】,高开:{today_open_growth}%,设定委卖数量【十分之二仓】")
                                        order_methods.sell_order_by_part_volume(0.2, symbol, position_volume_yesterday,
                                                                                current_price,
                                                                                k_line_data[0]['sec_name'], index)
                                    # 小高开视界
                                    if 4 > today_open_growth >= 1:
                                        logger_info(
                                            f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日炸板】【浮亏】【小高开】,高开:{today_open_growth}%,设定委卖数量【十分之五仓】")
                                        order_methods.sell_order_by_part_volume(0.5, symbol, position_volume_yesterday,
                                                                                current_price,
                                                                                k_line_data[0]['sec_name'], index)
                                    # 平开视界 < ±1%
                                    if -1 < today_open_growth < 1:
                                        logger_info(
                                            f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日炸板】【浮亏】【平开】,平开:{today_open_growth}%,设定委卖数量【十分之五仓】")
                                        order_methods.sell_order_by_part_volume(0.5, symbol, position_volume_yesterday,
                                                                                current_price,
                                                                                k_line_data[0]['sec_name'], index)
                                    # 小低开视界
                                    if -4 < today_open_growth <= -1:
                                        logger_info(
                                            f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日炸板】【浮亏】【小低开】,低开:{today_open_growth}%,设定委卖数量【十分之七仓】")
                                        order_methods.sell_order_by_part_volume(0.7, symbol, position_volume_yesterday,
                                                                                current_price,
                                                                                k_line_data[0]['sec_name'], index)
                                    # 中低开/大低开视界
                                    if today_open_growth <= -4:
                                        logger_info(
                                            f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日炸板】【浮亏】【中低开/大低开】,低开:{today_open_growth}%,设定委卖数量【全仓】")
                                        order_methods.sell_order_by_part_volume(1, symbol, position_volume_yesterday,
                                                                                current_price,
                                                                                k_line_data[0]['sec_name'], index)
                                                                                k_line_data[0]['sec_name'],
                                                                                index)
                            # 昨日跌停视界
                            if k_line_data[0]['attribute'] in data_cache.limit_down_type:
                            if k_line_data[0]['attribute'] in data_cache.limit_up_type:
                                # 执行与集合竞价一致,全仓出,不再复写
                                pass
                        # 当日涨停视界(板上盯 有时间限制  9:30:00 ---  14:36:00)
                        if data_cache.OPENING_TIME < now_time < data_cache.WATCH_DISK_END_TIME:
                            # if symbol in data_cache.LIMIT_UP_SELL_CODES:
                            if today_limit_up_price == current_high:
                                logger_info(
                                    f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日跌停】【无论开盘涨幅多少!!!】,开盘涨幅:{today_open_growth}%,设定委卖数量【全仓】")
                                    f"【开盘临机】【{k_line_data[0]['sec_name']}】 触及涨停! 买一总金额:{round(current_quotes_buy[0][1] * current_quotes_buy[0][0] / 10000, 2)} 万,当日当时量:{current_volume}")
                                # 如果 买一总金额 < 200000   买一总金额 在L1情况下估计的炸板前最后一刻的最低买一额无法缩小到更小,其本身跨度也因股票因时间因往下砸的力度而异,不然无法观察到结果。
                                if current_quotes_buy[0][1] * current_quotes_buy[0][0] < 1000000:
                                    logger_info(
                                        f"【开盘临机】【炸板风险!!】【{k_line_data[0]['sec_name']}】 买盘金额小于100万! 买一额:【{current_quotes_buy[0][1]}】,当日当时量:{current_volume}")
                                    if current_volume < k_line_data[0]['volume'] * 0.6:
                                        logger_info(
                                            f"【开盘临机】【 炸板!!且当日量不足】【{k_line_data[0]['sec_name']}】 买盘小于1万 且 今日量小于昨日量的 0.6,设定委卖数量【十分之一仓】,当日当时量:{current_volume}")
                                        # 设定委卖数量【十分之一仓】
                                        order_methods.sell_order_by_part_volume(0.1, symbol,
                                                                                position_volume_yesterday,
                                                                                current_price,
                                                                                k_line_data[0]['sec_name'],
                                                                                index)
                                else:
                                    logger_info(f"【开盘临机】【{k_line_data[0]['sec_name']}】 涨停封板!!")
                                '''
                                下面是目前看来更有效的板上盯卖
                                '''
                                # 如果 卖一 量 为零
                                if current_quotes_sell[0][1] * current_quotes_sell[0][0] == 0:
                                    logger_info(
                                        f"【开盘临机】【强势封板!!!】【{k_line_data[0]['sec_name']}】 买一总金额:{round(current_quotes_buy[0][1] * current_quotes_buy[0][0] / 10000, 2)} 万,当日当时量:{current_volume}")
                                else:
                                    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)
                        # 当前时间超过午盘时间【午盘决策】
                        if now_time > data_cache.NOON_MARKET_TIME:
                            # 进入当前最新价低于当日最低价 且 瞬时下跌
                            if current_price <= current_low and tick_growth < -0.2:
                                # 进入昨日首板涨停视界(昨日涨停但前日未涨停)且 当日当前量未超昨日量
                                if k_line_data[0]['attribute'] in data_cache.limit_up_type and k_line_data[1][
                                    'attribute'] not in data_cache.limit_up_type and current_volume <= \
                                        k_line_data[0]['volume']:
                                    if today_limit_up_price != current_high or today_growth < 7:
                                        logger_info(
                                            f"【午盘决策】【昨日涨停】【当日未涨停 或 当日当时涨幅小于7%】【{k_line_data[0]['sec_name']}】 设定委卖数量【十分之五仓】,当日当时涨幅为{today_growth}。最新价::{current_price},昨日收盘价:{k_line_data[0]['close']}")
                                        order_methods.sell_order_by_part_volume(0.5, symbol,
                                                                                position_volume_yesterday,
                                                                                current_price,
                                                                                k_line_data[0]['sec_name'], index)
                        # 当前时间超过平仓时间【尾盘决断】
                        if now_time > data_cache.CLOSE_POSITION_TIME:
                            if today_limit_up_price != current_high or today_growth < 7:
                                logger_info(
                                    f"【尾盘决断】【当日未涨停 或 当日当时涨幅小于7%】【{k_line_data[0]['sec_name']}】 设定委卖数量【全仓】,当日当时涨幅为{today_growth}。最新价::{current_price},昨日收盘价:{k_line_data[0]['close']}")
                                order_methods.sell_order_by_part_volume(1, symbol, position_volume_yesterday,
                                                                        current_price,
                                                                        k_line_data[0]['sec_name'], index)
                        '''
                        开盘阶段临机决策
                        '''
                        if data_cache.OPENING_TIME < now_time < data_cache.AFTER_CLOSING_TIME:
                            # 当日未涨停视界
                            if today_limit_up_price != current_high:
                                # 昨日起飞失败视界
                                if k_line_data[0]['attribute'] not in (
                                        data_cache.limit_up_type + data_cache.frying_plate_type + data_cache.limit_down_type):
                                    # 浮动盈亏【亏】
                                    if floating_profit_and_loss < 0:
                                        if tick_growth < -0.1 and current_price <= current_low:
                                            logger_info(
                                                f"【开盘临机】【浮动盈亏当前亏】【瞬时跌幅 <-0.1%】【当日新低】【{k_line_data[0]['sec_name']}】,设定委卖数量【十分之一仓】,【瞬时跌幅:{round(tick_growth, 2)}%】,当日当时涨幅:{today_growth}。最新价::{current_price},昨日收盘价:{k_line_data[0]['close']}")
                                            order_methods.sell_order_by_part_volume(0.1, symbol,
                                                                                    position_volume_yesterday,
                                                                                    current_price,
                                                                                    k_line_data[0]['sec_name'], index)
                                        if tick_growth < -1 and today_growth < 0 and current_price <= current_low:
                                            logger_info(
                                                f"【开盘临机】【浮动盈亏当前亏】【瞬时跌幅 <-1%】【当日当时涨幅 <0%】【当日新低】【{k_line_data[0]['sec_name']}】,设定委卖数量【全仓】,【瞬时跌幅:{round(tick_growth, 2)}%】,当日当时涨幅:{today_growth}。最新价::{current_price},昨日收盘价:{k_line_data[0]['close']}")
                                            order_methods.sell_order_by_part_volume(1, symbol,
                                                                                    position_volume_yesterday,
                                                                                    current_price,
                                                                                    k_line_data[0]['sec_name'], index)
                                # 昨日涨停视界
                                if k_line_data[0]['attribute'] in data_cache.limit_up_type:
                                    # 浮动盈亏【亏】
                                    if floating_profit_and_loss < 0:
                                        if tick_growth < -0.1 and today_growth < -4:
                                            logger_info(
                                                f"【开盘临机】【浮动盈亏当前亏】【瞬时跌幅 <-1%】【当日当时涨幅 <-4%】【{k_line_data[0]['sec_name']}】,设定委卖数量【十分之一仓】,【瞬时跌幅:{round(tick_growth, 2)}%】,当日当时涨幅:{today_growth}。最新价::{current_price},昨日收盘价:{k_line_data[0]['close']}")
                                            order_methods.sell_order_by_part_volume(0.1, symbol,
                                                                                    position_volume_yesterday,
                                                                                    current_price,
                                                                                    k_line_data[0]['sec_name'],
                                                                                    index)
                                        if tick_growth < -0.1 and today_growth < 0 and current_price <= current_low:
                                            logger_info(
                                                f"【开盘临机】【浮动盈亏当前亏】【瞬时跌幅 <-1%】【当日当时涨幅小于0%】【当日新低】【{k_line_data[0]['sec_name']}】,设定委卖数量【全仓】,【瞬时跌幅:{round(tick_growth, 2)}%】,当日当时涨幅:{today_growth}。最新价::{current_price},昨日收盘价:{k_line_data[0]['close']}")
                                            order_methods.sell_order_by_part_volume(1, symbol,
                                                                                    position_volume_yesterday,
                                                                                    current_price,
                                                                                    k_line_data[0]['sec_name'],
                                                                                    index)
                                # 昨日炸板视界
                                if k_line_data[0]['attribute'] in data_cache.limit_up_type:
                                    # 浮动盈亏【盈】
                                    if floating_profit_and_loss < 0:
                                        if tick_growth < -1 and today_growth < 0 and current_price <= current_low:
                                            order_methods.sell_order_by_part_volume(1, symbol,
                                                                                    position_volume_yesterday,
                                                                                    current_price,
                                                                                    k_line_data[0]['sec_name'],
                                                                                    index)
                                    # 浮动盈亏【亏】
                                    if floating_profit_and_loss < 0:
                                        if tick_growth < -0.1 and current_price <= current_low:
                                            logger_info(
                                                f"【开盘临机】【浮动盈亏当前亏】【瞬时跌幅 <-0.1%】【当日新低】【{k_line_data[0]['sec_name']}】,设定委卖数量【十分之一仓】,【瞬时跌幅:{round(tick_growth, 2)}%】,当日当时涨幅:{today_growth}。最新价::{current_price},昨日收盘价:{k_line_data[0]['close']}")
                                            order_methods.sell_order_by_part_volume(0.1, symbol,
                                                                                    position_volume_yesterday,
                                                                                    current_price,
                                                                                    k_line_data[0]['sec_name'],
                                                                                    index)
                                        if tick_growth < -1 and today_growth < 0 and current_price <= current_low:
                                            logger_info(
                                                f"【开盘临机】【浮动盈亏当前亏】【瞬时跌幅 <-1%】【当日当时涨幅小于0%】【当日新低】【{k_line_data[0]['sec_name']}】,设定委卖数量【全仓】,【瞬时跌幅:{round(tick_growth, 2)}%】,当日当时涨幅:{today_growth}。最新价::{current_price},昨日收盘价:{k_line_data[0]['close']}")
                                            order_methods.sell_order_by_part_volume(1, symbol,
                                                                                    position_volume_yesterday,
                                                                                    current_price,
                                                                                    k_line_data[0]['sec_name'],
                                                                                    index)
                                # 昨日跌停视界
                                if k_line_data[0]['attribute'] in data_cache.limit_up_type:
                                    # 执行与集合竞价一致,全仓出,不再复写
                                    pass
                            # 当日涨停视界(板上盯 有时间限制  9:30:00 ---  14:36:00)
                            if data_cache.OPENING_TIME < now_time < data_cache.WATCH_DISK_END_TIME:
                                # if symbol in data_cache.LIMIT_UP_SELL_CODES:
                                if today_limit_up_price == current_high:
                                    logger_info(
                                        f"【开盘临机】【{k_line_data[0]['sec_name']}】 触及涨停! 买一总金额:{round(current_quotes_buy[0][1] * current_quotes_buy[0][0] / 10000, 2)} 万,当日当时量:{current_volume}")
                                    # 如果 买一总金额 < 200000   买一总金额 在L1情况下估计的炸板前最后一刻的最低买一额无法缩小到更小,其本身跨度也因股票因时间因往下砸的力度而异,不然无法观察到结果。
                                    if current_quotes_buy[0][1] * current_quotes_buy[0][0] < 1000000:
                                        logger_info(
                                            f"【开盘临机】【炸板风险!!】【{k_line_data[0]['sec_name']}】 买盘金额小于100万! 买一额:【{current_quotes_buy[0][1]}】,当日当时量:{current_volume}")
                                        if current_volume < k_line_data[0]['volume'] * 0.6:
                                            logger_info(
                                                f"【开盘临机】【 炸板!!且当日量不足】【{k_line_data[0]['sec_name']}】 买盘小于1万 且 今日量小于昨日量的 0.6,设定委卖数量【十分之一仓】,当日当时量:{current_volume}")
                                            # 设定委卖数量【十分之一仓】
                                            order_methods.sell_order_by_part_volume(0.1, symbol,
                                                                                    position_volume_yesterday,
                                                                                    current_price,
                                                                                    k_line_data[0]['sec_name'],
                                                                                    index)
                                    else:
                                        logger_info(f"【开盘临机】【{k_line_data[0]['sec_name']}】 涨停封板!!")
                                    '''
                                    下面是目前看来更有效的板上盯卖
                                    '''
                                    # 如果 卖一 量 为零
                                    if current_quotes_sell[0][1] * current_quotes_sell[0][0] == 0:
                                        logger_info(
                                            f"【开盘临机】【强势封板!!!】【{k_line_data[0]['sec_name']}】 买一总金额:{round(current_quotes_buy[0][1] * current_quotes_buy[0][0] / 10000, 2)} 万,当日当时量:{current_volume}")
                                    else:
                                        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)
                            # 当前时间超过午盘时间【午盘决策】
                            if now_time > data_cache.NOON_MARKET_TIME:
                                # 进入当前最新价低于当日最低价 且 瞬时下跌
                                if current_price <= current_low and tick_growth < -0.2:
                                    # 进入昨日首板涨停视界(昨日涨停但前日未涨停)且 当日当前量未超昨日量
                                    if k_line_data[0]['attribute'] in data_cache.limit_up_type and k_line_data[1][
                                        'attribute'] not in data_cache.limit_up_type and current_volume <= \
                                            k_line_data[0]['volume']:
                                        if today_limit_up_price != current_high or today_growth < 7:
                                            logger_info(
                                                f"【午盘决策】【昨日涨停】【当日未涨停 或 当日当时涨幅小于7%】【{k_line_data[0]['sec_name']}】 设定委卖数量【十分之五仓】,当日当时涨幅为{today_growth}。最新价::{current_price},昨日收盘价:{k_line_data[0]['close']}")
                                            order_methods.sell_order_by_part_volume(0.5, symbol,
                                                                                    position_volume_yesterday,
                                                                                    current_price,
                                                                                    k_line_data[0]['sec_name'], index)
                            # 当前时间超过平仓时间【尾盘决断】
                            if now_time > data_cache.CLOSE_POSITION_TIME:
                                if today_limit_up_price != current_high or today_growth < 7:
                                    logger_info(
                                        f"【尾盘决断】【当日未涨停 或 当日当时涨幅小于7%】【{k_line_data[0]['sec_name']}】 设定委卖数量【全仓】,当日当时涨幅为{today_growth}。最新价::{current_price},昨日收盘价:{k_line_data[0]['close']}")
                                    order_methods.sell_order_by_part_volume(1, symbol, position_volume_yesterday,
                                                                            current_price,
                                                                            k_line_data[0]['sec_name'], index)
# L2级数据触发的板上盯的炸板策略