基于时间序列分析的A股形态点预测系统 / Time-based sequence analysis for A-share stock landmark prediction
A-Share Stock Pattern Predictor is a web application that predicts WHEN landmark low/high points will occur using time-based sequence analysis. Unlike traditional technical analysis that focuses on price patterns, this system analyzes mathematical patterns in the timing of landmark points.
-
Multi-layer Landmark Detection: 4-layer progressive filtering system
- Layer 1: ZigZag algorithm for initial pivot detection
- Layer 2: Statistical confirmation (frequency & deviation filters)
- Layer 3: Trend strength filtering
- Layer 4: Time interval validation
-
Pattern Recognition: Identifies arithmetic and geometric patterns in landmark timing
-
Bilingual Interface: Full support for English and Chinese
-
Real-time Analysis: FastAPI backend with responsive frontend
-
Interactive Charts: Chart.js visualization with landmark annotations
Backend:
- Python 3.10+
- FastAPI
- pandas, numpy
- scikit-learn
- matplotlib
Frontend:
- HTML5, JavaScript (Vanilla)
- Bootstrap 5
- Chart.js 4.4.0
- Clone the repository:
git clone https://github.com/yourusername/ashare_predict.git
cd ashare_predict- Create virtual environment:
conda create -n ashare python=3.10
conda activate ashare- Install dependencies:
pip install -r requirements.txt- Prepare stock database:
# 更新股票基本信息数据库
python -m scripts.update_stock_db
# 数据会自动从行情平台获取并缓存到本地SQLite数据库
# 首次运行会建立股票代码列表- Run the application:
cd web
python -m uvicorn app:app --host 0.0.0.0 --port 8000 --reload- Open browser:
http://localhost:8000
- Search Stock: Enter stock code (6 digits), pinyin, or name
- View Prediction: Click "分析" to see pattern prediction
- Detailed Analysis: Click "查看完整分析" for full chart and landmark details
- Adjust Parameters: Use multi-layer filter panel to fine-tune detection
ashare_predict/
├── core/ # Core analysis modules
│ ├── data_loader.py # Data loading and preprocessing
│ ├── zigzag.py # ZigZag algorithm implementation
│ ├── pattern_detector.py # Pattern recognition engine
│ └── multi_layer_detector.py # Multi-layer filtering
├── web/ # Web application
│ ├── app.py # FastAPI application
│ ├── templates/ # HTML templates
│ └── static/ # CSS, JS, images
├── data/ # Data directory
│ ├── stocks.json # Stock info (code/name/pinyin)
│ └── stock_cache.db # Local SQLite cache (auto-generated)
├── scripts/ # Utility scripts
│ └── update_stock_db.py # Update stock database
├── requirements.txt # Python dependencies
└── README.md # This file
The system automatically fetches stock data from:
- Real-time API: Fetches weekly/daily OHLCV data on demand
- Local Cache: SQLite database caches fetched data for performance
- Stock Database:
stocks.jsoncontains basic stock information
GET /- HomepageGET /analysis/{symbol}- Stock analysis pageGET /api/predict?symbol={code}- Get predictionGET /api/analyze?symbol={code}&threshold={val}&include_secondary={bool}- Get full analysisGET /api/stocks/search?q={query}- Search stocksPOST /api/multi-layer-detect- Run multi-layer detection with custom parameters
Optimized parameters based on testing:
- Layer 1 Threshold: 10%
- Layer 2 Min Frequency: 2
- Layer 2 Min Deviation: 20%
- Layer 3 Trend Strength: 0.50
- Layer 4 Same Type Interval: 10 weeks
- Layer 4 Alternating Interval: 4 weeks
This tool is for educational and research purposes only. Past patterns do not guarantee future results. Always do your own research and consult a qualified financial advisor before making investment decisions.
MIT License
Contributions are welcome! Please feel free to submit a Pull Request.
A股形态预测系统是一个基于时间序列分析的Web应用,用于预测关键低点/高点出现的时间。与关注价格形态的传统技术分析不同,本系统分析形态点时机的数学规律。
-
多层地标点检测:4层渐进式过滤系统
- 第1层:ZigZag算法初步检测转折点
- 第2层:统计确认(频率和偏离度过滤)
- 第3层:趋势强度过滤
- 第4层:时间间隔验证
-
模式识别:识别地标点时机中的算术和几何规律
-
双语界面:完整支持中英文
-
实时分析:FastAPI后端,响应式前端
-
交互式图表:Chart.js可视化,带地标点标注
后端:
- Python 3.10+
- FastAPI
- pandas, numpy
- scikit-learn
- matplotlib
前端:
- HTML5, JavaScript (原生)
- Bootstrap 5
- Chart.js 4.4.0
- 克隆仓库:
git clone https://github.com/yourusername/ashare_predict.git
cd ashare_predict- 创建虚拟环境:
conda create -n ashare python=3.10
conda activate ashare- 安装依赖:
pip install -r requirements.txt- 准备股票数据库:
# 更新股票基本信息数据库
python -m scripts.update_stock_db
# 数据会自动从行情平台获取并缓存到本地SQLite数据库
# 首次运行会建立股票代码列表- 运行应用:
cd web
python -m uvicorn app:app --host 0.0.0.0 --port 8000 --reload- 打开浏览器:
http://localhost:8000
系统自动从以下来源获取股票数据:
- 实时API: 按需获取周线/日线OHLCV数据
- 本地缓存: SQLite数据库缓存已获取数据,提高性能
- 股票数据库:
stocks.json包含股票基本信息
- 搜索股票:输入股票代码(6位数字)、拼音或名称
- 查看预测:点击"分析"按钮查看形态预测
- 详细分析:点击"查看完整分析"查看完整图表和地标点详情
- 调整参数:使用多层过滤控制面板微调检测参数
ashare_predict/
├── core/ # 核心分析模块
│ ├── data_loader.py # 数据加载和预处理
│ ├── zigzag.py # ZigZag算法实现
│ ├── pattern_detector.py # 模式识别引擎
│ └── multi_layer_detector.py # 多层过滤系统
├── web/ # Web应用
│ ├── app.py # FastAPI应用
│ ├── templates/ # HTML模板
│ └── static/ # CSS、JS、图片
├── data/ # 数据目录
│ ├── stocks.json # 股票基本信息 (代码/名称/拼音)
│ └── stock_cache.db # 本地SQLite缓存 (自动生成)
├── scripts/ # 辅助脚本
│ └── update_stock_db.py # 更新股票数据库
├── requirements.txt # Python依赖
└── README.md # 本文件
GET /- 首页GET /analysis/{symbol}- 股票分析页面GET /api/predict?symbol={code}- 获取预测GET /api/analyze?symbol={code}&threshold={val}&include_secondary={bool}- 获取完整分析GET /api/stocks/search?q={query}- 搜索股票POST /api/multi-layer-detect- 使用自定义参数运行多层检测
基于测试优化的默认参数:
- 第1层阈值:10%
- 第2层最小频率:2
- 第2层最小偏离:20%
- 第3层趋势强度:0.50
- 第4层同类型间隔:10周
- 第4层交替间隔:4周
本工具仅供教育和研究目的。过去的规律不能保证未来的结果。在做出投资决策前,务必自行研究并咨询合格的专业理财顾问。
MIT License
欢迎贡献!请随时提交 Pull Request。
Developed with ❤️ for A-share market analysis