Skip to main content

Advanced AI Trading Intelligence Framework โ€” MCP server with walk-forward backtesting, trade logs, equity curves, 1h timeframe, sentiment, Yahoo Finance, and 30+ technical analysis tools

Project description

๐Ÿ“ˆ AI Trading Intelligence Framework โ€” MCP Server

atilaahmettaner%2Ftradingview-mcp | Trendshift

The most complete AI-powered trading toolkit for Claude and MCP clients. Backtesting + Live Sentiment + Yahoo Finance + 30+ Technical Analysis Tools โ€” all in one MCP server.

License: MIT Python 3.10+ MCP Ready OpenClaw Ready Version PyPI GitHub Sponsors

โญ If this tool improves your workflow, please star the repo and consider sponsoring โ€” it keeps the project alive and growing!

Sponsor $5 Sponsor $15 Sponsor $30

๐ŸŽฅ Framework Demo

https://github-production-user-asset-6210df.s3.amazonaws.com/67838093/478689497-4a605d98-43e8-49a6-8d3a-559315f6c01d.mp4


๐Ÿ—๏ธ Architecture

tradingview-mcp Architecture


โœจ Why tradingview-mcp?

Feature tradingview-mcp Traditional Setups Bloomberg Terminal
Setup Time 5 minutes Hours (Docker, Conda...) Weeks (Contracts)
Cost Free & Open Source Variable $30k+/year
Backtesting โœ… 6 strategies + Sharpe โŒ Manual scripting โœ… Proprietary
Live Sentiment โœ… Reddit + RSS news โŒ Separate setup โœ… Terminal
Market Data โœ… Live / Real-Time Historical / Delayed Live
API Keys None required Multiple (OpenAI, etc.) N/A

๐Ÿš€ Quick Start (5 Minutes)

Install via pip

pip install tradingview-assistant

Claude Desktop Config (claude_desktop_config.json)

Note: On macOS, GUI apps like Claude Desktop may not have ~/.local/bin in their PATH. Use the full path to uvx to avoid "command not found" errors.

{
  "mcpServers": {
    "tradingview": {
      "command": "/Users/YOUR_USERNAME/.local/bin/uvx",
      "args": ["--from", "tradingview-assistant", "tradingview-mcp"]
    }
  }
}

On Linux, replace /Users/YOUR_USERNAME with /home/YOUR_USERNAME. On Windows, use %USERPROFILE%\.local\bin\uvx.exe.

Or run from source

git clone https://github.com/atilaahmettaner/tradingview-mcp
cd tradingview-mcp
uv run tradingview-mcp

๏ฟฝ Project Structure

tradingview-mcp/
โ”œโ”€ src/tradingview_mcp/
โ”‚  โ”œโ”€ server.py                     # MCP tool registry and handlers
โ”‚  โ”œโ”€ coinlist/                     # Exchange symbol universes
โ”‚  โ””โ”€ core/
โ”‚     โ”œโ”€ services/                  # Business logic (screener, risk, backtest, etc.)
โ”‚     โ”‚  โ””โ”€ market_adapters/        # Market-specific adapters (EGX, NSE)
โ”‚     โ”œโ”€ data/                      # Static market datasets (EGX/NSE sectors and indices)
โ”‚     โ”œโ”€ utils/                     # Validators and shared utilities
โ”‚     โ””โ”€ portfolio.py               # SQLite portfolio persistence
โ”œโ”€ tests/
โ”‚  โ”œโ”€ unit/                         # Unit and architecture/perf tests
โ”‚  โ””โ”€ live_feature_test.py          # Live integration checks (no mocks)
โ”œโ”€ scripts/
โ”‚  โ””โ”€ repo_hygiene_check.py         # Security/hygiene checker for repo content
โ”œโ”€ .githooks/pre-commit             # Optional local hook to block bad commits
โ””โ”€ .github/workflows/
   โ””โ”€ repo-hygiene.yml              # CI gate for secret/leak/hygiene checks

๐Ÿ”’ Repository Hygiene & Security Checks

This repository includes a guard to reduce accidental leakage of sensitive data or generated local artifacts.

What the checker blocks

  • Potential secrets (private key blocks, common API key token patterns)
  • Forbidden local/generated paths (for example graphify-out/, .agents/, .venv/)
  • Sensitive certificate/key extensions (.pem, .key, .p12, ...)
  • Oversized files (>2 MB) that should not live in source control

Run manually

python scripts/repo_hygiene_check.py

Enable local pre-commit hook

git config core.hooksPath .githooks

CI enforcement

The Repository Hygiene workflow runs on PRs and pushes to main.


โ–ถ๏ธ How to Use (MCP)

Typical prompts in Claude

  • Show top gainers on KuCoin in 1h timeframe
  • Run a Bollinger scan on Binance with limit 20
  • Analyze AAPL with technical + sentiment + news
  • Backtest RSI strategy for BTC-USD over 2 years
  • Assess trade risk for NSE:INFY buy setup

NSE sector scanner (adapter-level)

If you are developing locally and want to test the adapter directly:

python -c "from tradingview_mcp.core.services.market_adapters.nse_adapter import NSEAdapter; print(NSEAdapter().run_sector_scanner(timeframe='1D', top_n_sectors=3, top_n_stocks=2, min_stock_score=60)['status'])"

Expected result in healthy network conditions: ok.


๏ฟฝ๐Ÿ› ๏ธ Troubleshooting

๐ŸชŸ Windows: MCP error -32001: Request timed out on first launch

Symptom โ€” you see this in the Claude Desktop logs shortly after adding the config:

[tradingview] Server started and connected successfully
[tradingview] Message from client: initialize ...
[60 seconds later]
[tradingview] notifications/cancelled โ€” reason: "MCP error -32001: Request timed out"

Why it happens: on Windows with Python 3.14, uvx downloads tradingview-assistant, creates a fresh virtualenv, and installs dependencies the first time it runs. Because pandas has no prebuilt wheel for Python 3.14 yet, pip falls back to a source build โ€” which typically exceeds Claude Desktop's 60-second MCP initialization timeout.

Fix โ€” pin to Python 3.13 (has prebuilt pandas wheels):

{
  "mcpServers": {
    "tradingview": {
      "command": "uvx",
      "args": ["--python", "3.13", "--from", "tradingview-assistant", "tradingview-mcp"]
    }
  }
}

On macOS use the full path to uvx (see the note in Quick Start). On Windows uvx is typically %USERPROFILE%\.local\bin\uvx.exe.

Alternative โ€” pre-install once, then let Claude Desktop reuse the cache:

# Run in a terminal before launching Claude Desktop
uv tool install --python 3.13 tradingview-assistant

After the install finishes, start Claude Desktop with the normal config and the server will come up instantly (cache is already warm).

Credit: @wyh4444 for the original report in #24.


๐Ÿ“ฑ Use via Telegram, WhatsApp & More (OpenClaw)

Connect this server to Telegram, WhatsApp, Discord and 20+ messaging platforms using OpenClaw โ€” a self-hosted AI gateway. Tested & verified on Hetzner VPS (Ubuntu 24.04).

How It Works

OpenClaw routes Telegram messages to an AI agent. The agent uses trading.py โ€” a thin Python wrapper โ€” to call tradingview-mcp functions and return formatted results. No MCP protocol needed between OpenClaw and the server; it's a direct Python import.

Telegram โ†’ OpenClaw agent (AI model) โ†’ trading.py (bash) โ†’ tradingview-mcp โ†’ Yahoo Finance

Quick Setup

# 1. Install UV and tradingview-mcp
curl -LsSf https://astral.sh/uv/install.sh | sh && source ~/.bashrc
uv tool install tradingview-assistant

# 2. Configure OpenClaw channels
cat > ~/.openclaw/openclaw.json << 'EOF'
{
  channels: {
    telegram: {
      botToken: "YOUR_BOT_TOKEN_HERE",
    },
  },
}
EOF

# 3. Configure gateway + agent
openclaw config set gateway.mode local
openclaw config set acp.defaultAgent main

# 4. Set your AI model (choose ONE option below)
openclaw configure --section model

# 5. Install the skill + tool wrapper
mkdir -p ~/.agents/skills/tradingview-mcp ~/.openclaw/tools
curl -fsSL https://raw.githubusercontent.com/atilaahmettaner/tradingview-mcp/main/openclaw/SKILL.md \
  -o ~/.agents/skills/tradingview-mcp/SKILL.md
curl -fsSL https://raw.githubusercontent.com/atilaahmettaner/tradingview-mcp/main/openclaw/trading.py \
  -o ~/.openclaw/tools/trading.py && chmod +x ~/.openclaw/tools/trading.py

# 6. Start the gateway
openclaw gateway install
systemctl --user start openclaw-gateway.service

Choose Your AI Model

OpenRouter is not required โ€” use whichever provider you have a key for:

Provider Model ID for OpenClaw Get Key
OpenRouter (aggregator โ€” access to all models) openrouter/google/gemini-3-flash-preview openrouter.ai/keys
Anthropic (Claude direct) anthropic/claude-sonnet-4-5 console.anthropic.com
Google (Gemini direct) google/gemini-2.5-flash aistudio.google.com
OpenAI (GPT direct) openai/gpt-4o-mini platform.openai.com
# Examples โ€” set your chosen model:
openclaw config set agents.defaults.model "openrouter/google/gemini-3-flash-preview"  # via OpenRouter
openclaw config set agents.defaults.model "anthropic/claude-sonnet-4-5"               # Anthropic direct
openclaw config set agents.defaults.model "google/gemini-2.5-flash"                   # Google direct

โš ๏ธ Important: Prefix must match your provider. google/... needs a Google API key. openrouter/... needs an OpenRouter key.

โš ๏ธ Common Mistakes

Symptom Cause Fix
Unrecognized keys: mcpServers mcpServers not supported in this version Remove from config, use bash wrapper
No API key for provider "google" Used google/model but only have OpenRouter key Use openrouter/google/model instead
which agent? loop acp.defaultAgent not set openclaw config set acp.defaultAgent main
Gateway won't start gateway.mode missing openclaw config set gateway.mode local

Test Your Bot

Once running, send your Telegram bot:

market snapshot
backtest RSI strategy for AAPL, 1 year
compare all strategies for BTC-USD

๐Ÿ‘‰ Full OpenClaw Setup Guide โ†’


Unlike basic screeners, this framework deploys specialized AI agents that debate findings in real-time:

  1. ๐Ÿ› ๏ธ Technical Analyst โ€” Bollinger Bands (ยฑ3 proprietary rating), RSI, MACD
  2. ๐ŸŒŠ Sentiment & Momentum Analyst โ€” Reddit community sentiment + price momentum
  3. ๐Ÿ›ก๏ธ Risk Manager โ€” Volatility, drawdown risk, mean-reversion signals

Output: STRONG BUY / BUY / HOLD / SELL / STRONG SELL with confidence score


๐Ÿ”ง All 30+ MCP Tools

๏ฟฝ Paper Trading Simulation

Fully implemented. All trades execute in paper mode by default โ€” no real money, no broker connection required. State persists in a local SQLite database across restarts.

Tool Description
execute_order Submit a paper BUY/SELL order (paper=True by default). Enforces 30% max position size per symbol.
execute_portfolio_trade Direct portfolio trade execution with position-limit guard.
get_user_portfolio View current holdings: positions, P&L, cash balance.
get_portfolio_trade_history Full audit log of all past paper trades.

How it works:

  • Trades are recorded in ~/.tradingview_mcp_data/portfolio.db (SQLite)
  • Each user has an isolated paper portfolio (user_id parameter)
  • Position size is capped at 30% of portfolio value per symbol
  • Live broker execution is intentionally disabled โ€” execute_order(paper=False) returns {status: not_implemented}
Example prompts:
  "Buy 10 shares of AAPL at $175 (paper trade)"
  "Sell 5 ETH at $2,400"
  "Show my current portfolio"
  "Show my paper trading history"

๏ฟฝ๐Ÿ“Š Backtesting Engine (New in v0.6.0)

Tool Description
backtest_strategy Backtest 1 of 6 strategies with institutional metrics (Sharpe, Calmar, Expectancy)
compare_strategies Run all 6 strategies on same symbol and rank by performance

6 Strategies to Test:

  • rsi โ€” RSI oversold/overbought mean reversion
  • bollinger โ€” Bollinger Band mean reversion
  • macd โ€” MACD golden/death cross
  • ema_cross โ€” EMA 20/50 Golden/Death Cross
  • supertrend โ€” ATR-based Supertrend trend following ๐Ÿ”ฅ
  • donchian โ€” Donchian Channel breakout (Turtle Trader style)

Metrics you get: Win Rate, Total Return, Sharpe Ratio, Calmar Ratio, Max Drawdown, Profit Factor, Expectancy, Best/Worst Trade, vs Buy-and-Hold, with realistic commission + slippage simulation.

Example prompt: "Compare all strategies on BTC-USD for 2 years"
โ†’ #1 Supertrend: +31.5% | Sharpe: 2.1 | WR: 62%
โ†’ #2 Bollinger:  +18.3% | Sharpe: 3.4 | WR: 75%
โ†’ Buy & Hold:    -5.0%

๐Ÿ’ฐ Yahoo Finance โ€” Real-Time Prices (New in v0.6.0)

Tool Description
yahoo_price Real-time quote: price, change %, 52w high/low, market state
market_snapshot Global overview: S&P500, NASDAQ, VIX, BTC, ETH, EUR/USD, SPY, GLD

Supports: Stocks (AAPL, TSLA, NVDA), Crypto (BTC-USD, ETH-USD, SOL-USD), ETFs (SPY, QQQ, GLD), Indices (^GSPC, ^DJI, ^IXIC, ^VIX), FX (EURUSD=X), Turkish (THYAO.IS, SASA.IS)


๐Ÿง  AI Sentiment & Intelligence (New in v0.5.0)

Tool Description
market_sentiment Reddit sentiment across finance communities (bullish/bearish score, top posts)
financial_news Live RSS headlines from Reuters, CoinDesk, CoinTelegraph
combined_analysis Power Tool: TradingView technicals + Reddit sentiment + live news โ†’ confluence decision

๐Ÿ“ˆ Technical Analysis Core

Tool Description
get_technical_analysis Full TA: RSI, MACD, Bollinger, 23 indicators with BUY/SELL/HOLD
get_multiple_analysis Bulk TA for multiple symbols at once
get_bollinger_band_analysis Proprietary ยฑ3 BB rating system
get_stock_decision 3-layer decision engine (ranking + trade setup + quality score)
screen_stocks Multi-exchange screener with 20+ filter criteria
scan_by_signal Scan by signal type (oversold, trending, breakout...)
get_candlestick_patterns 15 candlestick pattern detector
get_multi_timeframe_analysis Weeklyโ†’Dailyโ†’4Hโ†’1Hโ†’15m alignment analysis

๐ŸŒ Multi-Exchange Support

Exchange Tools
Binance Crypto screener, all pairs
KuCoin / Bybit+ Crypto screener
NASDAQ / NYSE US stocks (AAPL, TSLA, NVDA...)
EGX (Egypt) egx_market_overview, egx_stock_screener, egx_trade_plan, egx_fibonacci_retracement
Turkish (BIST) Via TradingView screener

๐Ÿ’ฌ Example AI Conversations

You: "Give me a full market snapshot right now"
AI: [market_snapshot] โ†’ S&P500 -3.4%, BTC +0.1%, VIX 31 (+13%), EUR/USD 1.15

You: "What is Reddit saying about NVDA?"
AI: [market_sentiment] โ†’ Strongly Bullish (0.41) | 23 posts | 18 bullish

You: "Backtest RSI strategy on BTC-USD for 2 years"
AI: [backtest_strategy] โ†’ +31.5% return | 100% win rate | 2 trades | B&H: -5%

You: "Which strategy worked best on AAPL in the last 2 years?"
AI: [compare_strategies] โ†’ Supertrend #1 (+14.6%, Sharpe 3.09), MACD last (-9.1%)

You: "Analyze TSLA with all signals: technical + sentiment + news"
AI: [combined_analysis] โ†’ BUY (Technical STRONG BUY + Bullish Reddit + Positive news)

๐Ÿ’– Support the Project

This framework is free and open source, built in spare time. If it saves you hours of research or helps you make better decisions, please consider sponsoring:

Tier Monthly What You Get
โ˜• Coffee $5 Heartfelt gratitude + name in README
๐Ÿš€ Supporter $15 Above + priority bug fixes
๐Ÿ’Ž Pro $30 Above + priority feature requests
Sponsor

Every sponsor directly funds new features like Walk-Forward Backtesting, Twitter/X sentiment, and managed cloud hosting.


๐Ÿ“‹ Roadmap

  • TradingView technical analysis (30+ indicators)
  • Multi-exchange screener (Binance, KuCoin, MEXC, EGX, US stocks)
  • Reddit sentiment analysis
  • Live financial news (RSS)
  • Yahoo Finance real-time prices
  • Backtesting engine (6 strategies + Sharpe/Calmar/Expectancy)
  • Walk-forward backtesting (overfitting detection)
  • Twitter/X market sentiment
  • Paper trading simulation
  • Managed cloud hosting (no local setup)

๐Ÿ“„ License

MIT License โ€” see LICENSE for details.


Disclaimer: This tool is for educational and research purposes only. It does not constitute financial advice. Always do your own research before making investment decisions.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tradingview_assistant-0.8.tar.gz (169.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tradingview_assistant-0.8-py3-none-any.whl (188.2 kB view details)

Uploaded Python 3

File details

Details for the file tradingview_assistant-0.8.tar.gz.

File metadata

  • Download URL: tradingview_assistant-0.8.tar.gz
  • Upload date:
  • Size: 169.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for tradingview_assistant-0.8.tar.gz
Algorithm Hash digest
SHA256 4c04a3fd7459820947bfa742d92f3e183e2411bc2f829a43425800b7cc14e470
MD5 a621ec2105bc3e3b3b40f11fc4ceb795
BLAKE2b-256 d0f493f24182401931a86f950a30b1c69b5413f83e1d6049099ebbed991f1139

See more details on using hashes here.

File details

Details for the file tradingview_assistant-0.8-py3-none-any.whl.

File metadata

File hashes

Hashes for tradingview_assistant-0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 8633ca83fba54f7423ca2f061cf348f5b60728f9692bcf6c25a2b9687a6142f7
MD5 646084a0bbaa6ec22e246e6a9ae50317
BLAKE2b-256 abd1e7cdb9eacf255e95e7bf76bc0faaf85b7935d69d091770d886ef2797749b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page