完整的开发环境配置和数据获取设置指南。
- Environment Setup
- API Key Configuration
- MCP Server Setup
- Optional: Ollama Local Model
- Testing Your Setup
- Troubleshooting
There are two supported ways to install FinAI Research Workflow, and they
determine where the pipeline looks for your .env file:
| Installation method | Command | Where to put .env |
|---|---|---|
| PyPI wheel (recommended for users) | pip install finai-research-workflow[extras] |
Your working directory (cwd) |
| Source checkout (for contributors) | git clone ... && pip install -e ".[extras]" |
The repo root (<checkout>/.env) |
The pipeline uses FINAI_PROJECT_ROOT / importlib.metadata / cwd
in that priority order to locate the project root. If you install via PyPI
and run finai-pipeline --topic "..." from a directory other than
where your .env lives, set the environment variable first:
export FINAI_PROJECT_ROOT=/path/to/your/project
finai-pipeline --topic "..."The finai-doctor command (installed with the wheel) will show you
exactly where each key is being read from.
| Requirement | Version | Notes |
|---|---|---|
| Python | 3.11+ (3.12 recommended) | Required |
| pip | Latest | Comes with Python |
| Git | Any recent version | For version control |
# Create conda environment
conda create -n finai python=3.12
conda activate finai
# Install the package and all common optional integrations
# extras includes Tushare, akshare, yfinance, MCP, dashboards, and document processing.
pip install -e ".[extras]" # 推荐方式(支持 entry points)
# 或仅安装依赖:
pip install -e ".[extras]" --no-deps 2>&1 || pip install -e ".[extras]"# Create virtual environment
python3 -m venv .venv
# Activate (macOS/Linux)
source .venv/bin/activate
# Activate (Windows)
# .venv\Scripts\activate
# Install the package and all common optional integrations
pip install -e ".[extras]"python --version # Should show Python 3.11+
pip list | head -20 # Check installed packagesAll API keys are stored in the .env file in the project root. Never commit this file.
# Copy the example file → 创建 .env.local(不被 git 跟踪)
cp .env.example .env.local
# Edit with your actual keys
nano .env.local # or any text editor优先级说明:
.env.local优先级高于.env,系统自动加载。.env可被 git 跟踪,.env.local不会被跟踪。
# 交互式引导 — 根据研究方向推荐配置项
python scripts/setup_wizard.py --guided
# 查看当前配置状态
python scripts/setup_wizard.py --status配置向导会自动:
- 检测当前
.env/.env.local中的已配置项 - 询问你的研究方向(A 股 / 宏观 / 实证论文 / 量化 / 研报)
- 推荐需要配置的 API Key 和 MCP 服务器
- 允许选择性配置(必需 / 推荐 / 可选)
- 保存到
.env.local
| Key | Required | Service | Get Key From |
|---|---|---|---|
DEEPSEEK_API_KEY |
Recommended | DeepSeek LLM (Chinese tasks) | console.deepseek.com |
RELAY_API_KEY |
Optional | GPT/Claude via relay | B.AI, OpenRouter, etc. |
| Key | Required | Service | Get Key From |
|---|---|---|---|
TUSHARE_TOKEN |
Optional | A-share data (full access) | tushare.pro |
EODHD_API_KEY |
Optional | Macro data (yield curve, calendar) | eodhd.com |
FRED_API_KEY |
Optional | US macro (GDP, CPI) | fred.stlouisfed.org |
BRAVE_SEARCH_API_KEY |
Optional | Web search | brave.com/search/api |
# AI Models (required for LLM features)
DEEPSEEK_API_KEY=sk-your-deepseek-key-here
RELAY_API_KEY=your-relay-key-here
# Data Sources (optional)
TUSHARE_TOKEN=your-tushare-token
EODHD_API_KEY=your-eodhd-key
FRED_API_KEY=your-fred-key
# Other Services
BRAVE_SEARCH_API_KEY=your-brave-keyYou only need one AI key to start:
DEEPSEEK_API_KEY— Recommended for Chinese researchRELAY_API_KEY— For English writing (GPT/Claude)
The system will automatically route tasks to the appropriate model.
The system includes 43 MCP servers providing financial data:
| Category | Servers |
|---|---|
| A-shares | user-tushare, user-csmar, user-wind, user-eastmoney-reports, user-eastmoney-fund, user-eastmoney-bond, user-eastmoney-option |
| Macro | user-financial, user-wb-data, user-imf-data, user-oecd-data, user-bea-data, user-fed-data, user-macro-ceic, user-macro-datas, user-macro-stats |
| US Stocks | user-yfinance, user-eodhd, user-sec-edgar |
| Academic | user-arxiv, user-nber-wp, user-openalex, user-context7, user-semantic-scholar, user-chinese-literature |
| Provincial Stats | user-province-stats, user-hubei-stats, user-wuhan-stats |
| Utilities | user-filesystem-mcp, user-latex-mcp, user-e2b-mcp, user-pandas-mcp, user-playwright-mcp |
Most servers require no API key. See docs/tutorials/04-mcp-marketplace.md for the complete catalog.
- Open Cursor Settings → MCP
- Add new MCP server for each you want to use
- Or use the auto-registration script:
python scripts/register_mcp_servers.py --allAdd to Cursor MCP settings:
{
"mcpServers": {
"user-tushare": {
"command": "python",
"args": ["mcp_servers/user_tushare/server.py"]
},
"user-financial": {
"command": "python",
"args": ["mcp_servers/user_financial/server.py"]
}
}
}# Tushare is included in the extras dependency group
pip install -e ".[extras]"
# To install only the client instead: pip install "tushare>=1.4.0,<2.0"
# Configure token
echo "TUSHARE_TOKEN=your-tushare-token" >> .env# No additional setup needed
# Uses World Bank API (free) + akshare (free)# Install
pip install eodhd
# Configure key
echo "EODHD_API_KEY=your-eodhd-api-key" >> .envFor offline usage or cost savings, set up Ollama with local models.
# macOS/Linux
curl -fsSL https://ollama.com/install.sh | sh
# Or via Homebrew (macOS)
brew install ollamaollama serve# Chinese-optimized model
ollama pull qwen2.5:7b
# English model
ollama pull llama3.2:3bOLLAMA_BASE_URL=http://localhost:11434/v1
OLLAMA_MODEL=qwen2.5:7bAdd Ollama to the model pool in scripts/ai_router.py:
OLLAMA_CONFIG = {
"base_url": os.getenv("OLLAMA_BASE_URL", "http://localhost:11434/v1"),
"model": os.getenv("OLLAMA_MODEL", "qwen2.5:7b"),
}cd /path/to/论文-研报工作流
python -m pytest tests/ -v --tb=short# Test LLM connectivity
python scripts/agent.py --test
# Test MCP registry
python scripts/core/mcp_tool_market.py --report
# Test data fetching
# 测试数据获取(通过 Python API)
from scripts.research_framework.data_fetcher import DataFetcher
fetcher = DataFetcher()
# Test literature search (use AI Agent or research_framework pipeline)
python scripts/research_framework/pipeline.py --topic "carbon trading innovation"# Generate a test paper
python scripts/agent.py --goal "测试:AI在金融领域的应用"streamlit run scripts/dashboard.py --server.port 8050
# Open http://localhost:8050 in browserModuleNotFoundError: No module named 'xxx'
Solution: Install missing package
pip install xxxKeyError: 'DEEPSEEK_API_KEY'
Solution: Ensure .env file exists and contains the key
cat .env | grep DEEPSEEK_API_KEYMCP tool unavailable
Solution:
- Check Cursor MCP settings
- Restart Cursor
- Or use script fallback:
from scripts.research_framework.data_fetcher import DataFetcher
fetcher = DataFetcher()
data = fetcher.get_stock_data("000001.SZ")! LaTeX Error: File 'xxx.sty' not found.
Solution: Install missing LaTeX packages
# macOS
brew install --cask mactex
# Ubuntu/Debian
sudo apt install texlive-latex-extraConnectionError: Failed to fetch data
Solutions:
- Check internet connection
- Verify API key is valid
- Try alternative data source
- Use cached/fallback data
pip install fails with permission error
Solution: Use virtual environment
python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[extras]"- Check existing issues: GitHub Issues
- Run with verbose logging:
python scripts/agent.py --goal "xxx" --verbose- Check logs in
logs/directory
# Full dev setup
pip install -e ".[dev]"
# Run tests
make test
# Lint code
make lint
# Health check
make health| File | Purpose |
|---|---|
.env |
API keys (not committed) |
.env.example |
Template for .env |
config/llm_config.json |
Model configuration |
config/project_config.json |
Project settings |
output/ |
Output directory |
data/ |
Input data directory |
logs/ |
Log files |