Stocks, Gold, Bitcoin - how much of each should you hold?

It is a well known fact that if you want to protect your savings, using cash is a bad idea. Most financial advisors would recommend you to invest in ETFs - financial indexes that track performance of stock market. The idea here is that one individual stock can go bust (e.g. Enron), but holding a little bit of everything allows your portfolio to grow when the market grows.

However, those financial advisors are not being strictly honest with you, as investing in commodities and cryptocurrencies (both deemed “risky” investments) can actually derisk your portfolio! Don’t believe me? Well, let’s see what math tells us about minimizing portfolio risk (minimize Expected Shortfall). Code is attached below.

We are going to look at three indexes: S&P500, Gold and Bitcoin courtesy of Yahoo Finance, and will construct a portfolio that minimizes your risk. Once again, I want to emphasize that we’re not optimizing for high risk high return (that’s holding 100% BTC). I’m talking about lowest risk idea, e.g. what your nocoiner pension fund and central bank should be doing if they have your best interests in mind.

Then, we’re going to feed data into our model and see how changing amount of data being fed into portfolio risk minimization strategy ends up changing recommended value allocation. Namely, we’ll start by feeding data from year 2011 onwards, and then we’ll reduce amount of stale information the model receives so it only focuses on recent performance (so year 2012 and onwards, then 2013 and onwards, etc.)

Ready to see results?

Year Cutoff Stocks Gold Bitcoin ETL (risk measure)
2011 79.78% 19.97% 0.25% 0.06329
2012 76.29% 20.88% 2.83% 0.05673
2013 81.76% 17.16% 1.07% 0.0548
2014 78.94% 20.66% 0.4% 0.05516
2015 74.13% 22.84% 3.02% 0.05262
2016 67.77% 21.59% 10.64% 0.05119
2017 59.33% 27.08% 13.59% 0.05068


If you have 0 Bitcoin you are being financially irresponsible.

# Usage: [1] save this as portfolio.R [2] `rscript portfolio.R`

# You need to install R and GLPK in order to run this code
# R:

# uncomment this line to install dependencies
# install.packages(c("PortfolioAnalytics", "ROI", "ROI.plugin.glpk", "quantmod"))


assets <- c(

# snp500
# gold
# bitcoin

# change to "2011/" for 2011 onwards, etc.
SPX <- monthlyReturn(GSPC["2013/"])
XAU <- monthlyReturn(XAU["2013/"])
BTC <- monthlyReturn(`BTC-USD`["2013/"])

returns <- data.frame(
  SPX = SPX$monthly.returns,
  XAU = XAU$monthly.returns,
  BTC = BTC$monthly.returns
colnames(returns) <- assets

pspec <- portfolio.spec(assets = assets)

# ensure that we allocate 100% of our portfolio
pspec <- add.constraint(
  portfolio = pspec,
  type = "weight_sum",
  min_sum = 1,
  max_sum = 1

# ensure that weights are 0 <= w <= 1, aka no shorts
pspec <- add.constraint(portfolio = pspec, type = "box")

pspec <- add.objective(
  portfolio = pspec,
  type = "risk",
  name = "ETL",
  arguments = list(p = 0.95)

optimized <- optimize.portfolio(
  R = returns,
  portfolio = pspec,
  optimize_method = "ROI",
  trace = TRUE



Reading this article makes me feel like we are going to release Decentralized ETF. Should be one of the next IDEO after Atomic Arbitrage. :slight_smile:

1 Like