tradingview

henrik73/tradingview
Hosted
0 Stars 96 次浏览 更新于 2026-08-23

# TradingView MCP Server

MCP 服务配置

复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用

{
  "mcpServers": {
    "tradingview": {
      "args": [
        "tradingview-mcp"
      ],
      "command": "uvx"
    }
  }
}

可用工具 (31 个)

该服务在 MCP 协议中暴露的工具,AI 可按需调用

get_field_info 1 个参数 需填 1 项

Get display name, type, and related info for a field. Args: field: Field/column name to look up Returns: Field info including display name, type, and variants if available

必填参数:field

get_screener_preset 1 个参数 需填 1 项

Return a full screener preset (query + code) by name.

必填参数:name

get_market_metainfo 4 个参数 需填 1 项

Return metainfo (field definitions and allowed values) for a market. Args: market: Market type (stocks, crypto, forex, bond, etc.) limit: Maximum fields to return (default 50, max 500) offset: Starting offset for pagination confirm_large: Set True to allow returning more than 100 items Returns: Paginated metainfo with field definitions

必填参数:market

ai_get_reference

Get AI-friendly quick reference for this MCP. Returns a compact guide with: - Available markets by category - Common columns by type - Filter operations - Common filter patterns - Timeframes This is the recommended starting point for AI agents to understand how to use this MCP.

该工具无需必填参数,直接调用即可

search_available_fields 3 个参数 需填 1 项

Search for fields/columns by name or description. Args: query: Search term (e.g., "volume", "RSI", "market cap") market: Market type to search in (stocks, crypto, forex, etc.) limit: Maximum results (default 20, max 50) Returns: Matching fields with their display names and types

必填参数:query

get_code_example 1 个参数 需填 1 项

Get Python code example for a specific screener type. Args: screener_name: Screener name (e.g., "Stocks (legacy)", "Crypto", "Forex", "ETFs", "Bonds") Returns: Python code example for building that screener query

必填参数:screener_name

list_fields_for_market 5 个参数

List available fields for a specific market with pagination. Args: market: Market type (stocks, crypto, forex, coin, bond, cfd, futures, options) category: Optional filter by field type (price, volume, fundamental, technical) limit: Maximum results (default 50, max 200) offset: Starting offset for pagination confirm_large: Set True to allow more than 100 results Returns: Paginated list of field definitions

该工具无需必填参数,直接调用即可

get_common_fields_summary 2 个参数

Get summary of commonly used fields across all markets. Args: category: Optional filter (price, volume, fundamental, technical, rating) limit: Maximum fields to return (default 30) Returns: Dict with field names, display names, and types

该工具无需必填参数,直接调用即可

get_help 1 个参数

📖 Usage guide - required reading for AI! Args: topic: Optional topic: 'markets', 'columns', 'filters', 'examples', 'tools' If omitted, returns the full guide Returns: Usage guide and examples

该工具无需必填参数,直接调用即可

search_symbols 3 个参数 需填 1 项

🔍 Search symbols by name (fuzzy search) Supports company names or tickers, e.g., "Apple", "Tesla", "Microsoft". Args: query: Search keyword (company name or ticker) market: Market (america, crypto, uk, etc.) limit: Max results (default 25, max 100) Returns: Matching symbols with full names Examples: search_symbols("apple", "america") -> Apple Inc., Applebee's, etc. search_symbols("BTC", "crypto") -> BTC pairs

必填参数:query

get_symbol_info 2 个参数 需填 1 项

Get detailed information for a symbol. Args: symbol: Ticker in 'EXCHANGE:SYMBOL' format (e.g., 'NASDAQ:AAPL') or just a ticker (e.g., 'AAPL', auto-search) include_technical: Whether to include technical indicators Returns: Detailed symbol info including name, price, market cap, etc. Examples: get_symbol_info("NASDAQ:AAPL") -> Apple Inc. details get_symbol_info("AAPL") -> auto-search

必填参数:symbol

screen_market 6 个参数

Run a custom market screening query. ⚠️ Note: Default returns 25 rows. Increase `limit` for more. Args: market: Market (america=US stocks, crypto, uk, etc.) columns: Columns to return (default includes name, description, close, change, volume, market_cap) sort_by: Sort column ascending: Sort order (True=asc, False=desc) limit: Max results (1-500, default 25) filters: Filter list, e.g. [{"column": "change", "operation": "gt", "value": 5}] Supported ops: gt, gte, lt, lte, eq, neq, between, isin Returns: Dict with total_count, returned, data. Each row includes description (full name like "Apple Inc.").

该工具无需必填参数,直接调用即可

get_top_gainers 2 个参数

Get top gainers for a market. ⚠️ Note: Default returns 25 rows. Increase `limit` for more. Args: market: Market (america=US stocks, crypto, uk, etc.) limit: Result count (1-100, default 25) Returns: Top gainers with description (full name). Example: get_top_gainers("america", 10) -> Top 10 US gainers get_top_gainers("crypto", 25) -> Top 25 crypto gainers

该工具无需必填参数,直接调用即可

get_top_losers 2 个参数

Get top losers for a market. ⚠️ Note: Default returns 25 rows. Increase `limit` for more. Args: market: Market (america=US stocks, crypto, uk, etc.) limit: Result count (1-100, default 25) Returns: Top losers with description (full name). Example: get_top_losers("america", 10) -> Top 10 US losers

该工具无需必填参数,直接调用即可

get_most_active 2 个参数

Get most active by volume. ⚠️ Note: Default returns 25 rows. Args: market: Market limit: Result count (1-100) Returns: Most active list with description (full name)

该工具无需必填参数,直接调用即可

get_premarket_movers 2 个参数

Get pre-market movers (US only). Args: scan_type: 'gainers', 'losers', 'most_active', 'gappers' limit: Result count (1-100) Returns: List of pre-market movers

该工具无需必填参数,直接调用即可

get_postmarket_movers 2 个参数

Get post-market movers (US market only). Args: scan_type: Type of scan - 'gainers', 'losers', 'most_active' limit: Number of results (1-100) Returns: List of post-market movers

该工具无需必填参数,直接调用即可

scan_rsi_extremes 4 个参数

Scan for RSI overbought/oversold conditions. Args: market: Market to scan condition: 'oversold' or 'overbought' threshold: RSI threshold (default 30 for oversold, 70 for overbought) limit: Number of results (1-100) Returns: List of symbols matching RSI criteria

该工具无需必填参数,直接调用即可

scan_macd_crossover 3 个参数

Scan for MACD crossover signals. Args: market: Market to scan crossover_type: 'bullish' (MACD crosses above signal) or 'bearish' limit: Number of results (1-100) Returns: List of symbols with MACD crossover

该工具无需必填参数,直接调用即可

scan_bollinger_bands 3 个参数

Scan for Bollinger Band conditions. Args: market: Market to scan condition: 'squeeze' (low volatility), 'above_upper', 'below_lower' limit: Number of results (1-100) Returns: List of symbols matching BB criteria

该工具无需必填参数,直接调用即可

scan_volume_breakout 4 个参数

Scan for volume breakout candidates. Args: market: Market to scan volume_multiplier: Minimum relative volume vs 10-day average (default 2.0) min_price_change: Minimum absolute price change % (default 3.0) limit: Number of results (1-100) Returns: List of symbols with volume breakouts

该工具无需必填参数,直接调用即可

scan_moving_average_crossover 3 个参数

Scan for moving average crossovers. Args: market: Market to scan crossover_type: 'golden_cross' (SMA50 crosses above SMA200), 'death_cross' (SMA50 crosses below SMA200), 'above_all_mas', 'below_all_mas' limit: Number of results (1-100) Returns: List of symbols with MA crossovers

该工具无需必填参数,直接调用即可

scan_52_week_levels 4 个参数

Scan for stocks near 52-week highs or lows. Args: market: Market to scan level_type: 'near_high', 'near_low', 'new_high', 'new_low' threshold_pct: How close to the level (default 5%) limit: Number of results (1-100) Returns: List of symbols near 52-week extremes

该工具无需必填参数,直接调用即可

get_symbol_analysis 2 个参数 需填 1 项

Get comprehensive technical analysis for a specific symbol. Args: symbol: Symbol in format 'EXCHANGE:SYMBOL' (e.g., 'NASDAQ:AAPL', 'BINANCE:BTCUSDT') include_fundamentals: Include fundamental data if available Returns: Comprehensive analysis with indicators, signals, and recommendations

必填参数:symbol

compare_symbols 2 个参数 需填 1 项

Compare multiple symbols side by side. Args: symbols: List of symbols (e.g., ['NASDAQ:AAPL', 'NASDAQ:MSFT', 'NASDAQ:GOOGL']) columns: Columns to compare (default: standard comparison set) Returns: Comparison data for all symbols

必填参数:symbols

get_all_market_symbols 1 个参数

Get all available symbols for a market. Args: market: Market identifier (america, crypto, uk, etc.) Returns: Dictionary with symbol count and list of symbols

该工具无需必填参数,直接调用即可

run_scanner_preset 3 个参数 需填 1 项

Run a pre-built scanner preset. Args: preset_name: Name of the preset (see scanners://presets resource) market: Override market (optional) limit: Number of results (1-100) Returns: Scanner results

必填参数:preset_name

advanced_query 7 个参数

Execute an advanced query with complex AND/OR logic. Args: market: Market to scan select_columns: Columns to return conditions: List of conditions, each with: - column: Column name - op: Operation (gt, gte, lt, lte, eq, neq, between, isin, crosses_above, crosses_below) - value: Value or [min, max] for between logic: 'and' or 'or' to combine conditions sort_by: Column to sort by ascending: Sort order limit: Maximum results (1-500) Returns: Query results Example: conditions=[ {"column": "RSI", "op": "lt", "value": 30}, {"column": "volume", "op": "gt", "value": 1000000}, {"column": "change", "op": "between", "value": [-5, 5]} ]

该工具无需必填参数,直接调用即可

get_crypto_gainers 2 个参数

Get top gaining cryptocurrencies. Args: exchange: Specific exchange (binance, coinbase, etc.) or None for all limit: Number of results (1-100) Returns: List of top crypto gainers

该工具无需必填参数,直接调用即可

get_crypto_losers 2 个参数

Get top losing cryptocurrencies. Args: exchange: Specific exchange (binance, coinbase, etc.) or None for all limit: Number of results (1-100) Returns: List of top crypto losers

该工具无需必填参数,直接调用即可

scan_crypto_technicals 3 个参数

Scan cryptocurrencies based on technical indicators. Args: scan_type: Type of scan - 'oversold', 'overbought', 'macd_bullish', 'macd_bearish', 'high_volume' exchange: Specific exchange or None for all limit: Number of results (1-100) Returns: Crypto technical scan results

该工具无需必填参数,直接调用即可

服务介绍

TradingView MCP 服务器

PyPI 版本
Python

这是一个全面的模型上下文协议(MCP)服务器,用于TradingView市场筛选,并完全集成了筛选器功能。该服务器通过MCP接口直接提供了强大的加密货币和股票市场分析工具。

快速开始(无需安装)

使用uvx直接运行而无需安装:


{

  "mcpServers": {

    "tradingview": {

      "command": "uvx",

      "args": ["tradingview-mcp"]

    }

  }

}

🤖 针对AI代理

📖 阅读 AI.md 获取完整指南! 您可以复制整个AI.md文件以了解所有功能。

快速开始:

  1. 调用 get_help() 来了解如何使用此MCP
  2. 调用 ai_get_reference() 获取市场、列和过滤器参考

要点:

  • 所有结果都包含带有全名的description字段(例如,“Apple Inc.”而不仅仅是“AAPL”)
  • 使用limit参数控制结果数量(默认值:25)
  • 使用search_symbols("apple", "america")按公司名称搜索

# Quick examples:

get_top_gainers("america", 10)       # Top 10 US stock gainers

search_symbols("tesla", "america")    # Search for Tesla

get_symbol_info("NASDAQ:AAPL")       # Apple Inc. details

功能

核心筛选器功能

  • 直接集成TradingView API:查询TradingView扫描仪API,无需外部依赖
  • 多市场支持:包括加密货币、股票、外汇、期货和债券在内的76多个市场
  • 类似SQL的查询接口:构建带有过滤、排序和分页的复杂查询
  • 250+ 技术指标:访问一套全面的技术分析列
  • AI友好设计:包括description(全名)、节省令牌的限制和帮助工具

MCP 工具

🔍 发现与帮助工具(AI从这里开始!)

  • get_help(topic)📖 必读! 获取使用指南和示例
  • search_symbols(query, market):🔍 按公司名称搜索(例如,“Apple”,“Tesla”)
  • get_symbol_info(symbol):获取详细的符号信息
  • ai_get_reference():AI快速参考指南

筛选工具

  • screen_market:执行自定义市场筛选查询
  • get_top_gainers:查找涨幅最大的资产(包括完整的公司名称)
  • get_top_losers:查找跌幅最大的资产(包括完整的公司名称)
  • get_most_active:按成交量最活跃
  • get_premarket_movers:盘前涨幅最大、跌幅最大及最活跃
  • get_postmarket_movers:盘后活动分析
  • get_technical_analysis:特定符号的详细技术分析
  • scan_bollinger_bands:布林带挤压检测
  • scan_volume_breakout:成交量突破检测
  • scan_rsi_extremes:RSI超买/超卖扫描
  • scan_macd_crossover:MACD交叉检测
  • get_all_symbols:检索市场的所有符号
  • advanced_query:使用AND/OR逻辑执行高级查询

AI友好的参考工具

  • search_available_fields:按名称或描述搜索字段/列
  • get_field_info:获取特定字段的显示名称和类型
  • get_code_example:获取筛选器类型的Python代码示例
  • list_fields_for_market:列出带有分页的可用字段
  • get_common_fields_summary:按类别获取常用字段
  • get_screener_preset:检索预定义的筛选器预设
  • get_market_metainfo:每个市场的字段定义和允许值

MCP 资源

  • markets://list:列出所有可用市场
  • columns://list:列出所有可用的技术指标列
  • exchanges://crypto:列出加密货币交易所
  • presets://list:列出预定义的筛选预设
  • docs://params:筛选器参数格式和架构
  • docs://screeners:预定义筛选器预设概述
  • docs://fields:字段显示名称(分页)
  • docs://markets:市场元数据
  • docs://ai-reference:AI快速参考指南
  • docs://code-examples:筛选器的Python代码示例

安装

使用 uvx(推荐 - 无需安装)

{
  "mcpServers": {
    "tradingview": {
      "command": "uvx",
      "args": ["tradingview-mcp"]
    }
  }
}

使用 uvPLACEHOLDER_CODE_3

使用 pip

pip install tradingview-mcp

从源代码安装

git clone https://github.com/k73a/tradingview-mcp.git
cd tradingview-mcp
uv sync

使用方法

运行 MCP 服务器

标准输入输出传输(默认)

tradingview-mcp

HTTP 传输

tradingview-mcp streamable-http --host 127.0.0.1 --port 8000

MCP 客户端配置

使用 uvx(推荐)

{
  "mcpServers": {
    "tradingview": {
      "command": "uvx",
      "args": ["tradingview-mcp"]
    }
  }
}

使用已安装的包

{
  "mcpServers": {
    "tradingview": {
      "command": "tradingview-mcp",
      "args": []
    }
  }
}

对于 AI 代理:入门指南

  1. 首先调用 ai_get_reference() 以了解可用市场、列和过滤器
  2. 使用 search_available_fields("你的查询") 查找特定列
  3. 使用 get_code_example("Stocks (legacy)") 查看查询模式
  4. 使用 screen_market()advanced_query() 构建查询

示例查询

基本市场筛选

# Get top 50 stocks by trading volume
await client.call_tool("screen_market", {
    "market": "america",
    "columns": ["name", "close", "volume", "change"],
    "sort_by": "volume",
    "ascending": False,
    "limit": 50
})

技术分析筛选

# Find stocks with RSI below 30 (oversold)
await client.call_tool("scan_rsi_extremes", {
    "market": "america",
    "condition": "oversold",
    "threshold": 30,
    "limit": 20
})

加密货币筛选

# Get top crypto gainers
await client.call_tool("get_top_gainers", {
    "market": "crypto",
    "limit": 25
})

API 参考

市场

支持以下市场:

  • 加密货币: crypto, coin
  • 传统金融: america, uk, germany, japan 等(67 个国家)
  • 其他: forex, futures, bonds, cfd, options

技术指标

常用指标包括:

  • 价格: open, high, low, close, volume
  • 移动平均线: SMA5, SMA10, SMA20, SMA50, SMA100, SMA200, EMA5, EMA10, EMA20, EMA50, EMA100, EMA200
  • 振荡器: RSI, RSI7, MACD.macd, MACD.signal, Stoch.K, Stoch.D
  • 布林带: BB.upper, BB.lower
  • 其他: VWAP, ATR, ADX, CCI20

请参阅 columns://list 资源以获取完整列表。

开发

设置开发环境

git clone https://github.com/k73a/tradingview-mcp.git
cd tradingview-mcp
uv sync --all-extras

运行测试

uv run pytest tests/ -v

代码格式化

uv run ruff format .
uv run ruff check . --fix

类型检查

uv run pyright

调试模式

通过设置以下内容,启用工具的结构化调试响应:


export TRADINGVIEW_MCP_DEBUG=1

文档数据路径(可选)

如果你想使用完整的 TradingView Screener 文档数据集(例如,大型元信息文件),请将加载器指向你的文档数据目录:


export TRADINGVIEW_SCREENER_DOCS_DATA=/path/to/TradingView-Screener-docs/data

发布与版本

该项目使用 GitHub Actions 自动发布到 PyPI:

自动更新

  • 每周自动更新:每个星期一,工作流会检查依赖项更新,运行测试,并在有更改时发布新版本
  • 手动触发:你可以从 GitHub Actions 选项卡手动触发更新

手动发布

要创建手动发布:

  1. pyproject.toml 中更新版本
  2. 提交并创建标签:
    git commit -am "Bump version to x.y.z"
    git tag vx.y.z
    git push origin main --tags
    
  3. GitHub Actions 将自动构建并发布到 PyPI

有关详细的发布说明,请参阅 CONTRIBUTING.md

贡献

欢迎贡献!请参阅 CONTRIBUTING.md 获取指南。

许可证

MIT 许可证 - 详情请参阅 LICENSE

相关 MCP 服务