admin
2025-04-14 b973d8fbd2d57f3b67f34601b2215f5da581982d
修改当日BUG
5个文件已修改
47 ■■■■■ 已修改文件
strategy/buying_strategy.py 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
strategy/market_sentiment_analysis.py 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
strategy/order_methods.py 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
strategy/plate_strength_analysis.py 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
strategy/selling_strategy.py 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
strategy/buying_strategy.py
@@ -127,6 +127,9 @@
    # current_quotes_buy == [[23.25, 800], [23.24, 1100], [23.23, 1100], [23.22, 2200], [23.21, 2300]]
    # current_quotes_sell == [[23.27, 500], [23.29, 200], [23.3, 6900], [23.31, 500], [23.32, 200]]
    current_created_at = current_info[7]  # 当前信息创建时间
    # 如果最新价获取失败,就取买一价
    if current_price <= 0:
        current_price = current_quotes_buy[0][0]
    if type(current_created_at) == int:
        current_created_at = huaxin_util.convert_time(current_created_at)
    # 获取不到开盘价就不处理后续操作【此操作还包括了current_high,current_low 也一并处理了】
strategy/market_sentiment_analysis.py
@@ -453,12 +453,12 @@
# ====================== 核心因子计算 ======================
def calculate_factors(data):
    data = {'-1': '284', '-10': '2', '-2': '80', '-3': '32', '-4': '11', '-5': '6', '-6': '6', '-7': '2', '-8': '0',
            '-9': '1', '0': '101', '1': '1376', '10': '8', '2': '1760', '3': '964', '4': '285', '5': '108', '6': '49',
            '7': '17', '8': '9', '9': '2', 'DT': 3, 'SJDT': '2', 'SJZT': '15', 'STDT': '1', 'STZT': '7', 'SZJS': 4600,
            'XDJS': 427, 'ZSZDFB': '1939,238,57,446,45,8,271,19,2,42,7,1,26,19,5,217,71,12,', 'ZT': 22,
            'sign': '市场人气较好', 'szln': 1113353, 'qscln': 3725698, 's_zrcs': 2185592, 'q_zrcs': 5573160,
            's_zrtj': 58079140, 'q_zrtj': 134866542}
    # data = {'-1': '284', '-10': '2', '-2': '80', '-3': '32', '-4': '11', '-5': '6', '-6': '6', '-7': '2', '-8': '0',
    #         '-9': '1', '0': '101', '1': '1376', '10': '8', '2': '1760', '3': '964', '4': '285', '5': '108', '6': '49',
    #         '7': '17', '8': '9', '9': '2', 'DT': 3, 'SJDT': '2', 'SJZT': '15', 'STDT': '1', 'STZT': '7', 'SZJS': 4600,
    #         'XDJS': 427, 'ZSZDFB': '1939,238,57,446,45,8,271,19,2,42,7,1,26,19,5,217,71,12,', 'ZT': 22,
    #         'sign': '市场人气较好', 'szln': 1113353, 'qscln': 3725698, 's_zrcs': 2185592, 'q_zrcs': 5573160,
    #         's_zrtj': 58079140, 'q_zrtj': 134866542}
    if data is not None and len(data) > 0:
        zero = int(data.get('0'))
@@ -550,7 +550,6 @@
        max_key = max(rise_and_fall_dirt, key=rise_and_fall_dirt.get)
        # 找到最小值对应的键
        min_key = min(rise_and_fall_dirt, key=rise_and_fall_dirt.get)
        # 涨跌比因子 ---------------------------------------------------
        factors['rise_vs_fall'] = {
            'rise_vs_fall_ratio': round(rise_sum / fall_sum, 2) if fall_sum > 0 else 0,  # 涨跌比
@@ -650,8 +649,6 @@
                            f"上涨家数:{rise_numbers},下跌家数:{fall_numbers},实际涨停家数:{actual_limit_up_numbers},实际跌停家数:{actual_limit_down_numbers}")
                        logger.info(f"涨跌统计字典{data_cache.rise_and_fall_statistics_dirt}")
                    usefulMoney = data_cache.account_finance_dict[0].get('usefulMoney', 0)
                    logger.info(f"账户可用资金==={usefulMoney}元")
                    # 低迷情绪比例
                    low_emotion_mood_ratio = 1
                    # 33分是个两级分化阶梯不好,目前不好拿捏,暂时不用
@@ -674,6 +671,8 @@
                    # 定义一个今日的剩余新增持仓数量的变量
                    Unfinished_opening_plan_number = 3 - addition_position_number
                    logger.info(f"今日的剩余新增持仓数量==={Unfinished_opening_plan_number}")
                    usefulMoney = data_cache.account_finance_dict[0].get('usefulMoney', 0)
                    logger.info(f"账户可用资金==={usefulMoney}元")
                    if Unfinished_opening_plan_number != 0:
                        # 如果GUI看盘上没有手动设置具体的下单金额,就按照评分策略的金额下单,否则就按照GUI设置的金额下单。
                        if data_cache.BUY_MONEY_PER_CODE < 0:
@@ -682,8 +681,7 @@
                            #  ((大盘综合强度分数 + 大盘指数情绪预期分数) * 0.01) * (账户可用金额 * 0.9 * 极端低迷情绪比例 / 今日最大新增持仓票数)
                            # data_cache.today_planned_order_amount = ((data_cache.real_time_market_strong + data_cache.index_trend_expectation_score) * 0.01) * (
                            #                                                 usefulMoney * 0.9 * low_emotion_mood_ratio / Unfinished_opening_plan_number)
                            data_cache.today_planned_order_amount = (
                                        usefulMoney * 0.95 * low_emotion_mood_ratio / Unfinished_opening_plan_number)
                            data_cache.today_planned_order_amount = usefulMoney * 0.95 * low_emotion_mood_ratio / Unfinished_opening_plan_number
                            logger.info(
                                f"采用开仓策略计算方式=》今日计划下单金额:{data_cache.today_planned_order_amount},")
                        else:
strategy/order_methods.py
@@ -25,9 +25,10 @@
        # 暂停自动买
        logger.info(f"在交易方法函数处 关闭了 自动买")
        return
    # 限制交易标的的单价范围
    if current_price < 3 or current_price > 30:
        # 当前单价超出预设限制
        logger.info(f"当前标的个股{sec_name}单价超出预设限制!预设值3 < current_price < 30,当前最新价{current_price}")
        logger.info(f"当前标的个股【{sec_name}】单价超出预设限制!预设值3 < current_price < 30,当前最新价{current_price}")
        return
    price = round(float(current_price), 2)
    volume = (int(buy_order_value / price) // 100) * 100
strategy/plate_strength_analysis.py
@@ -19,11 +19,10 @@
    @dask.delayed
    def request_plate_codes(i):
        plate_name = i[1]
        log_data = None
        its_stock = json.loads(kpl_api.getCodesByPlate(i[0]))
        now_time_str = tool.get_now_time_str()
        if data_cache.OPENING_TIME < now_time_str < data_cache.NOON_MARKET_TIME:
            log_data = {plate_name: its_stock['list']}
        # now_time_str = tool.get_now_time_str()
        # if data_cache.OPENING_TIME < now_time_str < data_cache.NOON_MARKET_TIME:
        log_data = {plate_name: its_stock['list']}
        # 尝试过滤掉无意义的概念板块(plate_name not in ['科创板', '北交所', '次新股', '无', 'ST板块', 'ST摘帽', '并购重组', '国企改革','超跌', '壳资源', '股权转让', '送转填权']) and '增长' in plate_name
        if (plate_name not in ['科创板', '北交所', '次新股', '无', 'ST板块', 'ST摘帽', '并购重组', '国企改革', '超跌',
                               '壳资源', '股权转让', '送转填权']) or ('增长' in plate_name):
@@ -70,6 +69,10 @@
                # 并更新到精选板块个股字典中
                market_sift_plate_stock_dict.update(stock_power_item)
        return log_data
    # 定义一个时间段,在这个时间段内才会执行下面的代码,主要就是把强度数据作为日志打印存储下来。
    now_time = tool.get_now_time_str()
    if not (data_cache.OPENING_TIME < now_time < data_cache.NOON_MARKET_TIME):
        return
    data = (kpl_api.getMarketJingXuanRealRankingInfo())
    market_sift_plate = json.loads(data)
@@ -92,11 +95,10 @@
                continue
            for b in r:
                log_datas[b] = r[b]
        now_time = tool.get_now_time_str()
        if data_cache.L1_DATA_START_TIME < now_time < data_cache.NOON_MARKET_TIME:
            # logger.info(f"精选板块股票强度数据更新 == {market_sift_plate_stock_dict}")
            # 只在盘中时间获取
            kpl_api.KPLStockOfMarketsPlateLogManager().add_log(market_sift_plate['list'], log_datas)
        # logger.info(f"精选板块股票强度数据更新 == {market_sift_plate_stock_dict}")
        # 只在盘中时间获取
        kpl_api.KPLStockOfMarketsPlateLogManager().add_log(market_sift_plate['list'], log_datas)
    return market_sift_plate_stock_dict
strategy/selling_strategy.py
@@ -125,6 +125,7 @@
    current_quotes_buy = current_info[5]  # 买5档数据
    current_quotes_sell = current_info[6]  # 卖5档数据
    current_created_at = current_info[7]  # 当前信息创建时间
    # 如果最新价获取失败,就取买一价
    if current_price <= 0:
        current_price = current_quotes_buy[0][0]