← 返回
数据分析 Key 中文

A-Share Review and Analyse

A-share market automated review and analysis system, generating daily market insights with Gemini AI, supporting publishing to Hugo blog and WeChat Official...
A股市场自动化分析系统,使用Gemini AI生成每日市场洞察,支持发布至Hugo博客和微信公众号
donvink
数据分析 clawhub v1.0.1 2 版本 100000 Key: 需要
★ 1
Stars
📥 567
下载
💾 43
安装
2
版本
#latest

概述

🚀 Stock Review

👉 Live Demo Blog

GitHub: 👉 https://github.com/Donvink/stock-review

Language

Match user's language: Respond in the same language the user uses. If the user writes in Chinese, respond in Chinese. If the user writes in English, respond in English.

Script Directory

Agent Execution: Determine this SKILL.md directory as {baseDir}, then use {baseDir}/scripts/.py. Ensure Python 3.10+ is installed and dependencies are configured.

ScriptPurpose
------------
scripts/fetch_data.pyFetch A-share market data (indices, stocks, sectors, etc.)
scripts/analyze.pyGemini AI analysis of market data
scripts/post_to_hugo.pyPublish to Hugo blog
scripts/post_to_wechat.pyPublish to WeChat Official Account
scripts/main.pyMain execution script, coordinates the entire workflow

Configuration Preferences

  1. Check if config.yaml exists: {baseDir}/stock-review/config.yaml
  1. Check if .env file exists and is configured with GEMINI_API_KEY, WECHAT_APP_ID, WECHAT_APP_SECRET: {baseDir}/stock-review/.env

config.yaml supports: Default publishing platforms | Whether to skip AI analysis by default | Default data backtracking days | Default request delay | Default retry count | API key configuration

.env supports: API key configuration

Minimum supported keys (case-insensitive, accepts 1/0 or true/false):

KeyDefaultDescription
--------------------
datenullDate in YYYYMMDD format
force_refreshfalseWhether to force refresh already fetched data
skip_ai_analysisfalseWhether to skip AI analysis
platforms["hugo"]Default publishing platforms (['hugo']/['wechat']/['hugo', 'wechat'])
data_dirnullDirectory for data storage
max_retries3Default retry count
request_delay0.5Default request delay (seconds)
backtrack_days0Default data backtracking days
typegeminiModel type
model_namegemini-2.5-flashModel name

Recommended config.yaml example:

# default configuration for stock review skill
review:
  markets:                          # can include "shanghai", "shenzhen", "hongkong"
    - "shanghai"
    - "shenzhen"
    - "hongkong"
  default_period: "daily"           # can be "daily", "weekly", "monthly"
  date: null                        # can be specific date "YYYYMMDD" like "20260101" or null for today
  force_refresh: false              # whether to force refresh data even if cached data is available
  skip_ai_analysis: false           # whether to skip AI analysis and just return raw data
  platforms: ["hugo"]               # platforms to publish the report, e.g. ['hugo', 'wechat'] or ['hugo'] or ['wechat']

paths:
  data_dir: null                    # directory to store fetched data and cache, null means current project directory

parameters:
  max_retries: 3
  request_delay: 0.5
  backtrack_days: 0
  
models:
  type: "gemini"
  model_name: "gemini-2.5-flash"

.env example:

# Gemini API Key
GEMINI_API_KEY="your_gemini_api_key"

# WeChat Official Account Configuration
WECHAT_APP_ID="your_wechat_app_id"
WECHAT_APP_SECRET="your_wechat_app_secret"

How to Get a Gemini API Key:

  1. Visit the official portal: Go to https://aistudio.google.com/ and log in with your Google account.
  1. Create an API Key: Click "Get API key" in the left sidebar, click "Create API key in new project", and copy the generated string (please save it securely—you won't be able to see the full key again after closing the window).
  1. Important Notes:

Free Tier: Provides free quota but with request frequency limits (RPM/RPD).

Data Privacy: Free tier data may be used for model improvement. For commercially sensitive data, consider enabling the paid mode.

How to Get WeChat Official Account Credentials:

  1. Visit https://developers.weixin.qq.com/platform/
  2. Navigate: My Business → Official Account → Development Keys
  3. Add a development key, copy the AppID and AppSecret
  4. Add the IP address of your machine to the whitelist

Environment Check

Before first use, install the dependencies.

pip install -r {baseDir}/requirements.txt

Check items: Python version | Dependencies | API keys | Network connection | Directory permissions

If any check fails, provide fix guidance:

Check ItemFix Method
-----------------
Python versionInstall Python 3.10+: brew install python@3.10 (macOS) or apt install python3.10 (Linux)
DependenciesRun pip install -r {baseDir}/requirements.txt
Gemini API keyConfigure in .env or via environment variables
WeChat Official Account credentialsConfigure in .env or via environment variables
Network connectionCheck network proxy settings
Directory permissionsEnsure data/ and content/posts/ directories are writable

Workflow Overview

Copy this checklist and check items as you progress:

Review Analysis Progress:
- [ ] Step 0: Load preferences (config.yaml, .env), determine execution parameters
- [ ] Step 1: Fetch market data
- [ ] Step 2: Run AI analysis (optional)
- [ ] Step 3: Generate report
- [ ] Step 4: Publish to platforms
- [ ] Step 5: Report complete

Step 0: Load Preferences

Check and load config.yaml settings (see Configuration Preferences section above), parse and store default values for subsequent steps.

Step 1: Fetch Market Data

Fetch the following data for the specified date:

Data TypeSourceFile
----------------------
Index datastock_zh_index_spot_sinadata/{date}/index_{date}.csv
Limit-up poolstock_zt_pool_emdata/{date}/zt_pool_{date}.csv
Limit-down poolstock_zt_pool_dtgc_emdata/{date}/dt_pool_{date}.csv
Failed limit-up poolstock_zt_pool_zbgc_emdata/{date}/zb_pool_{date}.csv
Full market datastock_zh_a_spot_emdata/{date}/A_stock_{date}.csv
Top 20 by turnoverCalculateddata/{date}/top_amount_stocks_{date}.csv
Concept sectorsstock_board_concept_name_emdata/{date}/concept_summary_{date}.csv
Top traders liststock_lhb_detail_daily_sinadata/{date}/lhb_{date}.csv
WatchlistCalculateddata/{date}/watchlist*_{date}.csv

Retry Mechanism:

  • Default 3 retries
  • 0.5 second request interval
  • Automatic fallback to alternative interfaces on failure

Step 2: Run AI Analysis

CRITICAL: Run AI analysis only if:

  • --skip-ai is not set
  • GEMINI_API_KEY is configured (via config.yaml or environment variables)

AI Analysis Prompt:

prompt = f"""
Role Setting: You are a seasoned A-share strategy analyst with 20 years of experience...

Task Description: Conduct a multi-dimensional review based on the [daily review data]:
1. 🚩 Market Sentiment Diagnosis
2. 💰 Core Themes and Capital Flow
3. 🪜 Consecutive Limit-up Gradient and Space Game
4. ⚡ Key Stocks with Abnormal Movements Analysis
5. 🧭 Next Trading Day Strategy Recommendations

📊 Daily Review Data:
{market_summary}
"""

Output: data/{date}/ai_analysis_{date}.md

Step 3: Generate Reports

Market Summary Report:

  • File: data/{date}/market_summary_{date}.md
  • Format: Markdown
  • Content: Tabular summary of all data

AI Analysis Report (if run):

  • File: data/{date}/ai_analysis_{date}.md
  • Format: Markdown
  • Content: In-depth analysis generated by Gemini

Step 4: Publish to Platforms

Hugo Blog Publishing:

python3 {baseDir}/scripts/post_to_hugo.py --market-summary <file> --ai-analysis <file> --date <date>

Output: content/posts/stock-analysis-{YYYY-MM-DD}.md

WeChat Official Account Publishing (requires API credentials):

python3 {baseDir}/scripts/post_to_wechat.py --market-summary-file <file> --ai-analysis-file <file> --date <date> --cover-file <file> --title <title>

WeChat Official Account API Request Rules:

  • Endpoint: POST https://api.weixin.qq.com/cgi-bin/draft/add?access_token=ACCESS_TOKEN
  • article_type: news
  • Requires thumb_media_id (cover image)
  • Comment settings: need_open_comment=1, only_fans_can_comment=0

Step 5: Completion Report

Success Report:

✅ A-share Review Analysis Complete!

Date: 2026-03-04
Data: data/20260304/ (12 files)
AI Analysis: ✓ Generated (Gemini 2.0 Flash)

Published Platforms:
→ Hugo Blog: content/posts/stock-analysis-2026-03-04.md
→ WeChat Official Account: Draft ID: abc123def456

Market Snapshot:
• Shanghai Composite: 3350.52 (+1.02%)
• Turnover: 1.95 trillion
• Advance/Decline: 2857 / 2058
• Limit-up/Limit-down: 78 / 3

View Blog: https://donvink.github.io/stock-review/

Error Report:

❌ Review Analysis Failed

Error: Unable to fetch limit-up pool data
Suggestions: 
1. Check network connection
2. Try --force parameter to force refresh
3. Use --date to specify another date

Detailed Feature Description

Data Fetching Module

FunctionPurposeRetryCache
------------------------
stock_summary()Fetch index data
stock_zt_dt_pool()Fetch limit-up/down data
fetch_all_stock_data()Fetch full market data✓ (3 times)
get_top_amount_stocks()Fetch top 20 by turnover
get_concept_summary()Fetch concept sectors
get_lhb_data()Fetch top traders list

AI Analysis Module

Model: gemini-2.5-flash

Analysis Dimensions:

  1. Market Sentiment Diagnosis - Advance/decline ratio, limit-up/down comparison, turnover
  2. Core Theme Tracking - Capital flow, hot sectors
  3. Consecutive Limit-up Gradient Analysis - Space board height, limit-up structure
  4. Abnormal Movement Stock Analysis - High turnover, top traders list
  5. Next Day Strategy Recommendations - Data-based trading suggestions

Publishing Module

PlatformMethodRequirementsOutput
------------------------
Hugo BlogFile writeNoneMarkdown file
WeChat Official AccountAPIAppID/SecretDraft ID

Feature Comparison

FeatureData FetchingAI AnalysisHugo PublishingWeChat Publishing
--------------------------------------------
Auto-fetch latest date---
Data caching---
Retry mechanism---
Multi-source backup---
Format values (hundreds millions/ten thousands)---
Filter ST stocks---
Watchlist construction---
Market sentiment diagnosis---
Limit-up gradient analysis---
Strategy recommendations---
Markdown format-
Timezone handling---
Hugo frontmatter---
WeChat HTML conversion---
Comment settings---

Prerequisites

Required:

  • Python 3.10+
  • Dependencies: pip install -r requirements.txt
  • Gemini API key (for AI analysis)

Optional:

  • WeChat Official Account AppID and AppSecret (for WeChat publishing)
  • Hugo blog environment (for blog publishing)

Configuration Locations (priority order):

  1. CLI parameters
  2. config.yaml, .env (project-level/user-level)
  3. Environment variables
  4. Default values

Troubleshooting

IssueSolution
----------------
Unable to fetch dataCheck network, specify another date
Gemini API errorCheck if API key is valid, quota is sufficient
Limit-up pool data emptyPossibly non-trading day, try backtracking to another date
WeChat publishing failedCheck AppID/Secret, confirm IP is whitelisted
Chinese character encoding issuesEnsure file encoding is UTF-8
Data format errorCheck CSV files, ensure code column isn't converted to numbers
Timeout errorIncrease request_delay or max_retries
Insufficient memoryReduce data volume or process in batches

Extension Support

Customize via config.yaml. See the Configuration Preferences section for supported options.

Related References

TopicReference
------------
AkShare Documentationhttps://akshare.akfamily.xyz/index.html
Gemini APIhttps://aistudio.google.com/
WeChat Official Account APIhttps://developers.weixin.qq.com/platform
Hugo Documentationhttps://gohugo.io/

Version History

VersionDateChanges
------------------
1.0.02026-03-11Initial version

版本历史

共 2 个版本

  • v1.0.1 当前
    2026-05-01 11:34 安全 安全
  • v1.0.0
    2026-03-19 15:22 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

data-analysis

Stock Analysis

udiedrichsen
{"answer":"基于雅虎财经数据,分析股票与加密货币。支持投资组合管理、自选股预警、股息分析、8维评分、热门趋势扫描及传闻/早期信号探测。适用于股票分析、持仓追踪、财报异动、加密监控、热门股追踪或提前发掘非主流传闻。"}
★ 270 📥 56,914
data-analysis

Excel / XLSX

ivangdavila
创建、检查和编辑 Microsoft Excel 工作簿及 XLSX 文件,支持可靠的公式、日期、类型、格式、重算及模板保留功能。
★ 367 📥 140,150
data-analysis

A股量化 AkShare

mbpz
A股量化数据分析工具,基于AkShare库获取A股行情、财务数据、板块信息等。用于回答关于A股股票查询、行情数据、财务分析、选股等问题。
★ 164 📥 59,800