问财量化选股策略逻辑
选股逻辑:在RSI小于65、高点为两日最高,且15分钟周期MACD的绿柱长度变短的条件下,筛选出具有较强技术面和短期反弹潜力的股票。
选股逻辑分析
该选股策略同样是以技术面指标RSI、走势和MACD为基础,但相比前面的选股策略,增加了MACD红、绿柱长度的条件,并将选股周期再次缩短。选股集中在技术面和短期反弹潜力较强的个股。
有何风险?
该选股策略的短期性和依赖MACD指标特点可能导致杂乱无章的结果,需要避免盲目跟买/卖现象的发生。
如何优化?
1.考虑新增其他的技术面和基本面指标,减少对MACD指标的依赖性;
2.建立选股策略的长期性,添加短期走势与长趋势的仓位分配等手段;
3.加强风险控制,建立有效止盈、止损策略和合理的持仓比例。
最终的选股逻辑
在RSI小于65、高点为两日最高,且15分钟周期MACD的绿柱长度变短的条件下,筛选出具有较强技术面和短期反弹潜力的股票。
同花顺指标公式代码参考
- RSI指标:
通达信指标公式:RSI(CLOSE,N)
同花顺指标公式:RSI(CLOSE,N)
- MACD指标:
通达信指标公式:MACD(EMA(CLOSE,SHORT),EMA(CLOSE,LONG),MID)
同花顺指标公式:MACD(CLOSE,SHORT,LONG,MID)
- 筛选绿柱变短:
通达信指标公式:REF(MACD(EMA(CLOSE,SHORT),EMA(CLOSE,LONG),MID),1) > MACD(EMA(CLOSE,SHORT),EMA(CLOSE,LONG),MID)
同花顺指标公式:REF(MACD(CLOSE,SHORT,LONG,MID),1) > MACD(CLOSE,SHORT,LONG,MID)
python代码参考
以下是基于该选股策略编写的Python代码示例,仅供参考。
import tushare as ts
import pandas as pd
import talib
def select_stocks():
res = []
stocks_info = ts.get_stock_basics()
for stock in stocks_info.index:
try:
rsi_threshold = 65
if stocks_info.loc[stock]['timeToMarket'] > 20150101:
continue
if stocks_info.loc[stock]['code'].startswith('688'):
continue
hist_data = ts.get_hist_data(stock)
if hist_data is None:
continue
high_data = pd.Series(hist_data['high'].values)
if high_data[-1] != high_data[-2:].max():
continue
transaction_data = ts.get_today_ticks(stock)
if transaction_data is None or transaction_data.empty or transaction_data['changepercent'].iloc[-1] <= 0.0 or transaction_data['volume'].iloc[-1] == 0 or transaction_data['amount'].iloc[-1] == 0:
continue
rsi_data = talib.RSI(hist_data['close'].values, timeperiod=14)
if rsi_data is None or rsi_data[-1] > rsi_threshold:
continue
macd, macdsignal, macdhist = talib.MACD(hist_data['close'].values, fastperiod=12, slowperiod=26, signalperiod=9)
if macdhist[-1] < macdhist[-2]:
continue
res.append(stock)
except Exception as e:
continue
return res
res = select_stocks()
print(res)
注:以上代码示例较为简单,实际情况更为复杂,在具体使用时需要根据实际情况进行修改。
## 如何进行量化策略实盘?
请把您优化好的选股语句放入文章最下面模板的选股语句中即可。
select_sentence = '市值小于100亿' #选股语句。
模板如何使用?
点击图标右上方的复制按钮,复制到自己的账户即可使用模板进行回测。
## 如果有任何问题请添加 下方的二维码进群提问。


