Crypto Portfolio Optimization Part 3: Numerical Optimization

Crypto Portfolio Optimization Part 3: Numerical Optimization

In this article, we are going to use numerical optimization methods to perform crypto portfolio optimization.

Additional disclaimer: This is no investment advice or encouragement to buy Crypto. Please, do your own research before investing. This tutorial is only for educational purposes and therefore meant to explain simulation concepts using Python. Furthermore, all mentioned cryptocurrencies are just for illustrative purposes.

Portfolio Optimization

In the last article I was talking about Pareto optimization for crypto portfolio optimization. Therefore, we created a huge amount of different portfolios to find the efficient frontier of non-dominated portfolios. Furthermore, this is an expensive process regarding the computational costs.

In this article, we want to determine the portfolio with the minimum volatility or maximum Sharpe ratio without using Pareto optimization. Here, we are going to use numerical optimization to cut down the computational costs and therefore the demanded time.

Numerical Optimization

Mathematical optimization methods are used to find the “best” results (minimum or maximum) of an objective function within a defined domain. Here we use numerical methods to solve these mathematical problems.

In the following I want to state our optimization problem in mathematical terms. The standard deviation \sigma needs to be minimized by changing the weights w_i of the assets. Furthermore, we have the constraint, that the sum of the weight is equal to 1 (100 %) and every weight needs to be between 0 and 1 (0 – 100 %).

    \begin{equation*} \begin{aligned} & \underset{w_i}{\text{minimize}} && \sigma(w_1, \cdots , w_n) \\ & \text{constraints} && \sum\limits_{i=1}^n w_i - 1 = 0 \\ & \text{boundaries} && 0 \leq w_i \leq 1 \end{aligned} \end{equation*}

In Python we are going to use the Scipy library and in detail the optimization routines. Therefore, the Sequential Least Squares Programming (SSLSQP) method is used which is based on the Sequential Quadratic Programming (SQP) method.

Sharpe ratio

This time we are going to use another indicator called the Sharpe ratio. The Sharpe ratio is an indicator that calculates the risk adjusted return. It is calculated from the average return, risk-free return and the standard deviation of the return (volatility). While the Sortino ratio is just considering negative volatility, the Sharpe ratio is considering positive and negative volatility.

Using these indicators, we can try to examine the performance of an investment. Additionally, we can compare different portfolios with different asset allocations relatively to each other.

Here we assume, that the risk free rate is 0 %. This means there is no such thing as a risk free rate in the crypto space.

Assumptions for the Portfolio Simulation

  • The simulations are conducted on the 09.09.2018.
  • In the following we consider the exchange Binance.
  • We consider all prices in BTC.
  • The example portfolios consist of: XMR, VET, OMG, NEO. (For details have a look at CMC).
  • When using Pareto optimization we simulate 1000000 portfolios.


You can view and download the entire Python code in this Github repository.

Results Pareto optimization

First, let us have a look at the 1000000 portfolios and the pareto frontier (Using the method from this article). This massive amount of samples is taken, to map the parameter space as good as possible. Furthermore, the smoothness of the red line is an indicator for the right amount of samples.

The green circle marks the portfolio with a globally minimal volatility of 24.91 %, return of 7.34 % and Sharpe ratio of 0.295.

While the red circle the one with globally maximum Sharpe ratio of 0.731, return of 26.23 % and a volatility of 35.88 %.

This leads is to the portfolio allocations of all portfolios on the pareto frontier. This means, by mixing in VET the return increases, but the same time the volatility increases. But this can look very different in a different timeframe or in the future.

Results numerical optimization

Now, let us apply mathematical optimization and compare the results to the Pareto simulation.

First, let us have a look at the portfolio with the minimal volatility. It returns a portfolio of XMR: 86.88 %, VET: 0 %, OMG: 13.11 %, NEO: 0 %, which leads to an return of 7.18 % and a volatility of 24.91 %.

Furthermore, the result of the maximum Sharpe ratio. It returns a portfolio of XMR: 52.09 %, VET: 47.91 %, OMG: 0 %, NEO: 0 %, which leads to an return of 25.88 % and a volatility of 35.34 %.


  • You can use numerical optimization for crypto portfolio optimization.
  • Sometimes you do not want the entire Pareto frontier but just one specific portfolio e. g. min. volatility. Therefore, you can use numerical optimization.
  • The magnitude of the Pareto optimization results can be confirmed by numerical optimization methods.
  • The difference in numerical- and Pareto optimization can be based on the numerical tolerance of the optimizer. Furthermore, maybe not all possible portfolios are sampled
  • The final goal is to maximize return and minimize volatility.
  • You can use the Sharpe ratio to compare portfolios relative to each other.
  • Be careful, the results depend strongly on the input timeframe.
  • Legthening the timeframe lowers usually the volatility.
  • Past performance does not indicate future results.

What do you think?

I’d like to hear what you think about this post.

Let me know by leaving a comment below and don’t forget to subscribe to this blog!