admin
2025-03-07 d2011f3cfc2d54a50ebf00d1bd2b9e03288d972d
日志调整
2个文件已修改
71 ■■■■■ 已修改文件
strategy/index_market_trend_strategy.py 51 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
strategy/kpl_api.py 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
strategy/index_market_trend_strategy.py
@@ -46,6 +46,7 @@
        TSXV_index_turnover = round(TSXV_index_data[2]/100000000, 2)  # 创业板指 当日当时成交额度
        TSXV_Yesterday_closing_index = round(TSXV_index_data[3], 2)  # 深证指数 昨日收盘指数
        logger.info(f"创业板 指数:{TSXV_index}   昨日收盘指数:{TSXV_Yesterday_closing_index}  成交量------------{TSXV_index_volume}亿 手   成交额------------{TSXV_index_turnover}亿 元")
        # 调用涨幅公式计算对应的股票tick瞬时涨幅
        data_cache.Shanghai_tick_growth = basic_methods.tick_growth('000001', Shanghai_index)
        data_cache.Shanghai_today_growth = basic_methods.intraday_growth(Shanghai_index, Shanghai_Yesterday_closing_index)
@@ -75,4 +76,54 @@
        logger.info(f"创业板指 开盘涨幅 ==== {round(data_cache.TSXV_open_growth, 4)}%")
# 大盘指数趋势预期函数(用于对大盘开盘后短期内的趋势预测)
def index_trend_expectation():
    index_trend_expectation_score = 0
    # 判断三大指数开盘涨幅 预期
    if data_cache.Shanghai_open_growth > 0 and data_cache.Shenzhen_open_growth > 0 and data_cache.TSXV_open_growth > 0:
        index_composite_open_increase = '三大指数:高开'
        index_trend_expectation_score += 10
        if data_cache.Shanghai_open_growth >= 1 and data_cache.Shenzhen_open_growth >= 1 and data_cache.TSXV_open_growth >= 1:
            index_composite_open_increase = '三大指数:高开1% 以上'
            index_trend_expectation_score += 10
    elif data_cache.Shanghai_open_growth < 0 and data_cache.Shenzhen_open_growth < 0 and data_cache.TSXV_open_growth < 0:
        index_composite_open_increase = '三大指数:低开'
        index_trend_expectation_score -= 10
        if data_cache.Shanghai_open_growth <= 1 and data_cache.Shenzhen_open_growth <= 1 and data_cache.TSXV_open_growth <= 1:
            index_composite_open_increase = '三大指数:低开1% 以下'
            index_trend_expectation_score -= 10
    else:
        index_composite_open_increase = '三大指数:涨跌不一'
    logger.info(f"开盘指数开盘涨幅播报:{index_composite_open_increase}")
    # 判断三大指数开盘后当日涨幅 预期
    if data_cache.Shanghai_today_growth > data_cache.Shanghai_open_growth and data_cache.Shenzhen_today_growth > data_cache.Shenzhen_open_growth and data_cache.TSXV_today_growth > data_cache.TSXV_open_growth:
        index_composite_today_increase = '三大指数:短期高走'
        index_trend_expectation_score += 10
    elif data_cache.Shanghai_today_growth < data_cache.Shanghai_open_growth and data_cache.Shenzhen_today_growth < data_cache.Shenzhen_open_growth and data_cache.TSXV_today_growth < data_cache.TSXV_open_growth:
        index_composite_today_increase = '三大指数:短期低走'
        index_trend_expectation_score -= 10
    else:
        index_composite_today_increase = '三大指数:短期走势不一'
    logger.info(f"开盘指数开盘短期走势播报:{index_composite_today_increase}")
    # 判断三大指数开盘涨幅 预期
    if data_cache.Shanghai_tick_growth > 0 and data_cache.Shenzhen_tick_growth > 0 and data_cache.TSXV_tick_growth > 0:
        index_composite_tick_increase = '三大指数:瞬时高走'
        index_trend_expectation_score += 2
        if data_cache.Shanghai_tick_growth >= 0.01 and data_cache.Shenzhen_tick_growth >= 0.01 and data_cache.TSXV_tick_growth >= 0.01:
            index_composite_tick_increase = '三大指数:高走0.01% 以上'
            index_trend_expectation_score += 4
    elif data_cache.Shanghai_tick_growth < 0 and data_cache.Shenzhen_tick_growth < 0 and data_cache.TSXV_tick_growth < 0:
        index_composite_tick_increase = '三大指数:瞬时低走'
        index_trend_expectation_score -= 2
        if data_cache.Shanghai_tick_growth <= 0.01 and data_cache.Shenzhen_tick_growth <= 0.01 and data_cache.TSXV_tick_growth <= 0.01:
            index_composite_tick_increase = '三大指数:低走0.01% 以下'
            index_trend_expectation_score -= 4
    else:
        index_composite_tick_increase = '三大指数:涨跌不一'
    logger.info(f"开盘指数开盘瞬时走势播报:{index_composite_tick_increase}")
    return index_trend_expectation_score
strategy/kpl_api.py
@@ -14,6 +14,7 @@
# import requests
from strategy import data_cache
from strategy import basic_methods
from strategy.index_market_trend_strategy import index_trend_expectation
from trade import middle_api_protocol
from utils import hx_qc_value_util
@@ -230,7 +231,7 @@
            # print(f"{i[1]} 强度:{i[2]}")
            # 通过板块ID获取其下面的个股强度列表
            its_stock = getCodesByPlate(i[0])
            print(f"======={i[0]}=======")
            # print(f"======={i[0]}=======")
            its_stock = json.loads(its_stock)
            # print(f"its_stock['list']  ===  {its_stock['list']}")
            # print(f"its_stock['list'][0]  ===  {its_stock['list'][0]}")
@@ -724,10 +725,17 @@
                    usefulMoney = data_cache.account_finance_dict[0].get('usefulMoney', 0)
                    logger.info(f"账户可用资金==={usefulMoney}元")
                    # 低迷情绪比例
                    low_emotion_mood_emotion = 1
                    low_emotion_mood_ratio = 1
                    if data_cache.real_time_market_strong <= 33:
                        low_emotion_mood_emotion = 0.1
                    logger.info(f"低迷情绪比例===={low_emotion_mood_emotion}")
                        low_emotion_mood_ratio = 0.1
                        if data_cache.real_time_market_strong <= 10:
                            low_emotion_mood_ratio = 0
                    logger.info(f"极端低迷情绪比例===={low_emotion_mood_ratio * 100}%")
                    index_trend_expectation_score = index_trend_expectation()
                    logger.info(f"大盘指数情绪预期分数==={index_trend_expectation_score}分")
                    print(f"大盘指数情绪预期分数==={index_trend_expectation_score}分")
                    # 获取计算今天新增的持仓数量
                    addition_position_number = len(data_cache.addition_position_symbols_set)
                    # 定义一个今日的剩余新增持仓数量的变量
@@ -735,9 +743,7 @@
                    if Unfinished_opening_plan_number != 0:
                        # 根据账户可用金额 计算今日计划下单金额
                        # (账户可用金额/今日最大新增持仓票数) * (大盘综合强度分数 * 0.01)
                        data_cache.today_planned_order_amount = (
                                                                        usefulMoney * low_emotion_mood_emotion / Unfinished_opening_plan_number) * (
                                                                        data_cache.real_time_market_strong * 0.01)
                        data_cache.today_planned_order_amount = (usefulMoney * index_trend_expectation_score / Unfinished_opening_plan_number) * (data_cache.real_time_market_strong * 0.01)
        except Exception as error:
            logger.error(f"获取实时大盘行情情绪综合强度[分数] 函数报错: {error}")