Like many devs who double as market hobbyists, my weekends usually look like a chaotic mess of Jupyter notebooks, multiple stock data APIs, and half-broken custom scripts trying to backtest a simple idea.
A few months ago, I hit a wall. I realized I was writing more infrastructure plumbing than actual strategy code. When looking at commercial alternatives, I found they either cost a fortune, forced me into a proprietary cloud, or raised massive data privacy red flags regarding harvesting my strategy ideas.
So, I built my own ultimate sandbox: TradingSpy. It's a local-first AI trading research workstation running entirely in Docker, and I've just open-sourced it!
π Check out the repository: https://github.com/mrhustlex/TradingSpy-TradingAgentService
What exactly is TradingSpy?
It is not a trading bot and it does not connect to live brokerages to place trades. Instead, it's an end-to-end sandbox environment for strategy generation, market intelligence gathering, and automated backtesting.
The Core Tech Stack & Key Features
Loop-Engineering AI Agents π€
This is where it gets fun. Instead of just chatting with an LLM, you can assign it a self-correcting goal. For example: "Improve EMA_Trend for TQQQ until it beats the baseline buy-and-hold strategy." The agent will autonomously:
Write the Python code using Backtrader.
Run it through a syntax and runtime validation step.
Execute the backtest against historical candles.
Read the metricsβif it underperforms, it automatically iterates, tweaks the code, and tests again without you having to babysit the terminal.Multi-Provider & Local LLM Ready
Privacy was my #1 priority. You can hook it up to cloud providers like Google AI Studio or OpenRouter, or drop in Ollama (qwen2.5-coder, etc.) to run the entire operation completely offline on your local hardware.All-in-One Market Intelligence
No more context switching. It pulls real-time quotes, multi-period sector heatmaps, insider transactions, fundamentals, and even parses academic quantitative papers directly from arXiv into a single UI dashboard.Developer-First Design
The backend is built with FastAPI and features an OpenAI-compatible API layer (/v1/chat/completions). This means you can easily use TradingSpy as a headless engine to back your own custom automation scripts or external workflows.
Getting Started in 2 Minutes
As long as you have Docker installed, setting it up locally takes three commands:
git clone https://github.com/mrhustlex/TradingSpy-TradingAgentService.git
cd TradingSpy
cp .env.example .env
Pop your LLM keys in .env or configure them later in the UI!
docker compose up -d --build
Once up, your workspace is ready to go:
Frontend App: http://localhost:3000
Backend API Docs: http://localhost:8000/docs
Why I'm Sharing This
Right now, I am a solo developer building this purely because it was a tool I desperately needed for my own research. I'm opening it up to the open-source community because I think quantitative tools shouldn't be gated behind massive paywalls or privacy trade-offs.
Disclaimer: This is experimental software built strictly for educational research and coding exploration, not financial advice.
I'd love to hear your thoughts! What local models are you finding work best for Python code generation? What features or data sources should I add next? Drop a comment below or open an issue on GitHub! βοΈ
Top comments (0)