A China A-share analysis tool based on value investing theory, aimed at ordinary investors engaging in low-frequency trading.
When to Use
Call this skill when the user requests the following operations:
- Analyze a certain A-share stock
- Screen stocks that meet the criteria
- Compare multiple stocks or stocks within an industry
- Calculate stock valuation or intrinsic value
- View a stock's financial health
- Detect financial anomaly risks
Prerequisites
Python Environment Requirements
pip install akshare pandas numpy
Dependency Check
Before performing any analysis, first check whether akshare is installed:
python -c "import akshare; print(akshare.__version__)"
If not installed, prompt the user to install:
pip install akshare
Core Modules
1. Stock Screener
Screen stocks that meet the criteria
2. Financial Analyzer
In-depth financial analysis of individual stocks
3. Industry Comparator
Horizontal comparative analysis within the same industry
4. Valuation Calculator
Intrinsic value estimation and margin of safety calculation
Workflow 1: Stock Screening
Used when the user requests stock screening.
Step 1: Collect Screening Criteria
Ask the user for screening criteria. Provide the following options for the user to choose or customize:
Valuation metrics:
- PE (Price-to-Earnings Ratio): e.g., PE < 15
- PB (Price-to-Book Ratio): e.g., PB < 2
- PS (Price-to-Sales Ratio): e.g., PS < 3
Profitability:
- ROE (Return on Equity): e.g., ROE > 15%
- ROA (Return on Assets): e.g., ROA > 8%
- Gross margin: e.g., > 30%
- Net margin: e.g., > 10%
Growth:
- Revenue growth rate: e.g., > 10%
- Net profit growth rate: e.g., > 15%
- Consecutive years of growth: e.g., >= 3 years
Dividends:
- Dividend yield: e.g., > 3%
- Consecutive years of dividend payments: e.g., >= 5 years
Financial safety:
- Debt-to-asset ratio: e.g., < 60%
- Current ratio: e.g., > 1.5
- Quick ratio: e.g., > 1
Screening scope:
- All A-shares
- CSI 300 constituent stocks
- CSI 500 constituent stocks
- ChiNext/STAR Market
- User-defined list
Step 2: Execute Screening
python scripts/stock_screener.py \
--scope "hs300" \
--pe-max 15 \
--roe-min 15 \
--debt-ratio-max 60 \
--dividend-min 2 \
--output screening_result.json
Parameter descriptions:
--scope: Screening scope (all/hs300/zz500/cyb/kcb/custom:600519,000858,...)--pe-max/--pe-min: PE range--pb-max/--pb-min: PB range--roe-min: Minimum ROE--growth-min: Minimum growth rate--debt-ratio-max: Maximum debt-to-asset ratio--dividend-min: Minimum dividend yield--output: Output file path
Step 3: Present Results
Read screening_result.json and present it to the user in table form:
| Code | Name | PE | PB | ROE | Dividend yield | Score |
|---|---|---|---|---|---|---|
| 600519 | Kweichow Moutai | 25.3 | 8.5 | 30.2% | 2.1% | 85 |
Workflow 2: Stock Analysis
Used when the user requests analysis of a certain stock.
Step 1: Collect Stock Information
Ask the user:
- Stock code or name
- Analysis depth level:
- Summary level: Key metrics + investment conclusion (1 page)
- Standard level: Financial analysis + valuation + industry comparison + risk disclosure
- Deep level: Complete research report, including historical data tracking
Step 2: Fetch Stock Data
python scripts/data_fetcher.py \
--code "600519" \
--data-type all \
--years 5 \
--output stock_data.json
Parameter description:
--code: Stock code--data-type: Data type (basic/financial/valuation/holder/all)--years: How many years of historical data to retrieve--output: Output file
Step 3: Run Financial Analysis
python scripts/financial_analyzer.py \
--input stock_data.json \
--level standard \
--output analysis_result.json
Parameter description:
--input: Input stock data file--level: Analysis depth (summary/standard/deep)--output: Output file
Step 4: Calculate Valuation
python scripts/valuation_calculator.py \
--input stock_data.json \
--methods dcf,ddm,relative \
--discount-rate 10 \
--growth-rate 8 \
--output valuation_result.json
Parameter description:
--input: Stock data file--methods: Valuation method (dcf/ddm/relative/all)--discount-rate: Discount rate (%)--growth-rate: Perpetual growth rate (%)--margin-of-safety: Margin of safety (%)--output: Output file
Step 5: Generate Report
Read the analysis results, refer to the templates/analysis_report.md template to generate a Chinese analysis report.
Report structure (standard level):
- Company overview: Basic information, main business
- Financial health: Balance sheet analysis
- Profitability: DuPont analysis, profit margin trends
- Growth analysis: Revenue/profit growth trends
- Valuation analysis: DCF/DDM/relative valuation
- Risk disclosure: Financial anomaly detection, shareholder reduction
- Investment conclusion: Composite score, action recommendations
Workflow 3: Industry Comparison (Industry Comparison)
Step 1: Collect Comparison Targets
Ask the user:
- Target stock code(s) (can be multiple)
- Or: industry classification + number of comparisons
Step 2: Fetch Industry Data
python scripts/data_fetcher.py \
--codes "600519,000858,002304" \
--data-type comparison \
--output industry_data.json
Or retrieve by industry:
python scripts/data_fetcher.py \
--industry "白酒" \
--top 10 \
--output industry_data.json
Step 3: Generate Comparison
python scripts/financial_analyzer.py \
--input industry_data.json \
--mode comparison \
--output comparison_result.json
Step 4: Present Comparison Table
| Metric | Kweichow Moutai | Wuliangye | Yanghe Stock | Industry average |
|---|---|---|---|---|
| PE | 25.3 | 18.2 | 15.6 | 22.4 |
| ROE | 30.2% | 22.5% | 20.1% | 18.5% |
| Gross margin | 91.5% | 75.2% | 72.3% | 65.4% |
| Rating | 85 | 78 | 75 | - |
Workflow 4: Valuation Calculator (Valuation Calculation)
Step 1: Collect Valuation Parameters
Ask the user for valuation parameters (or use defaults):
DCF model parameters:
- Discount rate (WACC): default 10%
- Forecast period: default 5 years
- Perpetual growth rate: default 3%
DDM model parameters:
- Required rate of return: default 10%
- Dividend growth rate: estimated using historical data
Relative valuation parameters:
- Comparison benchmark: industry average / historical average
Step 2: Run Valuation
python scripts/valuation_calculator.py \
--code "600519" \
--methods all \
--discount-rate 10 \
--terminal-growth 3 \
--forecast-years 5 \
--margin-of-safety 30 \
--output valuation.json
Step 3: Present Valuation Results
| Valuation method | Intrinsic value | Current price | Margin of safety price | Conclusion |
|---|---|---|---|---|
| DCF | ¥2,150 | ¥1,680 | ¥1,505 | Undervalued |
| DDM | ¥1,980 | ¥1,680 | ¥1,386 | Undervalued |
| Relative valuation | ¥1,850 | ¥1,680 | ¥1,295 | Fair |
Financial Anomaly Detection (Financial Anomaly Detection)
Automatically detect the following anomaly signals during analysis:
Detection item
-
Accounts receivable anomaly
- Accounts receivable growth rate > revenue growth rate × 1.5
- Accounts receivable turnover days increase significantly
-
Cash flow divergence
- Net profit continues to grow but operating cash flow declines
- Cash income ratio < 80%
-
Abnormal inventory
- Inventory growth rate > Revenue growth rate × 2
- Inventory turnover days increase significantly
-
Abnormal gross margin
- Gross margin volatility > Industry average volatility × 2
- Gross margin severely deviates from peers
-
Related-party transactions
- Proportion of related-party transactions too high (> 30%)
-
Shareholder reduction
- Recent reduction announcement by major shareholder
- Concentrated reduction by executives
Risk level
- 🟢 Low risk: No obvious abnormality
- 🟡 Medium risk: 1-2 minor abnormalities
- 🔴 High risk: Multiple abnormalities or severe abnormalities
A-Share Specific Analysis (A股特色分析)
Policy sensitivity
Provide policy-related reminders based on industry classification:
- Real estate: Housing is for living, not for speculation policy
- New energy: Changes in subsidy policies
- Pharmaceuticals: Impact of centralized procurement policies
- Internet: Antitrust, data security
Shareholder structure analysis
- Type of controlling shareholder (state-owned/private/foreign)
- Equity concentration
- Recent increases or decreases in holdings
- Pledge ratio
Output Format
JSON output format
All scripts output in JSON format for subsequent processing:
{
"code": "600519",
"name": "贵州茅台",
"analysis_date": "2025-01-25",
"level": "standard",
"summary": {
"score": 85,
"conclusion": "低估",
"recommendation": "建议关注"
},
"financials": { ... },
"valuation": { ... },
"risks": [ ... ]
}
Markdown report
Generate a structured Chinese Markdown report, refer to templates/analysis_report.md。
Error Handling
Network error
If akshare data retrieval fails, prompt the user:
- Check network connection
- Retry later (may be interface rate limiting)
- Try changing the data source
Invalid stock code
Prompt the user to check whether the stock code is correct, and provide possible matching suggestions.
Incomplete data
For newly listed stocks or cases with incomplete financial data, explain the data limitations and conduct analysis based on available data.
Best Practices
- Data timeliness: Financial data is based on the latest quarterly/annual report, price data is the closing price of the day
- Investment advice: All analysis is for reference only and does not constitute investment advice
- Risk warning: Always include risk warnings, especially the results of financial anomaly detection
- Comparative analysis: When analyzing a single stock, automatically include industry average comparison
Important Notes
- All analysis is based on public financial data and does not involve any inside information
- The parameter assumptions of the valuation model have a significant impact on the results and must be explained to the user
- The A-share market is greatly affected by policies, and quantitative analysis needs to be combined with qualitative judgment