Nov 25, 2026
•
Insights

We Re-Ran a CoinQuant Bitcoin Backtest in Python, Trade by Trade

We Re-Ran a CoinQuant Bitcoin Backtest in Python, Trade by Trade

We re-coded one CoinQuant Bitcoin rule in Python from Binance daily closes, with fills at the daily close and the same 0.1% fee, and compared every trade from 1 Aug 2021 to 1 Nov 2026. 25 of the 25 trades matched on entry and exit days, and CoinQuant's 124.63% return differed from the re-run by 0.05 percentage points.

Python backtest vs AI backtest is a fair question: if an AI builds and tests a rule for you, would your own code agree? For this rule, it did. The re-run ended at $22,458.04 against CoinQuant's $22,462.83, and every entry and exit landed on the same day.

The rule also beat holding Bitcoin on the same window, 124.63% against 96.23%. This article shows the rule, the data, how we coded it, every trade next to each other and the small places the two differed. It reports the results without adjustment.

The answer first: how many trades matched

All 25 trades matched on their entry day and exit day. On 17 of the 25, the prices and fees matched too. On the other eight, one or both fill prices differed by between one cent and $6.33.

  • Trades: 25 in CoinQuant, 25 in Python, the same days.
  • Return: 124.63% in CoinQuant, 124.58% in Python.
  • Final balance: $22,462.83 in CoinQuant, $22,458.04 in Python.

If you have checked a backtest before by adding up its trade log, this goes one step further: it rebuilds the trades themselves from exchange data. For the simpler check, see how to rebuild the return from the trade log.

The rule and the data (Binance closes, UTC days)

The rule, as typed into CoinQuant in plain English:

Enter long when the daily close crosses above the 200-day simple moving average of the close. Exit when the daily close crosses below the 200-day simple moving average. BTCUSDT spot on Binance, 1d candles, from 2021-08-01 to 2026-11-01, $10,000 starting capital, all equity in each trade, one position at a time, 0.1% fee per order.

The Python side used Binance BTCUSDT daily candles from the public Binance API, closed candles only, each day running 00:00 to 24:00 UTC. CoinQuant's data comes from Kaiko via CoinQuant.

Both sides fill at the daily close. In CoinQuant's trade log, a row stamped 9 Aug 2021 00:00 was filled at the close of 9 Aug 2021 UTC.

MetricSMA 200 ruleBTC Spot Comparison
StrategyBTC SMA 200 Close Cross 1D Aug 2021-Nov 2026BTC Buy and Hold 1D Aug 2021-Nov 2026
Total Return124.63%96.23%
Final Balance$22,462.83$19,622.82
Total Trades251
Win Rate24.00%n/a (single hold)
Profit Factor2.57n/a
Sharpe Ratio0.610.51
Max Drawdown36.13%76.63%
Total Fees$734.36$29.63

Both runs share the same window, capital, sizing and fee. With 25 trades, the results card marks the rule "Statistically inconclusive": 25 trades, and it needs 50+ to rate.

Python backtest vs AI backtest: how we coded it, standard Python only

The re-run is one short script of about 70 lines, using only the Python standard library: no backtesting framework and no pandas. It does five things.

  1. Load closes: download BTCUSDT daily candles from the Binance API, starting in December 2020 so the 200-day average is ready by 1 Aug 2021.
  2. Average: compute the 200-day simple moving average of the close for each day.
  3. Signal: enter when the previous day's close was at or below its average and that day's close is above it; exit on the reverse.
  4. Fill and fee: fill at that day's close, put all equity into the trade and charge 0.1% on the entry and on the exit.
  5. Close out and compare: close any open trade on 1 Nov 2026, then line up each trade with CoinQuant's saved orders.

That is the whole rule. Nothing in the script reads CoinQuant's signals: it only reads the saved orders at the end, to compare.

Trade by trade: dates, prices, fees

25 of 25 trades matched on entry and exit days

Every trade, as both sides recorded it:

No.Entry day (UTC)Exit day (UTC)Same daysSame prices and fees
12021-08-092021-08-12YesYes
22021-08-132021-08-17YesYes
32021-08-192021-09-10YesYes
42021-09-122021-09-13YesYes
52021-09-142021-09-20YesExit fill differs
62021-10-012021-12-13YesYes
72021-12-142021-12-17YesBoth fills differ
82021-12-212021-12-28YesEntry fill differs
92023-01-132023-08-17YesYes
102023-08-292023-08-30YesBoth fills differ
112023-10-162024-07-04YesExit fill differs
122024-07-132024-08-03YesYes
132024-08-232024-08-26YesExit fill differs
142024-09-242024-09-25YesYes
152024-09-262024-09-30YesYes
162024-10-142025-03-09YesExit fill differs
172025-03-122025-03-13YesYes
182025-03-142025-03-16YesYes
192025-03-192025-03-20YesYes
202025-03-232025-03-28YesYes
212025-04-222025-10-17YesYes
222025-10-192025-10-22YesEntry fill differs
232025-10-232025-10-30YesYes
242025-10-312025-11-03YesYes
252026-08-192026-11-01YesYes (end of test)

The last trade was still open on 1 Nov 2026, so both sides closed it at the end of the test.

The two orders of the earliest trade are on CoinQuant's Trades tab, where each trade is two rows.

Order rows 1 and 2 of BTC SMA 200 Close Cross 1D Aug 2021-Nov 2026 on CoinQuant: the buy on 9 August 2021 and the sell on 12 August 2021, with the price and size of each order, as the Python re-run reproduced them. Times are UTC.

Where they differed and why (warm-up, rounding, fee timing)

The eight trades that did not match exactly all had the same cause: a stored daily close that differs slightly from the Binance API close. Ten fills on those eight trades differ:

No.FillBinance API close (Python)CoinQuant fill
5Exit43,015.6243,016.63
7Entry48,343.2848,336.95
7Exit46,131.2046,133.83
8Entry48,889.8848,889.89
10Entry27,716.3427,716.35
10Exit27,299.9927,300.00
11Exit57,050.0157,050.02
13Exit62,834.0062,834.28
16Exit80,734.3780,734.31
22Entry108,642.78108,643.01

The largest gap was $6.33, on the entry of trade 7. Four of the ten were a single cent. None changed a signal, so none moved a trade to a different day.

  • Warm-up: no effect. Both sides used history before 1 Aug 2021 for the 200-day average, so both opened the first trade on 9 Aug 2021. For why a long lookback need not delay the first trade, see indicator warm-up periods.
  • Rounding: the price gaps above come from small data differences, not rule differences.
  • Fee timing: both charge 0.1% on each fill. Because each fee depends on the equity at the time, the price gaps carried into the fees by a few cents. For why fees and data decide whether a result is real, see backtesting data quality.

Net effect on the return: 0.05 percentage points.

The totals the re-run had to match: the Total Trades, Total Fees and Total Return rows of BTC SMA 200 Close Cross 1D Aug 2021-Nov 2026 in CoinQuant's Detailed Statistics.

AI agent backtesting vs coding it yourself

Coding it yourself gives full control and takes time: data download, signal logic, fills, fees and a check of every edge case. Our script is short because the rule is simple. A rule with stops, several indicators or a second timeframe would need far more code and testing.

Building it on CoinQuant took one plain-English description. The test above shows that, for this rule, the two approaches produce the same trades. For the wider comparison in words, see how AI agent backtesting compares to traditional backtesting. For coded research frameworks, see CoinQuant vs Backtrader and vectorized vs event-driven backtesting.

One test of one rule does not prove every result matches. It does show a way to check any result you plan to trust.

The Practical Lesson

  • Same days, every trade: 25 of 25 entries and exits landed on the same day in both.
  • Tiny price gaps: ten fills differed by one cent to $6.33, from the stored daily close.
  • Same answer: 124.63% against 124.58%, a gap of 0.05 percentage points.

If a result matters to you, re-run one rule yourself once. On CoinQuant, an AI trading platform, you can build the rule in plain English, read every order on the Trades tab and compare it with your own code.

Build trading strategies on real data. No coding required.

Frequently Asked Questions

How does ai agent backtesting compare to traditional backtesting methods?

In our test, an AI-built CoinQuant backtest and a hand-coded Python re-run of the same Bitcoin rule matched on all 25 trades' entry and exit days, from 1 Aug 2021 to 1 Nov 2026. The returns differed by 0.05 percentage points. The AI route took one plain-English description; the coded route took a script and a data download.

Can I verify a backtest in Python?

Yes. Download the same daily closes, code the entry and exit exactly as stored, fill at the same price and charge the same fee. Then compare each trade's entry and exit day, not just the final return.

Why would two backtests of the same rule give different results?

Small data differences, such as a stored close that differs from an exchange API close by a cent, change fills slightly. Bigger gaps usually come from a different warm-up, fill price or fee setting.

Re-run this rule yourself, or test your own on the same window.

Run this BTC SMA 200 Close Cross backtest on CoinQuant

Try it yourself

Have an idea worth testing?

Describe it in plain English. CoinQuant writes the rules and shows how it would have done on real prices.

Plans from $12.99 a week. Cancel anytime.

Disclaimer:

This content is for educational and informational purposes only and does not constitute financial, investment, or trading advice. All strategies and examples are for illustrative purposes and do not guarantee results. Always conduct your own research before making financial decisions.

Key Takeaway