I built TradingSpy: local, privacy-first AI trading assistant(First Open Source) TradingSpy, an open-source, local-first AI trading assistant, has been released. The tool provides market heatmaps, news catalysts, strategy generation, and backtesting in a single Docker application, prioritizing user privacy by keeping all data local. Local-first AI trading research: market heatmaps, news catalysts, strategy generation, Backtrader backtests, and transparent agent runs in one Docker app. TradingSpy is an open-source research workstation for traders and builders who want to ask questions, inspect market context, generate strategy ideas, and test them against real historical candles without wiring together five separate tools. It is not a broker and it does not place trades. It is a local research environment for analysis, backtesting, and strategy iteration. Fully open-source, zero data privacy concerns, and free of charge. Trading Companion — Chat with your market data, strategies, news, heatmaps, and backtest history. Strategy Researcher — Research to find the best trading strategies until it beats the baseline strategy. Trading Trend Prediction — Leverage calculation and LLM with the support and resistance lines to simulate expected stock trend. Trading Signal Analysis — The tool analyzes the real-time movement, incorporates peer stocks, insider trading information, and trading indicators. TradingSpy is designed with a hybrid approach: traditional data visualisation for quick, deterministic results combined with loop-engineering-powered agents as a trading companion. | Feature | What it does | |---|---| Market Intelligence | Real-time quotes, sector heatmaps, industry performance, insider activity, news search, and fundamentals — all in one query. | AI Strategy Generation | Describe a trading thesis in plain English; get a working Backtrader strategy with syntax and runtime validation. | Automated Backtesting | Every generated strategy is backtested against downloaded candles with configurable parameter sweeps. | Benchmark Comparison | Every result is compared to buy-and-hold and any saved strategy. Underperformers are rejected automatically. | Loop Engineering | Set a goal "beat buy-and-hold", "find undervalued semiconductors" and the agent iterates until it succeeds — no babysitting required. | Transparent Agent Runs | Every tool call, validation failure, rejection reason, and accepted result is logged and visible in the Task Center. | Multi-Provider LLM | Google AI Studio, Mistral, OpenRouter, NVIDIA, LiteLLM, Ollama local , AWS Bedrock, GCP Vertex AI, and Azure OpenAI. | OpenAI-Compatible API | Use TradingSpy as a backend for scripts, other agents, or custom integrations via /v1/chat/completions . | Local-First Architecture | All data stored under backend/data/ . No external accounts, no telemetry, no cloud dependency. | | Agent | Example Prompt | What it does | |---|---|---| Strategy Race | Generate until it beats buy and hold for QQQ. Use daily candles. Improve EMA Trend for TQQQ using daily candles. Generate until it beats EMA Trend, not buy and hold. | Generates strategies based on selected modes tick data, research papers, etc. from the AI Strategy Studio. Improves or compares strategies over rounds — can use a previous accepted version or selected baseline, generate candidates, backtest them, and accept only versions that beat the target benchmark. | Signal Analysis | Predict the next move for btc-usd for daily interval | Reads recent bars and support/resistance levels to predict the price trend. | Stock Screening | Scan AI stocks until you find 10 which are good enough on fundamentals | Uses the fundamental scanner to search for undervalued stocks. Screens a universe for valuation/growth/profitability candidates, enriches passing names with market context, news, options, and insider summaries. Can continue with a wider universe. | Chat | Give me a daily market brief with breadth, strongest and weakest industries, important news, and earnings. | Pulls data from yfinance to summarize daily market information. | If the request involves long-running work, the UI creates a background run through /api/agent/runs . Background runs are stored locally, visible in the Task Center, and support: | Method | Endpoint | Purpose | |---|---|---| GET | /api/agent/runs | List recent runs | GET | /api/agent/runs/{run id} | Poll full state | POST | /api/agent/runs/{run id}/stop | Request cancellation | POST | /api/agent/runs/{run id}/continue | Continue a completed or stopped run | DELETE | /api/agent/runs/{run id} | Delete a single run | DELETE | /api/agent/runs | Clean all records | For strategy workflows, the agent is deliberately conservative: it validates generated code before backtesting, rejects zero-trade results instead of treating 0% ROI as meaningful, and reports validation failures and runtime errors as part of the public run log. It supports custom agent instructions, answer budget, run detail, sequential/parallel execution, and custom battle parameters. For insider buy/sell questions, the assistant uses deterministic tool-backed responses. It reports only returned records, separates open-market buys/sells from grants or awards, and says so if the feed is unavailable instead of filling gaps from memory. Not every question needs an agent. TradingSpy ships a full market dashboard for quick, deterministic results. | Component | Details | |---|---| Sector Heatmap | Color-coded grid of 25+ industry proxy ETFs grouped by sector. 16 time periods 1 min – max + YTD , extended hours toggle, search/filter, custom groups, and an Explain button that sends the heatmap to the AI assistant for analysis. Two display modes: industry ETFs or watchlist stocks. | Indices Banner | Top-of-page bar showing S&P 500, Dow Jones, NASDAQ 100, and Russell 2000 with live prices and percentage changes. | Industry Movements | Tracks individual stock price changes across 12 time windows 1 min to 1 year for 68+ major US stocks. Universe presets: High Cap, Semis, Software/AI, Leverage. | Watchlist & Intelligence | Auto-sync watchlists, real-time batch quotes, deep-dive panel company info, technicals, news, insider activity , and embedded candlestick charts. | | Source | What it provides | |---|---| Yahoo Finance | Price quotes, OHLCV candles daily, intraday, extended-hours , fundamentals, insider transactions, analyst recommendations, earnings dates, options chains, sector/industry metadata, screener queries. Primary data backbone. | SearXNG | Privacy-respecting metasearch for web and news — financial news, analyst opinions, macro events, catalyst research. Runs locally via Docker or standalone. | DuckDuckGo | Fallback web search when SearXNG is unavailable. HTML scraping + instant answer API. | arXiv | Academic papers on quantitative finance and algorithmic trading. Abstract and full-text PDF reading. | Backtrader | Local backtesting engine for strategy execution, parameter optimization, and benchmark comparison. | Any Yahoo Finance-compatible symbol works. Coverage varies by symbol and upstream source. | Market | Examples | Suffix | |---|---|---| | United States | AAPL , NVDA , QQQ , SPY | — | | London | AZN.L , HSBA.L | .L | | Hong Kong | 0700.HK | .HK | | Japan | 7203.T | .T | | India | RELIANCE.NS | .NS | | Canada | SHOP.TO | .TO | | Australia | BHP.AX | .AX | | Germany / France / UK / Eurozone | ^GDAXI , ^FCHI , ^FTSE , ^STOXX50E | ^ prefix | | China | 000001.SS | .SS | | Crypto | BTC-USD , ETH-USD | -USD | | Commodities | GC=F Gold , CL=F Oil | =F | | Region | Indices | |---|---| | United States | S&P 500, Dow Jones, NASDAQ 100, Russell 2000, VIX | | Europe | STOXX 50, FTSE 100, DAX, CAC 40 | | Asia | Nikkei 225, Hang Seng, Shanghai Composite, ASX 200 | | Commodities | Gold Futures, Crude Oil | | Crypto | Bitcoin, Ethereum | | Provider | Environment variable | Example default model | |---|---|---| | Google AI Studio | GOOGLE AI STUDIO API KEY | gemini-2.5-flash | | Mistral | MISTRAL API KEY | mistral-large-latest | | OpenRouter | OPENROUTER API KEY | openai/gpt-4o-mini | | NVIDIA | NVIDIA API KEY | nvidia/llama-3.1-405b-instruct | | LiteLLM | LITELLM API KEY , LITELLM BASE URL | Your proxy's model ID | | Ollama local | OLLAMA BASE URL ; no API key required | qwen2.5-coder:7b | Additional providers: AWS Bedrock, GCP Vertex AI, and Azure OpenAI are supported via the LiteLLM proxy. Point LITELLM BASE URL at your proxy and configure provider credentials there. Keys may be stored in .env / backend/.env or entered in the app's Settings page. Never commit a real key. See .env.example /mrhustlex/TradingSpy-TradingAgentService/blob/main/.env.example for every supported setting. git clone https://github.com/mrhustlex/TradingSpy-TradingAgentService.git cd TradingSpy cp .env.example .env Add at least one provider key to .env : GOOGLE AI STUDIO API KEY=your-gemini-key DEFAULT PROVIDER=google ai studio DEFAULT MODEL=gemini-2.5-flash Or use Ollama no API key required : ollama pull qwen2.5-coder:7b DEFAULT PROVIDER=ollama DEFAULT MODEL=qwen2.5-coder:7b OLLAMA BASE URL=http://host.docker.internal:11434/v1 You can also configure providers later in the app's Settings page. docker compose up -d --build | Service | URL | |---|---| | App | | http://localhost:8000 http://localhost:8000 http://localhost:8000/docs http://localhost:8000/docs http://localhost:8080 http://localhost:8080 docker compose down Runtime data remains under backend/data/ . Pull updates and rebuild with git pull && docker compose up -d --build . cd backend python3.11 -m venv .venv source .venv/bin/activate pip install -r requirements.txt uvicorn main:app --reload --host 0.0.0.0 --port 8000 Use Python 3.11. The pinned data-science dependencies are not reliable with Python 3.13. cd frontend npm ci npm run dev Open http://localhost:5173 http://localhost:5173 . npm run dev:searxng start npm run stop:searxng stop This starts only SearXNG at localhost:8080 . Alternatively, docker compose up -d searxng . php flowchart LR User "User / Browser" -- Frontend "React Frontend