Back to the red bull cans

Co-built with Ashutosh Pradhan and a TermiX colleague

XQuant

Describe a trading strategy in plain English. AI builds it and tests it on real data.

ShelvedSep 2025

Video in the works

XQuant

The real demo from September 2025, losses included.

About the project

Describe a crypto trading strategy in a chat. An AI agent turns it into rules and code, then tests how it would have done on real past prices from Binance.

XQuant lets you describe a crypto trading strategy in plain English. An AI agent turns it into rules, writes the code, and backtests it on real Binance data, asking your permission before each step.

I built it with Ashutosh Pradhan and a TermiX colleague, starting from a Chinese codebase that I translated. The whole flow worked in the demo. The strategies didn't: they lost money, and we stopped.

How it works

  1. Describe

    Chat about the strategy you want.

  2. Approve each step

    Every tool call waits for you: create rules, generate code, backtest, analyse the market, save.

  3. Rules, then code

    The AI fills a strict strategy format, then writes code from it.

  4. Backtest

    On real Binance candles, fetched in pages and retried on rate limits.

  5. Read the result

    Trades, return and drawdown on the analysis screen.

Under the hood

Backend
Node.js and Express, Prisma on Postgres, models through OpenRouter.
Frontend
React with Ant Design and Recharts.
Market data
The Binance API.

What I did

  • A tool-calling chat agent that runs up to 6 rounds, where every tool call waits for the user to approve it
  • Five tools: create the strategy rules, generate code, run a backtest, analyse market data, save the strategy
  • A strict schema so the AI always returns the same strategy format
  • Replaced mock data with real Binance candles, paged and retried on rate limits
  • Extended the backtest engine with price sources, volume, arithmetic in rules and breakout operators
  • Saved backtests in the database, with REST routes to run and fetch results
  • The backtest analysis screen and the chat screen with the approval modal
  • Translated the original Chinese codebase into English

What was new

  • A human-in-the-loop agent: no tool runs without approval
  • A two-step pipeline from plain language to rules to code, with fallbacks when no API key is set
  • AI-made strategies often barely trade, and loosening them doesn't make them profitable

Problems I hit, and how I fixed them

  1. The user's message was sent to the AI twice.

    Fix Check history before adding it.

  2. Backtests were running on mock data, and asking for ETH loaded BTC.

    Fix A real Binance data fetcher with paging and retries.

  3. AI-generated strategies stacked so many conditions that they made zero trades.

    Fix A relaxer that loosens the rules. In hindsight it changes the user's strategy before testing, which I would do differently.

  4. Saving a strategy crashed on a wrong field name.

    Fix Renamed the field.

  5. The strategies lost money: -8.8% and -7.5% in the demo, and the AI called one "profitable" before testing it.

    Fix Not fixed. We stopped.

Screenshots

Screenshots in the works

Real screens from XQuant go here.