FinanceMCP-Alpha

FinanceMCP-Alpha

Calculates WorldQuant 101 Alpha factors using real-time Chinese stock market data from Tushare.

Category
Visit Server

README

๐Ÿ“Š FinanceMCP-Alpha

npm version License

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

๐Ÿ™ 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! ๐Ÿ“ˆ

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured