FinanceMCP-Alpha
Calculates WorldQuant 101 Alpha factors using real-time Chinese stock market data from Tushare.
README
📊 FinanceMCP-Alpha
A powerful Model Context Protocol (MCP) server for calculating WorldQuant 101 Alpha factors using real-time Chinese stock market data from Tushare. Built with TypeScript and designed for quantitative trading analysis and research.
✨ Features
- 🎯 7 Alpha Factors: Alpha3, Alpha13, Alpha15, Alpha16, Alpha44, Alpha50, Alpha55
- 📈 Real-time Data: Integrates with Tushare API for A-share market data
- 🔒 Secure: Token-based authentication via HTTP headers
- 🚀 Streamable HTTP: Modern MCP protocol support
- 📊 Comprehensive Analysis: Detailed factor statistics and trading signals
- 🎨 Beautiful Reports: Markdown-formatted analysis with visual indicators
🏗️ Architecture
src/
├── index.ts # MCP server entry point
├── tools/
│ └── calculate_alpha.ts # Alpha calculation tool
├── alphas/
│ └── index.ts # Alpha factor implementations
└── utils/
├── tushare.ts # Tushare API client
└── operators.ts # Mathematical operators
📦 Installation
Option 1: Use as npm package
npm install finance-mcp-alpha
Option 2: Clone and build locally
git clone https://github.com/guangxiangdebizi/FinanceMCP-Alpha.git
cd FinanceMCP-Alpha
npm install
npm run build
🚀 Quick Start
1. Start the Server
npm start
The server will start on http://localhost:3000 by default.
🚀 FinanceMCP-Alpha Server Started
=====================================
Transport: Streamable HTTP
MCP Endpoint: http://localhost:3000/mcp
Health Check: http://localhost:3000/health
=====================================
2. Configure MCP Client
Add to your MCP client configuration (e.g., mcp.json or Claude Desktop config):
{
"mcpServers": {
"finance-alpha": {
"type": "streamableHttp",
"url": "http://localhost:3000/mcp",
"headers": {
"X-Tushare-Token": "YOUR_TUSHARE_TOKEN_HERE"
},
"timeout": 600
}
}
}
⚠️ Important: Get your free Tushare token at https://tushare.pro/register
3. Use the Tool
Once connected, you can use the calculate_alpha tool:
Calculate Alpha factors for stock 000001.SZ from 20240101 to 20241011
with factors Alpha3, Alpha13, Alpha50
📖 Alpha Factors
This package implements the following WorldQuant 101 Alpha factors:
Alpha#3
Formula: (-1 * correlation(rank(open), rank(volume), 10))
Use Case: Measures negative correlation between opening price ranks and volume ranks. High values suggest contrarian price-volume behavior.
Alpha#13
Formula: (-1 * rank(covariance(rank(close), rank(volume), 5)))
Use Case: Captures ranked covariance between closing prices and volume. Identifies price-volume anomalies.
Alpha#15
Formula: (-1 * sum(rank(correlation(rank(high), rank(volume), 3)), 3))
Use Case: Sum of ranked correlations between high prices and volume. Detects short-term momentum shifts.
Alpha#16
Formula: (-1 * rank(covariance(rank(high), rank(volume), 5)))
Use Case: Similar to Alpha13 but focuses on intraday volatility patterns using high prices.
Alpha#44
Formula: (-1 * correlation(high, rank(volume), 5))
Use Case: Negative correlation between high prices and volume ranks. Identifies volume divergence from price peaks.
Alpha#50
Formula: (-1 * ts_max(rank(correlation(rank(volume), rank(vwap), 5)), 5))
Use Case: Maximum ranked correlation between volume and VWAP. Measures volume-price efficiency.
Alpha#55
Formula: (-1 * correlation(rank((close - ts_min(low, 12)) / (ts_max(high, 12) - ts_min(low, 12))), rank(volume), 6))
Use Case: Correlation between normalized price position and volume. Captures momentum-volume relationships.
🔧 Tool Parameters
calculate_alpha
| Parameter | Type | Required | Description |
|---|---|---|---|
stock_code |
string | ✅ | Stock code in Tushare format (e.g., 000001.SZ, 600000.SH) |
start_date |
string | ✅ | Start date in YYYYMMDD format (e.g., 20240101) |
end_date |
string | ✅ | End date in YYYYMMDD format (e.g., 20241011) |
factors |
array | ✅ | List of factors: ["Alpha3", "Alpha13", "Alpha15", "Alpha16", "Alpha44", "Alpha50", "Alpha55"] |
Stock Code Format
- Shenzhen Stock Exchange:
XXXXXX.SZ(e.g.,000001.SZ- Ping An Bank) - Shanghai Stock Exchange:
XXXXXX.SH(e.g.,600000.SH- SPD Bank)
📊 Output Format
The tool returns a comprehensive Markdown report including:
- 📈 Factor Summary Table: Current values, percentiles, and signals
- 🔍 Detailed Analysis: Statistical metrics for each factor
- 💡 Trading Signals: Buy/Sell/Hold recommendations based on percentile analysis
- 🎯 Overall Recommendation: Aggregated signal from all factors
Signal Interpretation
| Percentile | Signal | Emoji | Action |
|---|---|---|---|
| ≥ 80% | STRONG BUY | 🟢 | Strong buying opportunity |
| 60-80% | BUY | 🟢 | Moderate buying opportunity |
| 40-60% | HOLD | 🟡 | Neutral, wait for clearer signal |
| 20-40% | SELL | 🔴 | Moderate selling pressure |
| < 20% | STRONG SELL | 🔴 | Strong selling pressure |
🔐 Security Notes
- Never commit your Tushare token to version control
- Store tokens securely in your MCP client configuration
- Use environment variables for server configuration
- Token is passed via HTTP header, not stored in server
🛠️ Development
# Install dependencies
npm install
# Build TypeScript
npm run build
# Run in development mode
npm run dev
# Start production server
npm start
📝 Environment Variables
Create a .env file (optional):
PORT=3000
🧪 Testing
Test the health endpoint:
curl http://localhost:3000/health
Expected response:
{
"status": "healthy",
"transport": "streamable-http",
"activeSessions": 0,
"serverInfo": {
"name": "FinanceMCP-Alpha",
"version": "1.0.0"
}
}
📚 Use Cases
- Quantitative Trading: Integrate alpha factors into your trading strategies
- Research: Analyze factor effectiveness across different stocks and time periods
- Portfolio Management: Use factor signals for position sizing and rebalancing
- Market Analysis: Understand price-volume relationships and market microstructure
- AI-Assisted Trading: Leverage LLMs with real-time factor calculations
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
📄 License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
⚠️ Disclaimer
This software is for educational and research purposes only. Alpha factors are statistical indicators and should not be the sole basis for investment decisions. Past performance does not guarantee future results. Always conduct thorough research and consult with financial professionals before making investment decisions.
👤 Author
Xingyu Chen
- 🌐 GitHub: @guangxiangdebizi
- 💼 LinkedIn: Xingyu Chen
- 📦 npm: @xingyuchen
- 📧 Email: guangxiangdebizi@gmail.com
🙏 Acknowledgments
- WorldQuant: For the Alpha101 factor formulas
- Tushare: For providing comprehensive Chinese stock market data
- Model Context Protocol: For the amazing MCP framework
📖 References
⭐ If you find this project helpful, please consider giving it a star on GitHub!
Happy Trading! 📈
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。