2
$\begingroup$

What is a good python backtesting library to use if I want to test buying and selling a list of different cryptocurrencies every day? Most libraries I find like backtesting.py and pyalgotrade are event-drive based on signals from a single asset. I would like to test an algorithm that buys a list of different assets every day. Any suggestions?

$\endgroup$

1 Answer 1

3
+50
$\begingroup$

Take a look at Backtrader:

There is an extensive backtesting Python library called Backtrader (link to Github repository), which from the documentation, supports event-based strategies across multiple assets. Due to the core community behind it, the library frequently gets updated with additional functionality (it has a whopping 122 built-in indicators). I have provided a link to the documentation.

Other than that, I have found an example where they backtest the strategy of this paper, across a subset of stocks. As long as the asset universe is fixed, then it can rebalance across asset-dimension based on some conditions. In the example, the conditions for rebalancing are based on Buying and selling top- and bottom-ranked stocks respectively and setting a target order for top-ranked stocks.

This seems like the same setup you're requesting in your question. Though, it is hard to tell, when you haven't disclosed your strategy. Here are some more examples. You can determine whether any of them fit your own scenario.


Alternatively, you could try Zipline (link here), which is another backtesting Python library. In the end, if your strategy is too "complex" (in one way or another) it is best to code your own backtester, where you check your signals across asset dimension and through time. This is the same as rebalancing a portfolio of assets, based on some conditions relative to the asset- and time-dimension. I hope this provide some insight.

$\endgroup$
1
  • 1
    $\begingroup$ Thank you! This looks promising. My strategy is similar to paper you shared, but for cryptocurrencies. Will try to validate if it works for me, and if it does I will accept your answer. $\endgroup$
    – md1630
    Sep 14, 2021 at 18:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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