cvxgrp / cvxportfolio

Portfolio optimization and back-testing.
https://www.cvxportfolio.com
Apache License 2.0
910 stars 242 forks source link

can we load into our custom crypto data into cvxportfolio for backtesting and portfolio construction ? [bounty possible] #153

Open blackivory opened 2 months ago

blackivory commented 2 months ago

also would want to load our own custom alpha factors & models to forecast returns and run simulation covariance can just be historical

can offer bounty if anyone can help to set this up :)

enzbus commented 3 weeks ago

Hi, yes of course you can use Cvxportfolio for any asset class, including crypto-currencies. If you have already returns dataframes I don't see any difference with what is shown in the examples with stocks or ETFs. Maybe you'll want to set cash_key='cash' in the cvx.UserProvidedMarketData initializer, since you probably can't collect USD risk free returns from an account on a crypto-currency exchange (with that shortkey you disable cash returns). You can do long-only portfolios, margined portfolios (using cvx.HoldingCost to model shorting fees and/or margin fees), and futures portfolios without any change. More complicated funding structures probably require custom cost objects. Other additions that may be useful could be a native cvx.data.SymbolData subclass to interface for example with binance API for their historical data, but I think Yahoo Finance in any case has historical returns for spot crypto-currencies, from Coinbase. In the future I plan to provide better infrastructure to run strategies online, now if you look in examples/strategies you'll see some not-so-clean code (that works, in any case). For high-frequency applications Cvxportfolio should work no problem, down to say a few seconds. I wouldn't recommend Cvxportfolio for super-high frequency trading, meaning sub-second, you'd probably want to use some custom C++ code for that.