使用说明
Python MCP服务器(市场加密代理)
概述
这个项目是一个最小的、注重生产的项目 主控程序 (市场加密代理)服务器:
- 通过以下方式从主要交易所获取实时行情数据
ccxt. - 提供历史OHLCV查询。
- 公开用于实时流式传输(基于轮询)的SSE端点。
- 包括缓存和强大的错误处理。
- 附带单元和API测试(pytest)。
此存储库旨在作为实习任务提交:它演示了结构化代码、测试覆盖率和最佳实践。
需求
- Python 3.10+
pip安装依赖项。
安装:
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
Project Requirements (Simplified)
1. Health Check
GET http://localhost:8000/health
2. Live Price
GET http://localhost:8000/price?exchange=binance&symbol=BTC/USDT
3. Historical OHLCV
GET http://localhost:8000/history?exchange=binance&symbol=BTC/USDT&timeframe=1m&limit=10
4. Streaming Prices
GET http://localhost:8000/stream/price?exchange=binance&symbol=BTC/USDT&interval=5
Features
- FastAPI-based server
- CCXT for market data
- TTL caching
- Error handling
- Test cases using pytest
Run the server
uvicorn app.main:app --reload