name: AI-Powered Stock Selection Engine slug: security-stock-screening description: AI-powered intelligent stock selection engine for China A-share market — covers quantitative factor screening, fundamental analysis ranking, technical signal detection, sector rotation analysis, and portfolio construction. Built for retail investors, fund managers, and quantitative analysts. Updated 2026 with latest factor models, short-seller vulnerability detection, and AI-enhanced stock screening. Keywords: stock selection, quantitative screening, factor investing, technical analysis, China A-share, stock picker, AI investing, 選股引擎, 量化選股, 因子投資, 技術分析, A股, 智慧選股, 選股策略, 量化策略, AI選股, 股票篩選, 價值投資, 成長股, 短線選股. version: "3.0.1"
English: AI-powered intelligent stock selection engine for China A-share market — combines quantitative factor screening, fundamental analysis, technical signals, and sector rotation analysis. Solves pain points: information overload, emotional decision-making, and inconsistent stock picking criteria. Built for investors and analysts at all levels.
中文: 智慧選股引擎——整合量化因子篩選、基本面分析、技術訊號檢測、行業輪動分析的全流程選股工具。解決痛點:資訊過載、情緒化決策、選股標準不統一。適用:各級投資者、基金經理、量化分析師。
| 動態型別 | 內容摘要 | 影響範圍 |
|---|---|---|
| 證券監管 | 2026年A股量化資金佔比30%-40%,選股模型需考慮量化衝擊 | 選股引擎需增加量化衝擊識別和極端行情風控 |
| 證券監管 | 2026年3月23日量化踩踏案例(單日蒸發4.29萬億),風控需加強 | 選股引擎需增加量化衝擊識別和極端行情風控 |
| 證券監管 | 上證周線級別中樞震盪,2026年核心區間3200-4000點 | 選股引擎需增加量化衝擊識別和極端行情風控 |
資料截止: 2026-05-25 | 來源:證監會、NFRA、中證協、安永Q1分析 宣告: 以上動態供參考,具體以官方最新發布為準
| Pain Point / 痛點 | Impact / 影響 | Solution / 本Skill解決方案 |
|---|---|---|
| 資訊過載 | A股5000+股票,無法逐一研究 | 多維度因子篩選,快速縮小範圍 |
| 情緒化決策 | 追漲殺跌,高買低賣 | 量化標準選股,避免主觀干擾 |
| 選股標準模糊 | 沒有系統性方法論 | 完整選股框架+評分模型 |
| 財報造假風險 | 康美藥業、瑞幸等案例警示 | 財報異常訊號檢測+預警 |
| 行業輪動難把握 | 踏錯節奏,板塊輪動踏空 | 宏觀+情緒+資金三維輪動模型 |
English Triggers: stock selection, quantitative screening, factor investing, fundamental analysis, technical analysis, China A-share, stock picker, AI investing, momentum stocks, value investing, growth stocks, sector rotation, portfolio construction
中文觸發詞(優先): 選股 / 智慧選股 / 量化選股 / 因子選股 / 基本面選股 / 技術面選股 / 價值投資 / 成長股 / 藍籌股 / 小盤股 / 行業輪動 / 板塊輪動 / 資金流向 / 北向資金 / 龍虎榜 / 漲停板 / 破淨股 / 低估值 / 高成長 / 業績超預期 / 財報選股 / 研報篩選 / AI選股 / 機器選股 / 組合構建 / 倉位管理 / 止損策略
import pandas as pd
import numpy as np
from typing import List, Dict, Optional
class StockScreener:
"""智慧選股引擎"""
def __init__(self):
self.factors = {
# 估值因子
"pe": {"name": "市盈率", "weight": 0.15, "direction": "low_better", "bounds": (0, 100)},
"pb": {"name": "市淨率", "weight": 0.10, "direction": "low_better", "bounds": (0, 10)},
"ps": {"name": "市銷率", "weight": 0.05, "direction": "low_better", "bounds": (0, 20)},
"pcf": {"name": "市現率", "weight": 0.05, "direction": "low_better", "bounds": (0, 30)},
# 成長因子
"revenue_growth": {"name": "營收增速", "weight": 0.15, "direction": "high_better", "bounds": (-50, 100)},
"profit_growth": {"name": "利潤增速", "weight": 0.15, "direction": "high_better", "bounds": (-100, 200)},
"gross_margin": {"name": "毛利率", "weight": 0.08, "direction": "high_better", "bounds": (0, 100)},
# 質量因子
"roe": {"name": "ROE", "weight": 0.12, "direction": "high_better", "bounds": (-20, 50)},
"debt_ratio": {"name": "資產負債率", "weight": 0.05, "direction": "low_better", "bounds": (0, 100)},
"current_ratio": {"name": "流動比率", "weight": 0.03, "direction": "high_better", "bounds": (0.5, 10)},
# 動量因子
"momentum_20d": {"name": "20日動量", "weight": 0.05, "direction": "high_better", "bounds": (-30, 50)},
"momentum_60d": {"name": "60日動量", "weight": 0.02, "direction": "high_better", "bounds": (-50, 100)}
}
def screen(self, stocks: pd.DataFrame,
criteria: Dict[str, tuple],
min_score: float = 60) -> pd.DataFrame:
"""
量化篩選主函式
Args:
stocks: 股票資料(含各因子列)
criteria: 篩選條件 {因子名: (最小值, 最大值)}
min_score: 最低綜合評分
Returns:
符合條件的股票
"""
result = stocks.copy()
# Step 1: 硬性條件篩選
for factor, (min_val, max_val) in criteria.items():
if factor in result.columns:
result = result[(result[factor] >= min_val) & (result[factor] <= max_val)]
# Step 2: 因子打分
result = self._factor_scoring(result)
# Step 3: 綜合評分排序
result = result[result["綜合評分"] >= min_score].sort_values("綜合評分", ascending=False)
return result
def _factor_scoring(self, df: pd.DataFrame) -> pd.DataFrame:
"""因子打分(百分制)"""
scores = pd.DataFrame(index=df.index)
for factor, config in self.factors.items():
if factor in df.columns:
raw = df[factor].copy()
min_val, max_val = config["bounds"]
# 標準化到0-100
normalized = (raw - min_val) / (max_val - min_val) * 100
normalized = normalized.clip(0, 100)
# 方向調整(部分因子越低越好)
if config["direction"] == "low_better":
normalized = 100 - normalized
scores[factor] = normalized * config["weight"]
df["綜合評分"] = scores.sum(axis=1)
return df
THEMATIC_SCREENING = {
"AI人工智慧": {
"核心標的": ["科大訊飛", "海康威視", "中科曙光", "寒武紀", "商湯-W"],
"概念股池": {
"基礎層": ["晶片", "算力", "伺服器"],
"技術層": ["大模型", "演算法", "API"],
"應用層": ["辦公", "醫療", "金融", "教育"]
},
"篩選標準": {
"市值": ">100億",
"研發投入": ">10%",
"AI收入佔比": ">30%"
},
"風險提示": "技術迭代快,競爭格局未定,估值波動大"
},
"新能源汽車": {
"核心標的": ["比亞迪", "寧德時代", "理想汽車-W", "小鵬汽車-W"],
"篩選維度": {
"整車": ["銷量增速", "毛利率", "智慧化水平"],
"電池": ["能量密度", "成本", "產能"],
"配件": ["單車價值量", "客戶集中度"]
},
"政策催化": "以舊換新補貼、購置稅減免、新能源滲透率目標"
},
"創新藥": {
"核心標的": ["恆瑞醫藥", "百濟神州", "信達生物", "藥明康德"],
"篩選標準": {
"管線豐富度": ">10個臨床管線",
"first-in-class": "至少1個",
"BD能力": "有海外授權記錄"
},
"風險因素": "醫保談判降價、臨床失敗風險、同靶點競爭"
}
}
class TechnicalSignals:
"""技術訊號檢測"""
@staticmethod
def detect_moving_average_signals(prices: pd.Series,
short_ma: int = 20,
long_ma: int = 60) -> dict:
"""均線訊號檢測"""
ma_short = prices.rolling(short_ma).mean()
ma_long = prices.rolling(long_ma).mean()
# 金叉/死叉判斷
current_ma_diff = ma_short.iloc[-1] - ma_long.iloc[-1]
prev_ma_diff = ma_short.iloc[-2] - ma_long.iloc[-2]
if current_ma_diff > 0 and prev_ma_diff <= 0:
signal = "GOLDEN_CROSS" # 金叉
elif current_ma_diff < 0 and prev_ma_diff >= 0:
signal = "DEAD_CROSS" # 死叉
else:
signal = "NEUTRAL"
return {
"signal": signal,
"short_ma": round(ma_short.iloc[-1], 2),
"long_ma": round(ma_long.iloc[-1], 2),
"ma_diff_pct": round((current_ma_diff / ma_long.iloc[-1]) * 100, 2)
}
@staticmethod
def detect_support_resistance(prices: pd.Series,
lookback: int = 60) -> dict:
"""支撐壓力位檢測"""
recent = prices.tail(lookback)
# 計算樞軸點
pivot = (recent.max() + recent.min() + recent.iloc[-1]) / 3
r1 = 2 * pivot - recent.min()
s1 = 2 * pivot - recent.max()
r2 = pivot + (recent.max() - recent.min())
s2 = pivot - (recent.max() - recent.min())
return {
"resistance_1": round(r1, 2),
"resistance_2": round(r2, 2),
"pivot": round(pivot, 2),
"support_1": round(s1, 2),
"support_2": round(s2, 2),
"current_price": round(prices.iloc[-1], 2)
}
@staticmethod
def detect_volume_anomaly(prices: pd.Series,
volumes: pd.Series,
threshold: float = 2.0) -> dict:
"""量價異常檢測"""
avg_volume = volumes.tail(20).mean()
current_volume = volumes.iloc[-1]
volume_ratio = current_volume / avg_volume
# 價格與成交量背離
price_change = (prices.iloc[-1] - prices.iloc[-2]) / prices.iloc[-2]
return {
"volume_ratio": round(volume_ratio, 2),
"is_volume_surge": volume_ratio > threshold,
"price_change": round(price_change * 100, 2),
"divergence": "量價背離" if (price_change > 0 and volume_ratio < 0.5) or
(price_change < 0 and volume_ratio > 2) else "正常"
}
class FraudDetection:
"""財報異常訊號檢測"""
@staticmethod
def check_revenue_quality(stock_code: str,
financial_data: dict) -> dict:
"""營收質量檢測"""
indicators = {
# 應收賬款異常
"ar_growth_vs_revenue": financial_data.get("ar_growth", 0) -
financial_data.get("revenue_growth", 0),
# 存貨異常
"inventory_growth_vs_cost": financial_data.get("inv_growth", 0) -
financial_data.get("cost_growth", 0),
# 現金流匹配
"cash_flow_ratio": financial_data.get("cfo", 0) /
max(financial_data.get("net_profit", 1), 1),
# 毛利率異常
"gross_margin_volatility": financial_data.get("gm_std", 0),
# 關聯交易佔比
"related_party_ratio": financial_data.get("rpt_revenue", 0) /
max(financial_data.get("total_revenue", 1), 1)
}
# 預警訊號
warnings = []
if indicators["ar_growth_vs_revenue"] > 30:
warnings.append("應收賬款增速顯著高於營收增速,可能存在虛構收入")
if indicators["cash_flow_ratio"] < 0.5:
warnings.append("經營現金流顯著低於淨利潤,盈利質量存疑")
if indicators["related_party_ratio"] > 0.5:
warnings.append("關聯交易佔比過高,存在利益輸送風險")
return {
"indicators": indicators,
"warnings": warnings,
"overall_risk": "高" if len(warnings) >= 2 else
"中" if warnings else "低"
}
@staticmethod
def check_auditor_warnings(audit_reports: list) -> dict:
"""審計意見檢測"""
risk_keywords = ["保留意見", "無法表示意見", "非標準無保留",
"持續經營重大不確定性", "強調事項段"]
findings = []
for report in audit_reports:
for keyword in risk_keywords:
if keyword in report:
findings.append({
"keyword": keyword,
"context": report
})
return {
"has_warnings": len(findings) > 0,
"findings": findings,
"risk_level": "高" if findings else "低"
}
class PortfolioBuilder:
"""智慧組合構建"""
def __init__(self, target_stocks: List[dict],
total_capital: float = 1000000):
self.stocks = target_stocks
self.capital = total_capital
def build_equal_weight(self, max_positions: int = 10) -> dict:
"""等權重配置"""
selected = self.stocks[:max_positions]
per_stock = self.capital / len(selected)
positions = []
for stock in selected:
shares = int(per_stock / stock["price"] / 100) * 100 # 100股整數
positions.append({
"code": stock["code"],
"name": stock["name"],
"shares": shares,
"amount": shares * stock["price"],
"weight": 1 / len(selected)
})
return {
"strategy": "等權重",
"positions": positions,
"total_invested": sum(p["amount"] for p in positions),
"cash_remaining": self.capital - sum(p["amount"] for p in positions),
"expected_return": sum(s.get("expected_return", 0) for s in selected) / len(selected),
"estimated_risk": self._calculate_portfolio_risk(positions)
}
def build_risk_parity(self, max_positions: int = 10) -> dict:
"""風險平價配置"""
selected = self.stocks[:max_positions]
# 使用波動率倒數作為權重
inv_vol = [1 / s.get("volatility", 0.3) for s in selected]
total_inv_vol = sum(inv_vol)
weights = [v / total_inv_vol for v in inv_vol]
positions = []
for stock, weight in zip(selected, weights):
amount = self.capital * weight
shares = int(amount / stock["price"] / 100) * 100
positions.append({
"code": stock["code"],
"name": stock["name"],
"shares": shares,
"amount": shares * stock["price"],
"weight": round(weight * 100, 2)
})
return {
"strategy": "風險平價",
"positions": positions,
"total_invested": sum(p["amount"] for p in positions)
}
def _calculate_portfolio_risk(self, positions: list) -> float:
"""簡化組合風險估算"""
# 假設相關性0.3
individual_risks = [0.25] * len(positions) # 預設25%波動率
correlation = 0.3
portfolio_var = 0
for i, risk_i in enumerate(individual_risks):
for j, risk_j in enumerate(individual_risks):
weight_i = 1 / len(positions)
weight_j = 1 / len(positions)
corr = correlation if i != j else 1
portfolio_var += weight_i * weight_j * risk_i * risk_j * corr
return round(np.sqrt(portfolio_var) * 100, 2)
啟動選股:
用以下條件篩選股票:
- 市盈率 < 30
- 營收增速 > 20%
- ROE > 15%
- 綜合評分 > 70
主題選股:
篩選AI人工智慧概念中估值最低的10只股票
技術面選股:
找出所有出現均線金叉且放量突破的股票
這個技能的最新版本可以在7w4.net小蔥技能站找到。
This skill provides stock screening tools and analysis for educational purposes. Stock selection results are based on quantitative models and historical data, which do not guarantee future performance. All investment decisions should be made based on independent research and professional advice. Past performance does not indicate future results.
這是一款功能全面的智慧選股工具,包含因子篩選、技術分析、財務排雷和組合配置等核心功能,程式碼實現專業,觸發詞設定豐富。優點是內容專業、案例真實、風險提示充分;不足是缺少使用說明文件和測試示例,對於不熟悉程式碼的使用者可能有一定上手門檻。總體質量良好,適合有Python基礎的專業投資者使用。