I saw and reviewed many python backtesting libraries - pyalgotrade, zipline, catalyst, backtrader, etc.

It seems that none of the provide a straightforward way to perform "Tick-based or Multi-timeframe backtesting on CRYPTO".

  • pyalgotrade seems to be only close-based.
  • zipline is for stocks.
  • catalyst (a fork of zipline) can simulate ticks with 1min closes, but their data provider for data ingestion is down.
  • backtrader seems to be only close-based.

What I want to achieve

I want to perform backtests such that:

  1. Indicators being calculated with daily timeframe data.
  2. Main loop progress with tick-based data or at least like zipline (with closes of a shorter timeframe, like 1min).

And I need feature two for the following:

  • being able to simulate stop-losses, i.e. within candle body or shadows - not only in candle close.
  • being able to backtest intra-bar strategies, so it could simulate entry and exits within body of a single bar.

Thanks in advance.

  • 1
    $\begingroup$ If you're going to do it properly, you should really really build your own backtesting platform. You probably have a bunch of custom ideas that aren't going to be backtest-able in a preexisting platform. $\endgroup$
    – Jase
    Jun 27, 2021 at 11:12

3 Answers 3


backtrader's Data Replay feature, does exactly what I was looking for. So, all you need to do is the following:

  1. Create a CSV data file with 1min timeframe.
  2. Load the data into a CSV data feed of backtrader.
  3. Pass the data feed to cerebro (backtrader's engine) with replaydata utility.
  4. Finally, add a strategy and other steps.

A code example to use replaydata is like the following:


Have you tried using ccxt? This library is available on GitHub and offers most of what you’re looking for. It offers minutely candle data from several dozen exchanges as well as a backtesting framework which implements indicators really well. I’m not sure if they offer intra-candle strategies but their features support what you’re looking for otherwise.

  • $\begingroup$ Didn't know that ccxt is able to backtest. Will check it and respond here later. Thanks. $\endgroup$
    – Amin Saqi
    Feb 3, 2021 at 13:29
  • $\begingroup$ Has this library answered the question? If so please feel free to accept the answer but if not, let us know what the shortcomings of it were. $\endgroup$ Feb 3, 2021 at 19:48
  • $\begingroup$ As I guessed before, ccxt does not offer ANY of what I'm looking for - It's just an exchange integration library, however a good one, maybe the best. $\endgroup$
    – Amin Saqi
    Feb 5, 2021 at 20:18

I have been looking for it also, and I don't think anything is able to do that. I personally re-built some backtrading program, and I think it's pretty straightforward to do especially with Pandas' ability to resample data by time and build candles from it. https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.resample.html

You have 2 set of data:

  • The ticks/trades, over which you look in real time to compute your balance, stop loss, take profit etc. Could be 1 minute candles also (and you use the "close" data as the tick, or could be live ticks).
  • The candles on which you build your indicators etc, that you can also build on-the-go as you loop over your ticks-trades. Personally, I pre-build the candles with pandas so I can "verify" that the live-built data from the trades matches exactly. And I also use the pre-computed candles to know at which time I should recompute the indicators (because when you loop over all the ticks/trades, you won't recompute the indicators every time, you have to wait for the candle to be completely built)

As for getting the data... You can get pretty good 1 minute candles (200 days) from Binance, or full trade history from Kraken from the API. Those are free and easy to get, maybe there are other ones.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.