Token导航 LogoToken导航TokenDH.com
Trade Graph logo
金融服务stdio官方级别未说明来源级核验

Trade Graph

MCP Server

一个基于多代理架构的智能金融分析系统,提供实时新闻分析、财务报告解析、技术指标计算和投资组合优化建议。

工具数

0

提示词数

0

GitHub Stars

2

资源数

0
金融数据PythonAI代理AI分析

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

ApexAILabs

提供方

ApexAILabs

最后核验

2026/5/17 20:20

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

pip install -e .

详细介绍

TradeGraph财务顾问

一个复杂的多代理财务分析系统,使用 LangGraph, DDGS,以及 Crawl4AI 基于实时财经新闻和全面的公司分析,提供智能交易建议。

🚀 特性

  • 多代理架构:新闻分析、财务数据处理和报告分析的协调代理
  • SEC备案分析:使用AI对10-K和10-Q报告进行深入分析
  • 技术分析:综合技术指标和图表模式识别
  • 情感分析:基于人工智能的新闻和社交媒体情绪分析
  • WebSocket新闻频道:用于一级财经新闻、开放机构和实时定价的专用多流WebSockets
  • 投资组合优化:智能投资组合构建与风险管理
  • 交易建议:带信心评分的买入/卖出/持有建议
  • 风险评估:多因素风险分析和头寸规模

📋 需求

  • Python 3.10+
  • OpenAI API密钥
  • 可选:用于增强财务数据的Alpha Vantage API密钥

🛠️ 安装

快速安装

# Clone the repository
git clone https://github.com/Mehranmzn/TradeGraph.git
cd financial-advisor

# Install the package
pip install -e .

# Or install from PyPI (when published)
pip install tradegraph-financial-advisor

开发安装

# Clone and install in development mode
git clone https://github.com/Mehranmzn/TradeGraph.git
cd financial-advisor

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\\Scripts\\activate

# Install with development dependencies
pip install -e ".[dev]"

⚙️ 配置

环境变量

创建 .env 文件基于 .env.example:

cp .env.example .env

所需的环境变量:

OPENAI_API_KEY=your_openai_api_key_here
FINNHUB_API_KEY=your_finnhub_api_key_here
# Optional but recommended
ALPHA_VANTAGE_API_KEY=your_alpha_vantage_api_key_here
FINANCIAL_DATA_API_KEY=your_financial_data_api_key_here

# Configuration
LOG_LEVEL=INFO
MAX_CONCURRENT_AGENTS=5
ANALYSIS_TIMEOUT_SECONDS=30
NEWS_SOURCES=bloomberg,reuters,yahoo-finance,marketwatch,cnbc
DEFAULT_PORTFOLIO_SIZE=100000

🎯 快速开始

命令行用法

# Basic analysis
uv run tradegraph AAPL MSFT GOOGL

# Comprehensive analysis with custom parameters
uv run tradegraph AAPL MSFT GOOGL \
  --portfolio-size 250000 \
  --risk-tolerance aggressive \
  --time-horizon long_term \
  --analysis-type comprehensive

# Quick analysis
uv run tradegraph TSLA NVDA --analysis-type quick

# Generate alerts only
uv run tradegraph AAPL --alerts-only

# JSON output
uv run tradegraph AAPL MSFT --output-format json > analysis.json

实时WebSocket通道

该存储库现在附带了一个FastAPI服务,该服务公开了三个专用的WebSocket通道:

  1. top_market_crypto –路透社、CNBC、《华尔街日报》、MarketWatch和CoinDesk头条新闻
  2. open_source_agencies –《卫报》、英国广播公司、半岛电视台、美国国家公共电台和《金融快报》(均免费/开放获取)
  3. live_price_stream –Finnhub(股票)+币安(加密货币)价格快照,显示去年/月/日/小时的趋势

启动通道服务器 uv 并从任何WebSocket客户端订阅:

uv run uvicorn tradegraph_financial_advisor.server.channel_server:app --reload

订阅示例(JavaScript代码段):

const socket = new WebSocket('ws://127.0.0.1:8000/ws/top_market_crypto?symbols=AAPL,MSFT,BTC-USD');
socket.onmessage = (event) => {
  console.log(JSON.parse(event.data));
};

PDF财务报告

金融代理现在可以将所有三个渠道浓缩成一个PDF,涵盖新闻背景、买入/持有/卖出指导、风险组合和多期价格趋势。趋势快照仅限于月/周/日/小时窗口,因此报告明确反映了本月迄今的势头。

uv run tradegraph AAPL BTC-USD --analysis-type comprehensive --channel-report \
  --pdf-path results/aapl_crypto_multichannel.pdf

Python API用法

import asyncio
from tradegraph_financial_advisor import FinancialAdvisor

async def main():
    advisor = FinancialAdvisor()

    # Comprehensive analysis
    results = await advisor.analyze_portfolio(
        symbols=["AAPL", "MSFT", "GOOGL"],
        portfolio_size=100000,
        risk_tolerance="medium",
        time_horizon="medium_term",
        include_reports=True
    )

    # Print results
    advisor.print_recommendations(results)

    # Quick analysis
    quick_results = await advisor.quick_analysis(
        symbols=["TSLA", "NVDA"],
        analysis_type="standard"
    )

    # Generate alerts
    alerts = await advisor.get_stock_alerts(["AAPL", "MSFT"])

    return results

# Run the analysis
results = asyncio.run(main())

高级用法

from tradegraph_financial_advisor.workflows import FinancialAnalysisWorkflow
from tradegraph_financial_advisor.agents import (
    NewsReaderAgent,
    FinancialAnalysisAgent,
    ReportAnalysisAgent
)

async def advanced_analysis():
    # Use individual agents
    news_agent = NewsReaderAgent()
    await news_agent.start()

    news_data = await news_agent.execute({
        "symbols": ["AAPL"],
        "timeframe_hours": 24,
        "max_articles": 50
    })

    await news_agent.stop()

    # Use the full workflow
    workflow = FinancialAnalysisWorkflow()
    portfolio_rec = await workflow.analyze_portfolio(
        symbols=["AAPL", "MSFT"],
        portfolio_size=500000,
        risk_tolerance="aggressive"
    )

    return portfolio_rec

📊 输出示例

控制台输出

================================================================================
TRADEGRAPH FINANCIAL ADVISOR - ANALYSIS RESULTS
================================================================================

Analysis Date: 2024-12-20T15:30:00
Symbols Analyzed: AAPL, MSFT, GOOGL
Portfolio Size: $100,000.00
Risk Tolerance: medium

📊 PORTFOLIO RECOMMENDATION
Overall Confidence: 75.2%
Diversification Score: 80.0%
Risk Level: medium

📈 INDIVIDUAL RECOMMENDATIONS (3 stocks):
------------------------------------------------------------

AAPL: BUY (Confidence: 78.5%)
  Current: $195.89 | Target: $225.00
  Allocation: 8.5% | Risk: medium
  Key Factors: Strong iPhone 15 sales, Services growth

MSFT: STRONG_BUY (Confidence: 85.2%)
  Current: $374.50 | Target: $420.00
  Allocation: 12.0% | Risk: low
  Key Factors: Azure growth, AI integration

GOOGL: HOLD (Confidence: 65.0%)
  Current: $140.25 | Target: $150.00
  Allocation: 5.5% | Risk: medium
  Key Factors: Search dominance, Cloud recovery

JSON输出结构

{
  "analysis_summary": {
    "symbols_analyzed": ["AAPL", "MSFT"],
    "portfolio_size": 100000,
    "risk_tolerance": "medium",
    "analysis_timestamp": "2024-12-20T15:30:00"
  },
  "portfolio_recommendation": {
    "recommendations": [
      {
        "symbol": "AAPL",
        "recommendation": "buy",
        "confidence_score": 0.785,
        "target_price": 225.00,
        "current_price": 195.89,
        "recommended_allocation": 0.085,
        "risk_level": "medium",
        "key_factors": ["Strong iPhone 15 sales", "Services growth"],
        "analyst_notes": "Strong fundamentals with growth catalysts"
      }
    ],
    "total_confidence": 0.752,
    "diversification_score": 0.80,
    "overall_risk_level": "medium"
  },
  "detailed_reports": {
    "AAPL": {
      "financial_health_score": 8.5,
      "executive_summary": "Apple maintains strong financial position...",
      "key_metrics": {...},
      "risk_factors": [...],
      "growth_prospects": [...]
    }
  }
}

🏗️ 建筑

多代理系统

┌─────────────────┐    ┌──────────────────┐    ┌─────────────────┐
│   News Reader   │    │ Financial Agent  │    │ Report Analyzer │
│     Agent       │    │                  │    │     Agent       │
├─────────────────┤    ├──────────────────┤    ├─────────────────┤
│ • Web scraping  │    │ • Market data    │    │ • SEC filings   │
│ • News analysis │    │ • Technical      │    │ • 10-K/10-Q     │
│ • Sentiment     │    │   indicators     │    │ • AI analysis   │
└─────────────────┘    └──────────────────┘    └─────────────────┘
         │                       │                       │
         └───────────────────────┼───────────────────────┘
                                 │
                    ┌─────────────────────┐
                    │   LangGraph        │
                    │   Workflow         │
                    │   Coordinator      │
                    └─────────────────────┘
                                 │
                    ┌─────────────────────┐
                    │  Recommendation    │
                    │     Engine         │
                    └─────────────────────┘

技术栈

  • LangGraph:工作流编排和代理协调
  • OpenAI GPT-4:自然语言处理和分析
  • Finnhub (股票)和 币安 (加密货币)用于实时/历史定价
  • 熊猫/numpy:数据处理和分析
  • 意图tp:异步HTTP请求
  • 皮丹提克:数据验证和序列化

📈 支持的分析类型

1.快速分析

  • 基本市场数据
  • 简单的新闻情绪
  • 快速推荐
  • 执行时间约为30秒

2.标准分析

  • 全面的市场数据
  • 技术指标
  • 新闻分析
  • 基本投资组合优化
  • 执行时间约为2-3分钟

3.综合分析

  • 一切都在标准
  • SEC文件分析
  • 深入的基本面分析
  • 高级投资组合优化
  • 风险相关性分析
  • ~5-10分钟执行时间

🔧 定制

添加自定义代理

from tradegraph_financial_advisor.agents import BaseAgent

class CustomAnalysisAgent(BaseAgent):
    def __init__(self, **kwargs):
        super().__init__(
            name="CustomAnalysisAgent",
            description="Custom analysis functionality",
            **kwargs
        )

    async def execute(self, input_data):
        # Your custom analysis logic
        return {"analysis_result": "custom_data"}

自定义工作流

from langgraph.graph import StateGraph
from tradegraph_financial_advisor.workflows import AnalysisState

def create_custom_workflow():
    workflow = StateGraph(AnalysisState)

    # Add your custom nodes
    workflow.add_node("custom_analysis", custom_analysis_node)

    # Define workflow
    workflow.set_entry_point("custom_analysis")
    workflow.add_edge("custom_analysis", END)

    return workflow.compile()

🧪 测试

# Run all tests
pytest

# Run with coverage
pytest --cov=tradegraph_financial_advisor

# Run specific test categories
pytest tests/test_agents.py
pytest tests/test_workflows.py

📝 发展

代码质量

# Format code
black src/
isort src/

# Lint code
flake8 src/

# Type checking
mypy src/

预提交钩子

# Install pre-commit hooks
pre-commit install

# Run hooks manually
pre-commit run --all-files

🚨 重要说明

速率限制

  • OpenAI API:监控使用情况以避免速率限制
  • 金融API:大多数都有每日/每月限额

数据准确性

  • 市场数据可能存在延迟(通常为15-20分钟)
  • 新闻情绪是人工智能生成的,应该经过验证
  • SEC文件分析是自动化的,可能会遗漏细微差别
  • 在做出投资决策之前,一定要进行自己的研究

法律免责声明

此软件仅用于教育和研究目的。它不构成财务建议。在做出投资决策之前,始终咨询合格的财务顾问。

🤝 贡献

  1. 分叉存储库
  2. 创建要素分支(git checkout -b feature/amazing-feature)
  3. 提交您的更改(git commit -m 'Add amazing feature')
  4. 推到分支(git push origin feature/amazing-feature)
  5. 打开拉取请求

📄 许可证

此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。

🆘 支持

🙏 致谢

  • LangGraph 优秀多智能体框架团队
  • 开放人工智能 强大的语言模型
  • 金融数据提供商 市场数据访问

______________________________________________________________________

⚠️ 投资免责声明:该工具根据可用数据和人工智能模型提供分析和建议。它不能代替专业的财务建议。在做出投资决策之前,一定要做自己的研究,并考虑咨询财务顾问。过去的表现并不能保证未来的结果。

目录标签

目录标签

金融数据PythonAI代理AI分析金融分析本地部署多代理系统投资建议实时数据

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP