A Python-based service providing stock and cryptocurrency market data through both RESTful API and MCP (Model Context Protocol).
- 📈 Stock Data: Real-time and historical stock market data
- 💰 Cryptocurrency Data: Real-time and historical crypto market data
- 🔌 Dual Protocol Support:
- RESTful API (FastAPI)
- MCP Server (FastMCP) for AI integration
- Clone the repository:
git clone <repository-url>
cd trading-data- Create virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Configure environment:
cp .env.example .env
# Edit .env with your configurationpython main.py --mode apiThe API will be available at http://localhost:8000
API Documentation: http://localhost:8000/docs
python main.py --mode mcpThe MCP server will start at: http://localhost:8001
- MCP Endpoint:
http://localhost:8001/mcp - Transport: Streamable HTTP
GET /api/v1/stocks/{symbol}- Get current stock dataGET /api/v1/stocks/{symbol}/history- Get historical stock dataGET /api/v1/stocks/{symbol}/quote- Get stock quote
GET /api/v1/crypto/{symbol}- Get current crypto dataGET /api/v1/crypto/{symbol}/history- Get historical crypto dataGET /api/v1/crypto/list- List available cryptocurrencies
The MCP server (built with FastMCP) provides the following tools via HTTP Streamable transport:
get_stock_data- Retrieve stock market dataget_crypto_data- Retrieve cryptocurrency dataget_historical_data- Get historical price datasearch_symbols- Search for stock/crypto symbols
Connection:
- Transport: Streamable HTTP
- URL:
http://localhost:8001/mcp/v1 - Protocol: MCP over Streamable HTTP
trading-data/
├── api/ # RESTful API implementation
│ ├── routers/ # API route handlers
│ └── app.py # FastAPI application
├── mcp_server/ # MCP server implementation
│ └── server.py # MCP server
├── models/ # Data models
├── services/ # Data provider services
├── config/ # Configuration
└── main.py # Entry point
MIT License