New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Daily holdings and returns time series (backtest and live) #7416
Comments
It's worth also mentioning that metrics in |
in live - you won't be able to do this - as freqtrade wont have the historical data available. #3059 (and the corresponding issue #3020) aimed to do something similar (although poorly describing what it's actually for). you may also wanna read through the discussion in #4497 - while the title suggests otherwise - the discussion then turned towards "daily balance snapshots" at some point - which is what you'd need for live. I don't think your code works correctly though - assuming a 1d frequency - you'll have to make sure trades are replicated once per day (assuming a can be open 4-5 days, it'll have to be counted on each of these days - which i currently don't really see after a quick skim). It's also definitely wrong when using the trade_adjust feature - where the same trade could be a 100$ stake one day, 1000$ stake the next day, and reduce to 500$the 3rd day - so your holdings will have to be calculated differently for each day (which will make this rather complex to calculate) - otherwise you're double-counting (or not counting) parts of your wallet. |
Thanks for the resources. I will see if I have some capacity to build + share something like this. I'll probably start with backtesting as the usecase would primarily be to drive analytics. But please let me know if you (and/or others) agree that this functionality would even be useful / worth having. For example, in a (once) popular backtesting framework called backtrader, the resulting frames of the result analyzer can be imported straight into Pyfolio or Quantstats: https://github.com/mementum/backtrader/blob/master/backtrader/analyzers/pyfolio.py Quick q: for backtesting, is there any way to see the portfolio's outstanding cash balance, or does it have to be reverse engineered after the fact by the trades table? On the code, I think the resample + ffill lines in the code do the first thing you're worried about. I agree that I didn't consider |
well - in your strategy, you can use the |
Describe your environment
(if applicable)
python -V
)pip freeze | grep ccxt
)freqtrade -V
ordocker-compose run --rm freqtrade -V
for Freqtrade running in docker)Describe the enhancement
I would be interested in examining daily (/ custom frequency) timeseries of holdings and returns. E.g., what is a snapshot of my holdings and the total value of my holdings + cash (e.g., NAV) at the end of each trading day.
I've not discovered this functionality in the current repo - the closest thing I found is the
daily_profit
series in backtesting, which, while helpful, only tabulates profit on closed trades, and isn't great for lower frequency strategies (since profit is 0 if a position is open). If the functionality is there and I've overlooked, please let me know.Holdings and returns can either be (1) calculated at each iteration during runtime or (2) derived from an (existing) combination of trades and price data, and would be a useful tool for determining portfolio analytics, as well as allow future integrations with tools such as Pyfolio, Quantstats, and potentially many others.
Thoughts are appreciated - thanks.
The text was updated successfully, but these errors were encountered: