问财量化选股策略逻辑
该选股策略包括三个条件:
- 振幅大于1;
- 至少5根均线重合的股票;
- 机构抄底。
选股逻辑分析
该选股策略依据的是波动适度的股票,同时考虑到机构的参与,认为机构抄底的股票有较大的上涨潜力。
有何风险?
在选股时如果没有判断机构是何种机构,机构划分不精准,可能机构抄底的信息来源不清晰,或者被动跟随机构过多而被套,产生逆周期的波动。同时对于股票的价值是否真正能够被机构所发现持怀疑态度,存在盲目跟风的风险。
如何优化?
可以使用基于大数据分析的机构评分模型,该模型可以通过多种方式评估机构的实力、质量、风险等级等指标,提高机构评估的准确性。同时在选股时,还要加入更多的技术指标,如相对强度指标,MACD等指标,增加交叉验证,避免盲目跟随机构。
最终的选股逻辑
根据上述分析,本策略可优化为:
- 振幅大于1;
- 5日均线、10日均线、20日均线、30日均线、60日均线重合;
- 机构参与抄底;
- 结合机构评分指标和技术指标进行选股。
同花顺指标公式代码参考
本选股策略采用的是技术分析原则,没有特定的指标公式。
python代码参考
import pandas as pd
import tushare as ts
import talib
df = ts.get_stock_basics()
codes = df.index.tolist()
result = pd.DataFrame()
for code in codes:
is_amplitude_large = False
is_ma_converge = False
is_institution_buying = False
bars = ts.get_k_data(code, '2022-01-01', '2022-12-31')
if bars is not None and len(bars) > 1:
# 振幅大于1
high, low, close = bars['high'].values, bars['low'].values, bars['close'].values
amplitude = (high - low) / close[:-1]
is_amplitude_large = amplitude.max() > 0.01
# 至少5根均线重合的股票
ma_5 = talib.MA(close, timeperiod=5)
ma_10 = talib.MA(close, timeperiod=10)
ma_20 = talib.MA(close, timeperiod=20)
ma_30 = talib.MA(close, timeperiod=30)
ma_60 = talib.MA(close, timeperiod=60)
ma_count = len(set([ma[-1] for ma in [ma_5, ma_10, ma_20, ma_30, ma_60]]))
is_ma_converge = ma_count >= 5
# 机构抄底
df_inst_detail = ts.inst_detail(code, start='2022-01-01', end='2022-12-31')
if df_inst_detail is not None and len(df_inst_detail) > 0:
institution_volume = df_inst_detail['bamount'].sum()
if institution_volume > 0:
is_institution_buying = True
if is_amplitude_large and is_ma_converge and is_institution_buying:
result = result.append({'code': code, 'name': df.loc[code]['name'], 'price': bars['close'].iloc[-1], 'industry': df.loc[code]['industry']}, ignore_index=True)
result = result.sort_values(by=['industry'], ascending=False)
## 如何进行量化策略实盘?
请把您优化好的选股语句放入文章最下面模板的选股语句中即可。
select_sentence = '市值小于100亿' #选股语句。
模板如何使用?
点击图标右上方的复制按钮,复制到自己的账户即可使用模板进行回测。
## 如果有任何问题请添加 下方的二维码进群提问。
