(同花顺量化)9点25分涨幅小于6%_、15分钟周期MACD绿柱变短、rsi小于65

用户头像神盾局量子研究部
2023-08-31 发布

问财量化选股策略逻辑

选股逻辑:在RSI小于65,15分钟周期MACD绿柱变短,且9点25分涨幅小于6%的股票中,选择作为股票池。

选股逻辑分析

该选股策略在技术指标的基础上,加入了交易时间点的涨幅来筛选股票。其中的RSI和MACD指标用于判断股票的技术性质,涨幅阈值用于过滤开盘价高开、短期内涨幅较大的股票。

有何风险?

该选股策略可能会忽视一些有大幅上涨可能的股票,并且过分依赖技术指标可能会忽视一些基本面好但技术走势不佳的股票。

如何优化?

  1. 可以加入其他时间点的涨幅条件,如中午收盘前、年中年末等关键时点的涨幅情况。

  2. 可以结合其他基本面指标,如收益、净利润等,来对标的股票进行全方位分析。

最终的选股逻辑

在RSI小于65,15分钟周期MACD绿柱变短,且9点25分涨幅小于6%的股票中,选择作为股票池。

同花顺指标公式代码参考

  1. RSI指标:

通达信指标公式:RSI(CLOSE,N)

同花顺指标公式:RSI(CLOSE,N)

  1. MACD指标:

通达信指标公式:MACD(CLOSE,SHORT,LONG,M)

同花顺指标公式:MACD(CLOSE,SHORT,LONG,M)

python代码参考

以下是基于该选股策略编写的Python代码示例,仅供参考。

import tushare as ts
import talib
import time

def select_stocks(stocks):
    res = []
    for stock in stocks:
        try:
            # 判断RSI小于65
            rsi_threshold = 65
            hist_data = ts.get_k_data(stock, ktype='D', end=ts.get_today_date(), autype='qfq')
            if hist_data is None or hist_data.empty or len(hist_data) < 14:
                continue
            rsi_data = talib.RSI(hist_data['close'].values, timeperiod=14)
            if rsi_data is None or rsi_data[-1] >= rsi_threshold:
                continue

            # 判断MACD条件
            hist_data = ts.get_k_data(stock, ktype='15', end=ts.get_today_date(), autype='qfq')
            if hist_data is None or hist_data.empty or len(hist_data) <= 10:
                continue
            macd, macdsignal, macdhist = talib.MACD(hist_data['close'].values, fastperiod=12, slowperiod=26, signalperiod=9)
            if macd is None or macdsignal is None or macdhist is None or macdhist[-1] > macdhist[-2]:
                continue

            # 判断9点25分涨跌幅
            price_data = ts.get_realtime_quotes(stock)
            if price_data is None or price_data.empty or float(price_data['open']) == 0.0:
                continue
            rise = (float(price_data['price']) / float(price_data['open']) - 1.0) * 100.0
            if rise >= 6.0:
                continue

            res.append(stock)

        except Exception as e:
            print(e)
            continue

    return res

stocks = ts.get_stock_basics().index
res = select_stocks(stocks)
print(res)
    ## 如何进行量化策略实盘?
    请把您优化好的选股语句放入文章最下面模板的选股语句中即可。

    select_sentence = '市值小于100亿' #选股语句。

    模板如何使用?

    点击图标右上方的复制按钮,复制到自己的账户即可使用模板进行回测。


    ## 如果有任何问题请添加 下方的二维码进群提问。
    ![94c5cde12014f99e262a302741275d05.png](http://u.thsi.cn/imgsrc/pefile/94c5cde12014f99e262a302741275d05.png)
收益&风险
源码

评论