admin
2025-03-13 b8ab86d048d8a2a34e54a020d304d6741062327f
日志调整
9个文件已修改
1个文件已添加
228 ■■■■ 已修改文件
strategy/L2_data_analysis.py 75 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
strategy/all_K_line.py 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
strategy/buying_strategy.py 27 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
strategy/check_timer.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
strategy/data_cache.py 43 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
strategy/index_market_trend_strategy.py 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
strategy/instant_time_market.py 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
strategy/kpl_api.py 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
strategy/order_methods.py 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
strategy/selling_strategy.py 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
strategy/L2_data_analysis.py
New file
@@ -0,0 +1,75 @@
import re
import ast
import datetime
import os
import constant
from log_module.log import logger_debug, logger_common
# 获取logger实例
logger = logger_common
# 读取log日志并转换格式
def read_and_parse_log(log_file_path):
    # 打开并读取日志文件
    with open(log_file_path, 'r', encoding='utf-8') as log_file:
        lines = log_file.readlines()
        # print(f"lines=={lines}")
    # 初始化一个列表数据 来安置转换好的日志文件
    parsed_logs = []
    # 正则表达式匹配日志格式,例如:YYYY-MM-DD HH:MM:SS LEVEL PID TID MESSAGE
    # 这里我们假设一个简化的格式:HH:MM:SS LEVEL MESSAGE
    # 正则表达式匹配日志格式,例如:YYYY-MM-DD HH:MM:SS.mmm | LEVEL | MODULE:FUNCTION:LINE - MESSAGE
    log_regex = re.compile(
        r'^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3} \|\s*(\w+)\s*\|\s*([\w.]+:\w+:\d+) -\s*(.*)$')
    for line in lines:
        match = log_regex.match(line.strip())
        if match:
            # 提取时间戳、日志级别和日志信息
            timestamp, level, message = match.groups()
            # 这里我们不添加时间戳和日志级别到parsed_logs,只添加日志信息
            parsed_logs.append(message)
    return parsed_logs
# 找到具体目标个股L2中有无大单记录
def find_L2_big_order_of_code(code):
    # 获取当前日期,并格式化为 'YYYY-MM-DD'
    current_date = datetime.datetime.now().strftime('%Y-%m-%d')
    # 声明要转义的文件的路径
    log_file_path = f'{constant.LOG_PATH}/transaction.{current_date}.log'
    # 检查文件是否存在,如果存在则继续处理,如果不存在则就此打住
    if not os.path.exists(log_file_path):
        logger.info(f"Error错误:{log_file_path}----文件不存在!")
        return
    parsed_logs = read_and_parse_log(log_file_path)
    # 使用列表推导式和 ast.literal_eval() 将字符串转换为列表
    true_lists = [ast.literal_eval(log) for log in parsed_logs]
    # 初始化一个标志变量,用于检查是否找到了特定股票代码
    found = False
    # 遍历转换后的列表
    for sublist in true_lists:
        if sublist and sublist[0] and sublist[0][0] == code:
            logger.info(f"找到大单的对应行列表 sublist[0]===={sublist[0]}")
            # print(f"找到大单的对应行列表 sublist[0]===={sublist[0]}")
            found = True  # 设置标志为 True,表示找到了
    # 检查是否没有找到特定股票代码
    if not found:
        logger.info(f"没有找到这个货:{code}")
        # print(f"没有找到这个货:{code}")
# 测试的时候可以调用一下
find_L2_big_order_of_code('002384')
# # 如果你需要将解析后的日志保存到新文件中,可以使用以下代码:
# output_file_path = 'path/to/your/parsed_logfile.txt'
# with open(output_file_path, 'w', encoding='utf-8') as output_file:
#     for log in parsed_logs:
#         output_file.write(log + '\n')
strategy/all_K_line.py
@@ -451,8 +451,8 @@
            now_time = datetime.datetime.now().strftime("%H:%M:%S")
            # print(f"now_time==={now_time}")
            # if now_time > data_cache.after_closing_time and data_cache.execution is False:
            # # if now_time > data_cache.after_closing_time:
            # if now_time > data_cache.AFTER_CLOSING_TIME and data_cache.execution is False:
            # # if now_time > data_cache.AFTER_CLOSING_TIME:
            #     data_cache.execution = True
            #     # 整理当日涨停信息并写入本地管理好本地数据
            #     kpl_api.get_arrange_limit_up_info()
@@ -476,16 +476,16 @@
            # 盘中不进行时间与数据的判断(也不能早于服务器重启时间,因为次日凌晨拉取的K线会有错误),一方面判断应该在开盘前完成,另一方面收盘后离最新拉取时间都还有很长时间
            # 在这个时间段内运行  9:00--9:30 或  15:00--23:00
            if data_cache.server_restart_time < now_time < data_cache.opening_time or data_cache.closing_time < now_time < data_cache.program_sleep_time:
            if data_cache.SERVER_RESTART_TIME < now_time < data_cache.OPENING_TIME or data_cache.CLOSING_TIME < now_time < data_cache.PROGRAM_SLEEP_TIME:
                # 然后判断一下,当K线字典中的任意一只个股的的第一个K线表中的第一个日期 等于 上一个交易日日期 或 今日日期  且  运行时时间未到 18:30 那么不需要新拉取直接读取已有的就行,
                # 否者还是得调用K线对象方法拉取,并重新读取赋值全局化
                # if hour < 18 or (hour == 18 and minute < 31):
                if now_time < data_cache.update_data_time:
                if now_time < data_cache.UPDATE_DATA_TIME:
                    # if now_time < data_cache.closing_time:
                    check_pre_trading_day = check_data_date(data_cache.DataCache().pre_trading_day)
                    if check_pre_trading_day is True:
                        # if hour >= 17:
                        if now_time > data_cache.checking_data_time:
                        if now_time > data_cache.CHECKING_DATA_TIME:
                            print(
                                f"未到【18:31】 但 既有数据 【是】 上个交易日数据 【不执行拉取K线】  ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε(/’-‘)/")
                    else:
strategy/buying_strategy.py
@@ -13,10 +13,11 @@
# import dateutil
# 引入掘金API
# from gm.api import *
from strategy import data_cache
from strategy import data_cache, L2_data_analysis
from strategy import basic_methods
from strategy import account_management
from strategy import order_methods
from utils import tool, huaxin_util
@@ -323,7 +324,7 @@
                                            logger.info(f"【不利】有概念买入已经 3 次了!不买了!!")
                                        elif len(data_cache.addition_position_symbols_set) >= 3:
                                            logger.info(f"【不利】当日已经买了3只票!不买了!!")
                                        elif now_time < data_cache.opening_time or now_time > data_cache.noon_market_time:
                                        elif now_time < data_cache.OPENING_TIME or now_time > data_cache.NOON_MARKET_TIME:
                                            logger.info(f"【不利】不在9:30-13:05时间内!不买!!")
                                        else:
                                            logger.info(
@@ -340,6 +341,10 @@
                                            data_cache.have_plate_buy_times += 1
                                            # 将买入个股的当时概念添加到全局变量中存储
                                            data_cache.bought_plate.extend(limit_up_plate_included_list)
                                            # 查看一下该股有无大单
                                            L2_data_analysis.find_L2_big_order_of_code(symbol_code)
                                    # 有概念无强度视界
                                    if strength_list_have_it is False:
                                        logger.info(
@@ -404,7 +409,7 @@
                                                logger.info(f"【不利】有概念无强度买入已经1次了!不买了!!")
                                            elif len(data_cache.addition_position_symbols_set) >= 4:
                                                logger.info(f"【不利】当日已经买了3只票!不买了!!")
                                            elif now_time < data_cache.opening_time or now_time > data_cache.noon_market_time:
                                            elif now_time < data_cache.OPENING_TIME or now_time > data_cache.NOON_MARKET_TIME:
                                                logger.info(f"【不利】不在9:30-13:05时间内!不买!!")
                                            else:
                                                logger.info(
@@ -419,6 +424,8 @@
                                                data_cache.have_plate_buy_times += 1
                                                # 将买入个股的当时概念添加到全局变量中存储
                                                data_cache.bought_plate.extend(limit_up_plate_included_list)
                                                # 查看一下该股有无大单
                                                L2_data_analysis.find_L2_big_order_of_code(symbol_code)
                                '''
                                无概念 有强度视界
@@ -486,7 +493,7 @@
                                                    logger.info(f"【不利】有强度买入 1 次了!不买了!!")
                                                elif len(data_cache.addition_position_symbols_set) >= 3:
                                                    logger.info(f"【不利】当日已经买了3只票!不买了!!")
                                                elif now_time < data_cache.opening_time or now_time > data_cache.noon_market_time:
                                                elif now_time < data_cache.OPENING_TIME or now_time > data_cache.NOON_MARKET_TIME:
                                                    logger.info(f"【不利】不在9:30-13:05时间内!不买!!")
                                                else:
                                                    logger.info(
@@ -504,6 +511,8 @@
                                                    data_cache.have_strength_buy_times += 1
                                                    # 将买入个股的当时概念添加到全局变量中存储
                                                    data_cache.bought_plate.extend(strength_plate)
                                                    # 查看一下该股有无大单
                                                    L2_data_analysis.find_L2_big_order_of_code(symbol_code)
                                '''
                                无概念无强度 有小量换大涨幅度视界
                                '''
@@ -527,7 +536,7 @@
                                                    logger.info(
                                                        f"【不利】今日成交量 < 昨日的{ratios}倍,不买!!公司名称:{k_line_data[0]['sec_name']},今日目前成交量为昨日的{round(current_volume / k_line_data[0]['volume'], 2)}")
                                                elif buying_strong is not True and current_volume <= k_line_data[0][
                                                    'volume'] * ratios and now_time > data_cache.morn_market_time:
                                                    'volume'] * ratios and now_time > data_cache.MORN_MARKET_TIME:
                                                    logger.info(
                                                        f"【不利】买一量小于卖一量 且 挂买总量小于挂卖总量 且 当日量不足 (9:35后实施)!不买!!公司名称:{k_line_data[0]['sec_name']},自由市值:{free_market_value} 亿,最新价: {current_price}")
                                                    logger.info(
@@ -581,7 +590,7 @@
                                                    logger.info(
                                                        f"【不利】当日已经买了4只票!不买了!!")
                                                elif (
                                                        data_cache.morn_market_time < now_time < data_cache.noon_market_time) is False or free_market_value < 100 or (
                                                        data_cache.MORN_MARKET_TIME < now_time < data_cache.NOON_MARKET_TIME) is False or free_market_value < 100 or (
                                                        today_open_growth < 5 or today_growth < 5):
                                                    logger.info(
                                                        f"【不利】不在9:35-13:05时间内!或自由市值小于100亿!或开盘涨幅或当日当时涨幅都小于5%!不买!!")
@@ -601,6 +610,8 @@
                                                    data_cache.have_small_turn_large_buy_times += 1
                                                    # 将买入个股的当时概念添加到全局变量中存储
                                                    data_cache.bought_plate.append(k_line_data[0]['sec_name'])
                                                    # 查看一下该股有无大单
                                                    L2_data_analysis.find_L2_big_order_of_code(symbol_code)
                                '''
                                昨日涨停视界,今日连板预期盯视界
                                '''
@@ -624,7 +635,7 @@
                                            elif len(data_cache.addition_position_symbols_set) >= 3:
                                                logger.info(
                                                    f"【不利】当日已经买了3只票!不买!!")
                                            elif now_time < data_cache.opening_time or now_time > data_cache.morn_market_time:
                                            elif now_time < data_cache.OPENING_TIME or now_time > data_cache.MORN_MARKET_TIME:
                                                logger.info(
                                                    f"【不利】不在9:30-9:35时间内!不买!!")
                                            else:
@@ -659,7 +670,7 @@
                                            elif len(data_cache.addition_position_symbols_set) >= 3:
                                                logger.info(
                                                    f"【不利】当日已经买了3只票!不买!!")
                                            elif now_time < data_cache.opening_time or now_time > data_cache.morn_market_time:
                                            elif now_time < data_cache.OPENING_TIME or now_time > data_cache.MORN_MARKET_TIME:
                                                logger.info(
                                                    f"【不利】不在9:30-9:05时间内!不买!!")
                                            else:
strategy/check_timer.py
@@ -25,7 +25,7 @@
            # 声明赋值实时时间
            now_time = datetime.datetime.now().strftime("%H:%M:%S")
            # print(f"now_time==={now_time}")
            if now_time > data_cache.after_closing_time and data_cache.execution is False:
            if now_time > data_cache.AFTER_CLOSING_TIME and data_cache.execution is False:
                # 整理当日涨停信息并写入本地管理好本地数据
                kpl_api.get_arrange_limit_up_info()
                logger.info(f"整理当日涨停信息 已经运行完成")
strategy/data_cache.py
@@ -108,26 +108,29 @@
'''
设定基本时间点
设定常用当前时间函数方法
'''
Local_startup_time = datetime.datetime.now().strftime("%H:%M:%S")
server_restart_time = datetime.time(9, 00, 00).strftime("%H:%M:%S")  # 定义9:00
L1_data_start_time = datetime.time(9, 15, 00).strftime("%H:%M:%S")  # 定义9:15
before_open_bidding_time = datetime.time(9, 20, 00).strftime("%H:%M:%S")  # 定义9:20
open_bidding_time = datetime.time(9, 25, 00).strftime("%H:%M:%S")  # 定义 盘前 集合竞价 时间
later_open_bidding_time = datetime.time(9, 25, 6).strftime("%H:%M:%S")  # 定义 盘前 集合竞价 时间
after_open_bidding_time = datetime.time(9, 25, 12).strftime("%H:%M:%S")  # 定义 集合竞价 开始后 时间
opening_time = datetime.time(9, 30, 00).strftime("%H:%M:%S")  # 定义开盘时间
morn_market_time = datetime.time(9, 35, 00).strftime("%H:%M:%S")  # 定义早盘时间
noon_market_time = datetime.time(13, 5, 00).strftime("%H:%M:%S")  # 定义午盘时间
close_position_time = datetime.time(14, 55, 00).strftime("%H:%M:%S")  # 定义平仓时间
watch_disk_end_time = datetime.time(14, 56, 00).strftime("%H:%M:%S")  # 定义 板上盯结束时间
close_bidding_time = datetime.time(14, 57, 00).strftime("%H:%M:%S")  # 定义 盘后 集合竞价 时间
closing_time = datetime.time(15, 00, 00).strftime("%H:%M:%S")  # 定义 收盘时间
after_closing_time = datetime.time(15, 1, 00).strftime("%H:%M:%S")  # 定义 收盘后时间
checking_data_time = datetime.time(17, 00, 00).strftime("%H:%M:%S")  # 定义 检查数据时间
update_data_time = datetime.time(18, 31, 00).strftime("%H:%M:%S")  # 定义更新数据时间
program_sleep_time = datetime.time(23, 00, 00).strftime("%H:%M:%S")  # 定义程序休眠时间
now_time = datetime.datetime.now().strftime("%H:%M:%S")  # 定义并实时获取 当前时间
'''
设定常用时间点【常量】
'''
SERVER_RESTART_TIME = datetime.time(9, 00, 00).strftime("%H:%M:%S")  # 定义9:00
L1_DATA_START_TIME = datetime.time(9, 15, 00).strftime("%H:%M:%S")  # 定义9:15
BEFORE_OPEN_BIDDING_TIME = datetime.time(9, 20, 00).strftime("%H:%M:%S")  # 定义9:20
OPEN_BIDDING_TIME = datetime.time(9, 25, 00).strftime("%H:%M:%S")  # 定义 盘前 集合竞价 时间
LATER_OPEN_BIDDING_TIME = datetime.time(9, 25, 6).strftime("%H:%M:%S")  # 定义 盘前 集合竞价 时间
AFTER_OPEN_BIDDING_TIME = datetime.time(9, 25, 12).strftime("%H:%M:%S")  # 定义 集合竞价 开始后 时间
OPENING_TIME = datetime.time(9, 30, 00).strftime("%H:%M:%S")  # 定义开盘时间
MORN_MARKET_TIME = datetime.time(9, 35, 00).strftime("%H:%M:%S")  # 定义早盘时间
NOON_MARKET_TIME = datetime.time(13, 5, 00).strftime("%H:%M:%S")  # 定义午盘时间
CLOSE_POSITION_TIME = datetime.time(14, 55, 00).strftime("%H:%M:%S")  # 定义平仓时间
WATCH_DISK_END_TIME = datetime.time(14, 56, 00).strftime("%H:%M:%S")  # 定义 板上盯结束时间
CLOSE_BIDDING_TIME = datetime.time(14, 57, 00).strftime("%H:%M:%S")  # 定义 盘后 集合竞价 时间
CLOSING_TIME = datetime.time(15, 00, 00).strftime("%H:%M:%S")  # 定义 收盘时间
AFTER_CLOSING_TIME = datetime.time(15, 1, 00).strftime("%H:%M:%S")  # 定义 收盘后时间
CHECKING_DATA_TIME = datetime.time(17, 00, 00).strftime("%H:%M:%S")  # 定义 检查数据时间
UPDATE_DATA_TIME = datetime.time(18, 31, 00).strftime("%H:%M:%S")  # 定义更新数据时间
PROGRAM_SLEEP_TIME = datetime.time(23, 00, 00).strftime("%H:%M:%S")  # 定义程序休眠时间
# 读取已经获取到并存储在本地的目标范围的个股的板块概念
# 读取JSON文件并解析为字典
@@ -199,8 +202,6 @@
record_current_open_execution = False
# 定义一个实时计算最高价和最低价的函数是否在规定时间内启动
record_high_and_low_execution = False
# 定义一个集合竞价后开盘前的逻辑是否只进入判断一次
# later_open_bidding_time_is_entered = False ##################
# 定义一个集合竞价时间段条件分支逻辑的初始执行次数
execution_times = 0
# 定义一个有概念逻辑分支买入进入执行的初始化次数
strategy/index_market_trend_strategy.py
@@ -21,6 +21,12 @@
# 指数行情策略函数
def instant_trend_strategy(current_info):
    len_current_info = len(current_info)
    # 初始化 index_K_line 字典,后期加上日期属性,每日分行写入本地JSONL文件中
    index_K_line = {
        'Shanghai': {},
        'Shenzhen': {},
        'TSXV': {}
    }
    if current_info is not None and len_current_info > 0:
        # print(f"current_info------------{current_info}")
        # 上证指数数据
@@ -65,12 +71,21 @@
        # 在集合竞价时更新一下 各个指数的开盘涨幅
        now_time = datetime.datetime.now().strftime("%H:%M:%S")
        # 9:25:06 < now_time < 9:25:12
        if data_cache.later_open_bidding_time < now_time < data_cache.after_open_bidding_time:
        # 9:25:06 < now_time < 9:25:12 记录开盘指数 及 开盘涨幅
        if data_cache.LATER_OPEN_BIDDING_TIME < now_time < data_cache.AFTER_OPEN_BIDDING_TIME:
            index_K_line['Shanghai']['Shanghai_open_index'] = Shanghai_index
            index_K_line['Shenzhen']['Shenzhen_open_index'] = Shenzhen_index
            index_K_line['TSXV']['TSXV_open_index'] = TSXV_index
            data_cache.Shanghai_open_growth = data_cache.Shanghai_today_growth
            data_cache.Shenzhen_open_growth = data_cache.Shenzhen_today_growth
            data_cache.TSXV_open_growth = data_cache.TSXV_today_growth
        # 15:00:00 < now_time < 15:01:00  记录收盘指数
        if data_cache.CLOSING_TIME < now_time < data_cache.AFTER_CLOSING_TIME:
            index_K_line['Shanghai']['Shanghai_close_index'] = Shanghai_index
            index_K_line['Shenzhen']['Shenzhen_close_index'] = Shenzhen_index
            index_K_line['TSXV']['TSXV_close_index'] = TSXV_index
        logger.info(f"上证指数 开盘涨幅 ==== {round(data_cache.Shanghai_open_growth, 4)}%")
        logger.info(f"深证指数 开盘涨幅 ==== {round(data_cache.Shenzhen_open_growth, 4)}%")
        logger.info(f"创业板指 开盘涨幅 ==== {round(data_cache.TSXV_open_growth, 4)}%")
strategy/instant_time_market.py
@@ -32,7 +32,7 @@
            # 在data_cache中获取到推送过来的实时指数行情数据
            stock_index_dict = data_cache.stock_index_dict
            now_time = datetime.datetime.now().strftime("%H:%M:%S")
            if len(stock_index_dict) == 0 and data_cache.L1_data_start_time < now_time < data_cache.closing_time:
            if len(stock_index_dict) == 0 and data_cache.L1_DATA_START_TIME < now_time < data_cache.CLOSING_TIME:
                print(f"9:15--15:00 实时指数数据为空===={stock_index_dict}")
            index_judge_thread_manager(stock_index_dict)
        except Exception as error:
@@ -71,10 +71,10 @@
    # 获取当前时间
    now_time = datetime.datetime.now().strftime("%H:%M:%S")
    # 如果当前时间大于09:25:06才运行最高价和最低价的运算
    if data_cache.later_open_bidding_time < now_time:
        # if data_cache.after_closing_time < now_time:
        if now_time < data_cache.opening_time and data_cache.record_current_open_execution is False:
            # if now_time < data_cache.after_closing_time:
    if data_cache.LATER_OPEN_BIDDING_TIME < now_time:
        # if data_cache.AFTER_CLOSING_TIME < now_time:
        if now_time < data_cache.OPENING_TIME and data_cache.record_current_open_execution is False:
            # if now_time < data_cache.AFTER_CLOSING_TIME:
            logger.info(f"在开盘前启动,采用【华鑫数据】记录 开盘价")
            data_cache.record_current_open_execution = True
            # print(f"current_info=={current_infos}")
@@ -160,9 +160,9 @@
    # 获取当前时间
    now_time = datetime.datetime.now().strftime("%H:%M:%S")
    # 如果当前时间大于09:25:06才运行最高价和最低价的运算
    if data_cache.later_open_bidding_time < now_time:
        # if data_cache.after_closing_time < now_time:
        if data_cache.Local_startup_time < data_cache.opening_time:
    if data_cache.LATER_OPEN_BIDDING_TIME < now_time:
        # if data_cache.AFTER_CLOSING_TIME < now_time:
        if data_cache.now_time < data_cache.OPENING_TIME:
            logger.info(f"【在】开盘前启动,采用【华鑫数据】记录 最高最低价")
            # # 如果在9:30前启动,则只采用【华鑫数据】记录 最高最低价
            # while True:
@@ -271,7 +271,7 @@
            now_start = time.time()
            current_infos = l1_data_api.get_current_info()
            now_time = datetime.datetime.now().strftime("%H:%M:%S")
            if len(current_infos) == 0 and now_time > data_cache.L1_data_start_time:
            if len(current_infos) == 0 and now_time > data_cache.L1_DATA_START_TIME:
                print(f"9:15后 l1数据为空=l1_data_current_infos===={current_infos}")
            # for i in current_infos:
            #     if i[0] == '000001':
@@ -302,7 +302,7 @@
    try:
        now_start = time.time()
        now_time = datetime.datetime.now().strftime("%H:%M:%S")
        if len(current_infos) == 0 and now_time > data_cache.L1_data_start_time:
        if len(current_infos) == 0 and now_time > data_cache.L1_DATA_START_TIME:
            print(f"9:15后 l1数据为空=l1_data_current_infos===={current_infos}")
        # for i in current_infos:
        #     if i[0] == '000001':
strategy/kpl_api.py
@@ -279,7 +279,7 @@
        dask_result = batch_get_plate_codes(ds)
        dask_result.compute()
        now_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        if data_cache.L1_data_start_time < now_time < data_cache.closing_time:
        if data_cache.L1_DATA_START_TIME < now_time < data_cache.CLOSING_TIME:
            logger.info(f"精选板块股票强度数据更新 == {market_sift_plate_stock_dict}")
    return market_sift_plate_stock_dict
@@ -333,7 +333,7 @@
    # 设定当前时间点
    now_time = datetime.datetime.now().strftime("%H:%M:%S")
    # print(f"now_time===={now_time}")
    if data_cache.server_restart_time < now_time < data_cache.update_data_time:
    if data_cache.SERVER_RESTART_TIME < now_time < data_cache.UPDATE_DATA_TIME:
        # print(f"在时间内使用--------------------------")
        # 获取涨停信息列表
        limit_up_info = get_limit_up_info()
@@ -719,7 +719,7 @@
        try:
            if data_cache.position_automatic_management_switch is True:
                now_time = datetime.datetime.now().strftime("%H:%M:%S")
                if data_cache.server_restart_time < now_time < data_cache.update_data_time:
                if data_cache.SERVER_RESTART_TIME < now_time < data_cache.UPDATE_DATA_TIME:
                    # 获取大盘综合强度分数
                    data_cache.real_time_market_strong = get_market_strong()
                    # data_cache.time_sharing_market_strong_dirt = time_sharing_market_strong_dirt.update({now: data_cache.real_time_market_strong})
strategy/order_methods.py
@@ -41,12 +41,14 @@
        # 调用资金查询函数 查看资金变化
        account_management.finance_management()
        logger.info(f"更新的资金数据data_cache.account_finance_dict=={data_cache.account_finance_dict}")
        # 买票后添加 持仓代码集合
        data_cache.position_symbols_set.add(symbol)
        # 买票后添加 今日新增持仓代码集合
        data_cache.addition_position_symbols_set.add(symbol)
        logger.info(f"当前持仓数量:::{len(data_cache.position_symbols_set)}")
        logger.info(f"今日新增持仓数量:::{len(data_cache.addition_position_symbols_set)}")
        # 因为上面的更新持仓数据函数会计算 今日新增持仓数量,所以如果再手动新增持仓数据会重复计算【考虑到持仓函数有可能会有延迟,这也可能是同时运行一段时间没有出现BUG的原因,先暂时保留以下这段代码,只是注释】
        # # 买票后添加 持仓代码集合
        # data_cache.position_symbols_set.add(symbol)
        # # 买票后添加 今日新增持仓代码集合
        # data_cache.addition_position_symbols_set.add(symbol)
        # logger.info(f"当前持仓数量:::{len(data_cache.position_symbols_set)}")
        # logger.info(f"今日新增持仓数量:::{len(data_cache.addition_position_symbols_set)}")
# 下单买入函数(按可用资金的一定比例,在涨停价买)【按金额买 高级版】
strategy/selling_strategy.py
@@ -161,7 +161,7 @@
                # 处理行情订阅中持仓金额>0的个股(或者直接把先把指数的数据过滤掉放进来)
                if position_volume_yesterday > 0:  # 如果可用资金不等于0 且 持仓数量大于0 (不知名原因导致有些票会获取到零值导致后续公式报错,阻止intraday_growth函数正常运行)
                    # 进入集合竞价前和收盘前作持仓可用交易,在此时间为不生效
                    if data_cache.before_open_bidding_time < now_time < data_cache.after_closing_time:
                    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瞬时涨幅
@@ -195,7 +195,7 @@
                        集合竞价阶段决断(只判断一次)
                        '''
                        #  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):
                        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}")
@@ -363,7 +363,7 @@
                        '''
                        开盘阶段临机决策
                        '''
                        if data_cache.opening_time < now_time < data_cache.after_closing_time:
                        if data_cache.OPENING_TIME < now_time < data_cache.AFTER_CLOSING_TIME:
                            # 当日未涨停视界
                            if today_limit_up_price != current_high:
                                # 昨日起飞失败视界
@@ -437,7 +437,7 @@
                                    pass
                            # 当日涨停视界(板上盯 有时间限制  9:30:00 ---  14:36:00)
                            if data_cache.opening_time < now_time < data_cache.watch_disk_end_time:
                            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(
@@ -505,7 +505,7 @@
                                                                                            index)
                            # 当前时间超过午盘时间【午盘决策】
                            if now_time > data_cache.noon_market_time:
                            if now_time > data_cache.NOON_MARKET_TIME:
                                # 进入当前最新价低于当日最低价 且 瞬时下跌
                                if current_price <= current_low and tick_growth < -0.2:
                                    # 进入昨日首板涨停视界(昨日涨停但前日未涨停)且 当日当前量未超昨日量
@@ -517,7 +517,7 @@
                                                                                    current_price,
                                                                                    k_line_data[0]['sec_name'], index)
                            # 当前时间超过平仓时间【尾盘决断】
                            if now_time > data_cache.close_position_time:
                            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']}")