Disclaimer: This article was originally published January 20, 2018 on FreeCodeCamp. This is for informational purposes only. This is not financial advice.
The amount of engagement in the crypto investment space needs no introduction. With market caps, volumes, and public awareness on the rise, I thought I’d put together a simple Jupyter notebook to get a clearer and broader viewpoint into the investment activities within my own crypto portfolio.
TL;DR here’s the code ;)
Because we’re definitely missing important details about our investments by only looking at the total value of our (potentially fat) wallets — even though I enjoy looking at Blockfolio from time to time. Because seeing our Ripple go to the moon and overshadow the rest of our investments is likely increasing our financial risk substantially. Because we all want our money to grow, but achieving this by picking a diverse set of cryptos is easier and safer than picking a moonshot that could end up a dud (and make us broke).
And let’s face it, the market gains are just too big for us to be left in the dark on the true characteristics of our investment portfolios.
Now there are several characteristics of our portfolio that we should take a good look at, including return and risk. But a lot of the time we’re fixated on one and not the other.
We can look at return in several ways: the amount of money we’ve made from the beginning to the current date, the average rate of money we’ve made over specific time periods (e.g., annual returns), how much better our investments did when compared to several characteristics of a benchmark (e.g., alpha), and even the annual compound rate it would have taken to get to our current investment based on our starting point (i.e., CAGR).
As important, if not more, is how we look at risk and its effect on return. I don’t know about you, but I want to make sure I’m making a good return based on an amount of risk I feel comfortable with. If we take on a huge amount of risk to make one particular return when we could have taken much less risk to make that very same return, the path to take for a more efficient investment is clear.
This is where understanding volatility, correlations, and risk-adjusted returns come into play by computing statistics such as standard deviation of returns (or volatility), beta, the Sharpe ratio, and the Sortino ratio.
And while we can compute all the statistics under the sun to measure our portfolio’s performance, it doesn’t do much good if we don’t include a reference point to see how well we’re doing in comparison. This is called a benchmark, and we’ll be using the golden boy of cryptocurrencies: Bitcoin.
So I don’t want to display a bunch of code here because I think you should go through the notebook yourself and get a feel for things. Don’t be afraid, the notebook includes some clear explanations and the code is commented! It’ll also help in better understanding this post. If you want, clone the repo and give it a whirl first. However, I will show you results through some statistics and nice visualizations.
To start, we need to create a tradesheet that emulates how we invested our portfolio. The one below is included in the repo. These are actually the same cryptos I invested in and the times I bought and sold them up until now, but the amount of money and the allocations (i.e., the amount I bought and sold) are not.
Now we want to run a backtest on our investment strategy. Simply put, running a backtest allows us to go back in time to our first trade, walk forward in time, and simulate the trading activity that occurred in our portfolio up until today. A backtester can be very sophisticated and can be used in a lot of different scenarios (to the finance geeks: pun intended), but in our case it’s rather straightforward.
OK. Numbers are nice, but I want to see some charts.
Again, go ahead and clone the repo and play around a bit so you can understand in more detail how we went about analyzing our portfolio. You can even add your own tradesheet to get a glimpse into yours. And if you find bugs, let me know!
I hope you’ve gained a better appreciation for why it’s important to look at your portfolio through various lenses. It’s hard to get a clear understanding from just visualizing asset price movements, especially with all that’s been going on lately in the crypto space. Also, it’s not always clear how much risk we’re taking on over time, and how those risks will evolve when we invest.
What is clear is that diversification in such a market is important, because none of us knows where this market is going. With that in mind, best to keep an eye on your ship while weathering the storms and HODL.