Every developer who has tinkered with pairs trading knows the pattern: a promising notebook, too many glue scripts, and a graveyard of half-finished backtests. At AI Tech Inspire, we spotted a project that tries to turn that spaghetti into a runnable system. It’s called HedgeVision, and it aims to package a full statistical arbitrage workflow—from cointegration discovery to paper trading—into a local-first, developer-friendly stack.


At a glance: key facts

  • Open-source full-stack statistical arbitrage platform: HedgeVision (GitHub).
  • Cointegration-based pairs discovery using Engle–Granger and Johansen tests.
  • Backtesting engine with configurable lookback windows and z-score thresholds.
  • Paper trading simulation with realistic order execution.
  • Backend: FastAPI; Frontend: React/Vite dashboard with live analytics.
  • Local-first: uses SQLite by default; no external services required.
  • Supports Supabase/PostgreSQL for production scaling.
  • LLM integration for market intelligence (Ollama, OpenAI, Anthropic).
  • CLI tooling and MCP server for automation and orchestration.
  • Containerized deployment via Docker and docker-compose.
  • Stack: Python 3.10+, FastAPI, React, TypeScript, SQLite/PostgreSQL, Docker.
  • Positioned as the first public piece of a larger autonomous trading system.
  • Actively seeking technical feedback on the strategy and architecture.

Why this is compelling for engineers

Many open-source trading repos focus on one slice of the problem: a nifty strategy script, or a sleek dashboard, or a framework you still need to wire. HedgeVision goes for an end-to-end approach. It’s local-first, which means you can clone the repo, run it with SQLite, and start experimenting without signing up for a dozen services. That’s a relief for researchers who value reproducibility and for practitioners navigating compliance-sensitive environments.

The FastAPI-based backend and a React/Vite dashboard are a familiar combo for modern Python/TypeScript teams. If you’ve deployed microservices or internal tools, the architecture will feel approachable. Add Docker on top for packaging, and you have a clean path from laptop to server.

Inside the stat-arb engine

HedgeVision centers on pairs trading via cointegration—looking for asset pairs whose price series move together in a statistically stable way. The platform supports both Engle–Granger and Johansen tests, which is notable:

  • Engle–Granger: Good for testing pairwise cointegration; straightforward and fast.
  • Johansen: Useful for testing multiple time series and identifying the number of cointegrating relationships.

Developers often ask which test to use. Engle–Granger is a practical starting point when scanning pairs. Johansen adds power when you want to consider small baskets or validate robustness. Either way, the real friction tends to be operational: automating scans on rolling windows, storing results, and surfacing candidates in a dashboard. That’s the niche HedgeVision appears to fill.

Key takeaway: Signal quality isn’t just about the math—it’s about turning the math into a reliable, repeatable pipeline.

Backtesting knobs that matter

The backtester exposes configurable lookback windows and z-score thresholds. Those two parameters alone can make or break a pairs strategy:

  • Lookback: Too short and you overfit to noise; too long and you react late to regime shifts.
  • Z-score thresholds: These control entry/exit sensitivity. Tighter bands increase trade frequency (and slippage risk). Wider bands reduce churn but may miss opportunities.

For practical evaluation, consider:

  • Walk-forward analysis to reduce look-ahead bias.
  • Multiple testing controls when scanning thousands of pairs.
  • Stress tests across volatility regimes (e.g., pre/post major macro events).

If you’ve used libraries in the PyTorch or TensorFlow ecosystem for modeling, think of HedgeVision as playing a different role: not a deep learning workbench, but a market microstructure sandbox where the target is execution-ready logic and operational reliability.

Paper trading and execution realism

Backtests can look pristine until they meet the messiness of the order book. HedgeVision’s paper trading mode simulates execution with more realistic assumptions—an underappreciated step for stat-arb. If you test a mean-reversion edge that lives on thin spreads, slippage and latency assumptions can erase the edge quickly.

A practical workflow many teams adopt:

  • Discover pairs via Engle–Granger on a rolling window.
  • Backtest with conservative z-score thresholds and transaction costs.
  • Run paper trading for at least one full volatility cycle.
  • Only then, graduate a handful of pairs to live tests with tiny sizing.

LLMs in the loop (carefully)

There’s optional LLM integration for “market intelligence,” including Ollama, OpenAI, and Anthropic. The obvious use cases: summarizing earnings transcripts, turning news into structured tags, or generating watchlists. If you lean on GPT for research workflows, a local Ollama setup can help with privacy and cost control. For teams already living in the Hugging Face ecosystem, it’s natural to imagine plugging in domain-tuned models, though that isn’t a built-in feature.

That said, stat-arb signals are traditionally price- and microstructure-driven. Treat LLMs as an overlay—contextual triage, not the trade trigger—unless you can quantify exactly how the intelligence translates into risk-adjusted returns.

Local-first now, scalable later

The local-first posture—SQLite default, zero external services—makes iteration fast. When it’s time to scale, support for Supabase/PostgreSQL offers a path to multi-user analytics, longer histories, and better concurrency. This two-lane approach mirrors how many internal quant tools evolve: a tight loop on a laptop, then a careful step to a managed DB once the workflow earns its keep.

On the serving side, a FastAPI backend is a solid choice for async I/O and typed endpoints, and a React/Vite frontend keeps the dashboard snappy. Docker and docker-compose round out a developer-friendly deployment story—great for spinning up reproducible environments or sharing a baseline stack with collaborators.

Automation hooks: CLI and MCP

HedgeVision includes CLI tooling and an MCP server for automation. Think scheduled scans, periodic backtests, and notifications when spreads breach thresholds. For teams standardizing on chatops or agent-driven ops, MCP is a welcome integration point. Pair that with a simple cron and you’ve got a hands-off nightly workflow.

Getting started (quick sketch)

Expect something along these lines:

  • Clone the repo and bring it up locally: docker compose up --build
  • Explore the API: http://localhost:8000/docs (if served via FastAPI’s OpenAPI UI)
  • Open the dashboard, load a watchlist, and run a discovery scan.
  • Tweak lookback/z-score and re-run backtests; promote candidates to paper trading.

Small tip: keep a config.json checkpoint of each experiment. Version it with Git. When a promising configuration emerges, tag it. Reproducibility beats memory every time. And if a run goes sideways, Ctrl+C is your friend.

What to watch out for

  • Data quality: Stat-arb edges are sensitive to stale ticks, dividend adjustments, and corporate actions.
  • Multiple comparisons: Scanning thousands of pairs inflates false positives—apply corrections or out-of-sample checks.
  • Regime changes: Cointegration can break; consider rolling recalibration and kill switches.
  • Costs and frictions: Include fees, borrow costs, and execution latencies in simulations.

Why it matters

For developers and engineers, HedgeVision isn’t just another strategy demo; it’s a workflow scaffold. It supplies the baselines—testing, simulation, orchestration, and a UI—so you can focus on research and controls. Even if your endgame isn’t pairs trading, the architectural choices (local-first defaults, typed APIs, containerized deploys) are a useful pattern for any data-driven trading or analytics tool.

“Build small, test locally, automate thoughtfully, and only then scale.” It’s a playbook that ages well.

Questions worth exploring next:

  • How robust are the results across asset classes (equities, ETFs, crypto, futures)?
  • What’s the win-rate vs. average PnL per trade for conservative vs. aggressive thresholds?
  • Can the LLM overlay catch structural breaks faster via news or filings analysis?
  • How do execution assumptions compare to your actual brokerage fills?

HedgeVision is open-source and actively seeking technical feedback. For teams considering a stat-arb stack—or anyone who wants a clean, local-first research harness—it’s worth a spin. The repo is here: github.com/ayush108108/hedgevision. As always, none of this is financial advice; treat it as a lab for testing ideas responsibly. If you do put it through its paces, share findings—engineers learn fastest from concrete, reproducible experiments.

Recommended Resources

As an Amazon Associate, I earn from qualifying purchases.