{"slug": "i-built-tradingspy-local-privacy-first-ai-trading-assistant-first-open-source", "title": "I built TradingSpy: local, privacy-first AI trading assistant(First Open Source)", "summary": "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.", "body_md": "Local-first AI trading research: market heatmaps, news catalysts, strategy generation, Backtrader backtests, and transparent agent runs in one Docker app.\n\nTradingSpy 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.\n\nIt 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.\n\n**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.\n\nTradingSpy is designed with a hybrid approach: traditional data visualisation for quick, deterministic results combined with loop-engineering-powered agents as a trading companion.\n\n| Feature | What it does |\n|---|---|\nMarket Intelligence |\nReal-time quotes, sector heatmaps, industry performance, insider activity, news search, and fundamentals — all in one query. |\nAI Strategy Generation |\nDescribe a trading thesis in plain English; get a working Backtrader strategy with syntax and runtime validation. |\nAutomated Backtesting |\nEvery generated strategy is backtested against downloaded candles with configurable parameter sweeps. |\nBenchmark Comparison |\nEvery result is compared to buy-and-hold and any saved strategy. Underperformers are rejected automatically. |\nLoop Engineering |\nSet a goal (\"beat buy-and-hold\", \"find undervalued semiconductors\") and the agent iterates until it succeeds — no babysitting required. |\nTransparent Agent Runs |\nEvery tool call, validation failure, rejection reason, and accepted result is logged and visible in the Task Center. |\nMulti-Provider LLM |\nGoogle AI Studio, Mistral, OpenRouter, NVIDIA, LiteLLM, Ollama (local), AWS Bedrock, GCP Vertex AI, and Azure OpenAI. |\nOpenAI-Compatible API |\nUse TradingSpy as a backend for scripts, other agents, or custom integrations via `/v1/chat/completions` . |\nLocal-First Architecture |\nAll data stored under `backend/data/` . No external accounts, no telemetry, no cloud dependency. |\n\n| Agent | Example Prompt | What it does |\n|---|---|---|\nStrategy Race |\n`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.` |\nGenerates 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. |\nSignal Analysis |\n`Predict the next move for btc-usd for daily interval` |\nReads recent bars and support/resistance levels to predict the price trend. |\nStock Screening |\n`Scan AI stocks until you find 10 which are good enough on fundamentals` |\nUses 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. |\nChat |\n`Give me a daily market brief with breadth, strongest and weakest industries, important news, and earnings.` |\nPulls data from yfinance to summarize daily market information. |\n\nIf the request involves long-running work, the UI creates a background run through `/api/agent/runs`\n\n. Background runs are stored locally, visible in the Task Center, and support:\n\n| Method | Endpoint | Purpose |\n|---|---|---|\n`GET` |\n`/api/agent/runs` |\nList recent runs |\n`GET` |\n`/api/agent/runs/{run_id}` |\nPoll full state |\n`POST` |\n`/api/agent/runs/{run_id}/stop` |\nRequest cancellation |\n`POST` |\n`/api/agent/runs/{run_id}/continue` |\nContinue a completed or stopped run |\n`DELETE` |\n`/api/agent/runs/{run_id}` |\nDelete a single run |\n`DELETE` |\n`/api/agent/runs` |\nClean all records |\n\nFor strategy workflows, the agent is deliberately conservative: it validates generated code before backtesting, rejects zero-trade results instead of treating `0% ROI`\n\nas 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.\n\nFor 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.\n\nNot every question needs an agent. TradingSpy ships a full market dashboard for quick, deterministic results.\n\n| Component | Details |\n|---|---|\nSector Heatmap |\nColor-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. |\nIndices Banner |\nTop-of-page bar showing S&P 500, Dow Jones, NASDAQ 100, and Russell 2000 with live prices and percentage changes. |\nIndustry Movements |\nTracks 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. |\nWatchlist & Intelligence |\nAuto-sync watchlists, real-time batch quotes, deep-dive panel (company info, technicals, news, insider activity), and embedded candlestick charts. |\n\n| Source | What it provides |\n|---|---|\nYahoo Finance |\nPrice quotes, OHLCV candles (daily, intraday, extended-hours), fundamentals, insider transactions, analyst recommendations, earnings dates, options chains, sector/industry metadata, screener queries. Primary data backbone. |\nSearXNG |\nPrivacy-respecting metasearch for web and news — financial news, analyst opinions, macro events, catalyst research. Runs locally via Docker or standalone. |\nDuckDuckGo |\nFallback web search when SearXNG is unavailable. HTML scraping + instant answer API. |\narXiv |\nAcademic papers on quantitative finance and algorithmic trading. Abstract and full-text PDF reading. |\nBacktrader |\nLocal backtesting engine for strategy execution, parameter optimization, and benchmark comparison. |\n\nAny Yahoo Finance-compatible symbol works. Coverage varies by symbol and upstream source.\n\n| Market | Examples | Suffix |\n|---|---|---|\n| United States | `AAPL` , `NVDA` , `QQQ` , `SPY` |\n— |\n| London | `AZN.L` , `HSBA.L` |\n`.L` |\n| Hong Kong | `0700.HK` |\n`.HK` |\n| Japan | `7203.T` |\n`.T` |\n| India | `RELIANCE.NS` |\n`.NS` |\n| Canada | `SHOP.TO` |\n`.TO` |\n| Australia | `BHP.AX` |\n`.AX` |\n| Germany / France / UK / Eurozone | `^GDAXI` , `^FCHI` , `^FTSE` , `^STOXX50E` |\n`^` prefix |\n| China | `000001.SS` |\n`.SS` |\n| Crypto | `BTC-USD` , `ETH-USD` |\n`-USD` |\n| Commodities | `GC=F` (Gold), `CL=F` (Oil) |\n`=F` |\n\n| Region | Indices |\n|---|---|\n| United States | S&P 500, Dow Jones, NASDAQ 100, Russell 2000, VIX |\n| Europe | STOXX 50, FTSE 100, DAX, CAC 40 |\n| Asia | Nikkei 225, Hang Seng, Shanghai Composite, ASX 200 |\n| Commodities | Gold Futures, Crude Oil |\n| Crypto | Bitcoin, Ethereum |\n\n| Provider | Environment variable | Example default model |\n|---|---|---|\n| Google AI Studio | `GOOGLE_AI_STUDIO_API_KEY` |\n`gemini-2.5-flash` |\n| Mistral | `MISTRAL_API_KEY` |\n`mistral-large-latest` |\n| OpenRouter | `OPENROUTER_API_KEY` |\n`openai/gpt-4o-mini` |\n| NVIDIA | `NVIDIA_API_KEY` |\n`nvidia/llama-3.1-405b-instruct` |\n| LiteLLM | `LITELLM_API_KEY` , `LITELLM_BASE_URL` |\nYour proxy's model ID |\n| Ollama (local) | `OLLAMA_BASE_URL` ; no API key required |\n`qwen2.5-coder:7b` |\n\nAdditional providers: AWS Bedrock, GCP Vertex AI, and Azure OpenAI are supported via the LiteLLM proxy. Point`LITELLM_BASE_URL`\n\nat your proxy and configure provider credentials there.\n\nKeys may be stored in `.env`\n\n/`backend/.env`\n\nor 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.\n\n```\ngit clone https://github.com/mrhustlex/TradingSpy-TradingAgentService.git\ncd TradingSpy\ncp .env.example .env\n```\n\nAdd at least one provider key to `.env`\n\n:\n\n```\nGOOGLE_AI_STUDIO_API_KEY=your-gemini-key\nDEFAULT_PROVIDER=google_ai_studio\nDEFAULT_MODEL=gemini-2.5-flash\n```\n\nOr use Ollama (no API key required):\n\n```\nollama pull qwen2.5-coder:7b\nDEFAULT_PROVIDER=ollama\nDEFAULT_MODEL=qwen2.5-coder:7b\nOLLAMA_BASE_URL=http://host.docker.internal:11434/v1\n```\n\nYou can also configure providers later in the app's Settings page.\n\n```\ndocker compose up -d --build\n```\n\n| Service | URL |\n|---|---|\n| App |\n|\n\n[http://localhost:8000](http://localhost:8000)[http://localhost:8000/docs](http://localhost:8000/docs)[http://localhost:8080](http://localhost:8080)\n\n```\ndocker compose down\n```\n\nRuntime data remains under `backend/data/`\n\n. Pull updates and rebuild with `git pull && docker compose up -d --build`\n\n.\n\n```\ncd backend\npython3.11 -m venv .venv\nsource .venv/bin/activate\npip install -r requirements.txt\nuvicorn main:app --reload --host 0.0.0.0 --port 8000\n```\n\nUse Python 3.11. The pinned data-science dependencies are not reliable with Python 3.13.\n\n```\ncd frontend\nnpm ci\nnpm run dev\n```\n\nOpen [http://localhost:5173](http://localhost:5173).\n\n```\nnpm run dev:searxng    # start\nnpm run stop:searxng   # stop\n```\n\nThis starts only SearXNG at `localhost:8080`\n\n. Alternatively, `docker compose up -d searxng`\n\n.\n\n``` php\nflowchart LR\n    User[\"User / Browser\"] --> Frontend[\"React Frontend<br/>localhost:3000\"]\n    Frontend --> Backend[\"FastAPI Backend<br/>localhost:8000\"]\n    Backend --> ChatAgent[\"Tool-Using Chat Assistant<br/>short research + tool checks\"]\n    Backend --> WorkflowAgent[\"Background Workflow Agents<br/>strategy_create / strategy_race / market_review / fundamental_screener\"]\n    Backend --> RemoteAgents[\"Remote Agent Outputs<br/>OpenAI-compatible / ACP / A2A\"]\n    Backend --> Backtest[\"Backtrader Engine<br/>backtests + optimization\"]\n    Backend --> Market[\"Market Intelligence<br/>yfinance + heatmaps + news\"]\n    Backend --> Store[\"Local Data<br/>TinyDB + candles + strategies\"]\n    Backend --> Search[\"SearXNG<br/>localhost:8080\"]\n    ChatAgent --> LLM[\"Validated LLM Providers<br/>Google AI Studio / Mistral / OpenRouter / LiteLLM\"]\n    WorkflowAgent --> LLM\n    RemoteAgents --> ChatAgent\n    RemoteAgents --> WorkflowAgent\n```\n\nAll runtime data is stored locally and ignored by Git:\n\n```\nbackend/data/\n├── db.json\n├── system_settings.json\n├── market_data/local_user/\n├── strategies/local_user/\n├── results/local_user/\n├── optimization_history/\n└── temp_datas/\n```\n\nBack these up separately if the results matter to you.\n\n| What | Deterministic? |\n|---|---|\n| Saved strategy against same candles, dates, capital, commission, parameters | Yes |\n| LLM-generated strategy code | No — non-deterministic across runs |\n| Live quotes, fundamentals, insider records, heatmaps, news | No — changes over time |\n| Model aliases and upstream provider behavior | May change — use explicit model IDs when comparing |\n| Backtest performance | Depends on period and assumptions — not a promise of future returns |\n\nKeep the dataset, generated strategy, benchmark, and run details together when sharing a result.\n\n| Concern | Detail |\n|---|---|\n| Research only | TradingSpy is for research and education. It is not financial advice. |\n| Backtest overfitting | Backtests can overfit and do not predict future returns. |\n| Code execution | Generated strategy Python is executed locally and is not sandboxed. Review it before running. |\n| Network binding | Keep all services bound to localhost unless you add auth, TLS, network controls, and process isolation. |\n| Credentials | Keep API keys out of git. Use `.env` or your own secret manager. |\n\n| Task | Command |\n|---|---|\n| Check services | `docker compose ps` |\n| Health check | `curl http://localhost:8000/health` |\n| View backend logs | `docker compose logs -f backend` |\n| View frontend logs | `docker compose logs -f frontend` |\n| View SearXNG logs | `docker compose logs -f searxng` |\n| Full rebuild | `docker compose build --no-cache && docker compose up -d` |\n| Check disk usage | `docker system df` |\n| Prune build cache | `docker builder prune` |\n\n- Discord community server\n- Per-agent GIF demos in README\n- More LLM provider integrations\n- Strategy sharing and export\n\nJoin the conversation:\n\n[Discord](coming soon)\n\nContributions are welcome. See [CONTRIBUTING.md](/mrhustlex/TradingSpy-TradingAgentService/blob/main/CONTRIBUTING.md) for the full guide.\n\n| Type | What to do |\n|---|---|\n| Bug reports | Open an issue with steps to reproduce, expected vs. actual behavior, and environment details. |\n| Feature requests | Describe the use case, not just the implementation. What problem does it solve? |\n| Code | Pick an open issue or start a discussion first for large changes. |\n| Documentation | Fix typos, clarify explanations, or add examples. |\n| Testing | Try edge cases, different providers, or non-US markets and report what breaks. |\n\n- Fork the repository and create a feature branch.\n- Set up with Docker or follow\n[Manual Development](#manual-development). - Run development checks:\n\n```\npython3 -m py_compile backend/main.py backend/modules/*.py\nnpm run build --prefix frontend\nnpm run lint --prefix frontend\n```\n\n- Add or update tests where practical.\n- Include screenshots for visual changes and request/response examples for API changes.\n- Submit a pull request with a clear description of what changed and why.\n\n| Rule | Why |\n|---|---|\n| One logical change per PR | Keeps reviews focused and diffs clean. |\n| Never commit credentials, databases, market data, strategies, caches, or build output | Preserves security and keeps the repo small. |\n| Treat generated strategy code as untrusted | Preserve the local-only security model. |\n| No new lint warnings or errors in files you change | Keeps the codebase healthy. |\n| Contributions licensed under the repository's license | Standard open-source contribution terms. |\n\nTradingSpy is licensed under the PolyForm Noncommercial License 1.0.0. Non-commercial use is allowed; commercial use requires separate permission from the copyright holder. See [LICENSE](/mrhustlex/TradingSpy-TradingAgentService/blob/main/LICENSE).\n\nTradingSpy is experimental software. It is not investment advice, a trading signal service, or a guarantee of performance. You are responsible for reviewing all generated code, assumptions, data quality, and results.", "url": "https://wpnews.pro/news/i-built-tradingspy-local-privacy-first-ai-trading-assistant-first-open-source", "canonical_source": "https://github.com/mrhustlex/TradingSpy-TradingAgentService", "published_at": "2026-07-11 20:45:06+00:00", "updated_at": "2026-07-11 21:05:54.592008+00:00", "lang": "en", "topics": ["ai-tools", "ai-agents"], "entities": ["TradingSpy", "Google AI Studio", "Mistral", "OpenRouter", "NVIDIA", "LiteLLM", "Ollama", "AWS Bedrock"], "alternates": {"html": "https://wpnews.pro/news/i-built-tradingspy-local-privacy-first-ai-trading-assistant-first-open-source", "markdown": "https://wpnews.pro/news/i-built-tradingspy-local-privacy-first-ai-trading-assistant-first-open-source.md", "text": "https://wpnews.pro/news/i-built-tradingspy-local-privacy-first-ai-trading-assistant-first-open-source.txt", "jsonld": "https://wpnews.pro/news/i-built-tradingspy-local-privacy-first-ai-trading-assistant-first-open-source.jsonld"}}