问财量化选股策略逻辑
- 今日增仓占比>5%
- 连续3天以上大单净量大于0.05
- 15分钟周期MACD绿柱变短
选股逻辑分析
这个策略的逻辑是基于三个条件来筛选股票。首先,要求股票在今天的交易中增仓比例大于5%,这表明机构投资者对这只股票有兴趣。其次,要求这只股票连续三天以上的大单净量大于0.05,这表明这只股票有较多的买入交易。最后,要求这只股票的15分钟周期MACD绿柱变短,这表明这只股票的短期趋势正在好转。
有何风险?
这个策略的潜在风险是它可能过于侧重于短期趋势,而忽略了长期趋势。此外,如果机构投资者在某一天突然大量买入或卖出这只股票,可能会导致股票价格的剧烈波动。
如何优化?
为了优化这个策略,可以考虑加入一些长期趋势指标,例如移动平均线或布林线,以更好地评估股票的长期趋势。此外,可以考虑加入一些过滤条件,例如要求股票的成交量和换手率处于合理的水平,以避免交易过于活跃的股票。
最终的选股逻辑
以下是最终的量化选股策略逻辑:
import talib
def select_stock():
# 获取所有A股股票的代码和基本信息
stock_codes = get_stock_codes()
# 初始化股票池
stock_pool = []
# 遍历每个股票
for code in stock_codes:
# 获取股票的基本信息
info = get_stock_info(code)
# 过滤条件
if info['vol'] > 0.05 and info['turnover'] > 0.05 and info['vwap'] > 10 and info['macd'][-1] < 0:
# 计算今日增仓占比
today_buy_amount = info['buy_amount'] / info['total_amount']
today_buy_percentage = today_buy_amount / info['close'] * 100
if today_buy_percentage > 5:
# 连续三天以上大单净量大于0.05
three_day_buy_amount = info['buy_amount'] - info['sell_amount'] + info['buy_amount'] - info['sell_amount'] + info['buy_amount'] - info['sell_amount']
three_day_buy_percentage = three_day_buy_amount / info['total_amount'] * 100
if three_day_buy_percentage > 5:
# 15分钟周期MACD绿柱变短
macd = talib.MACD(info['close'], fastperiod=12, slowperiod=26, signalperiod=9)
if macd[-1] > macd[-2] and macd[-1] > macd[-3]:
stock_pool.append(code)
# 返回股票池
return stock_pool
python代码参考
import talib
def get_stock_codes():
# 获取所有A股股票的代码和基本信息
codes = []
for code in stock_code_list:
codes.append(code)
return codes
def get_stock_info(code):
# 获取股票的基本信息
url = f'https://quote.eastmoney.com/{code}'
response = requests.get(url)
data = response.json()
return data
def get_stock_code_list():
# 获取所有A股股票的代码
codes = []
for i in range(0, 1000):
url = f'https://quote.eastmoney.com/hsgt/hsgt00{str(i+1)}'
response = requests.get(url)
data = response.json()
codes.append(data['code'])
return codes
def select_stock():
# 获取所有A股股票的代码和基本信息
stock_codes = get_stock_codes()
# 初始化股票池
stock_pool = []
# 遍历每个股票
for code in stock_codes:
# 获取股票的基本信息
info = get_stock_info(code)
# 过滤条件
if info['vol'] > 0.05 and info['turnover'] > 0.05 and info['vwap'] > 10 and info['macd'][-1] < 0:
# 计算今日增仓占比
today_buy_amount = info['buy_amount'] / info['total_amount']
today_buy_percentage = today_buy_amount / info['close'] * 100
if today_buy_percentage > 5:
# 连续三天以上大单净量大于0.05
three_day_buy_amount = info['buy_amount'] - info['sell_amount
## 如何进行量化策略实盘?
请把您优化好的选股语句放入文章最下面模板的选股语句中即可。
select_sentence = '市值小于100亿' #选股语句。
模板如何使用?
点击图标右上方的复制按钮,复制到自己的账户即可使用模板进行回测。
## 如果有任何问题请添加 下方的二维码进群提问。


