Crypto Portfolio Optimization using Python

Omkar Dash
3 min readJan 21, 2018

--

In the last post, I had provided an overview of Modern Portfolio theory.

The goal is to determine the optimal allocation of investments dollars over 14 large cap crypto-assets (market cap > USD 5B), based on price data from last 180 days.

In this post, I will go into the details of implementation of the portfolio optimization strategy, which on paper yields 406% returns over a 180 days period (and Sharpe ratio of 4.69).

Data Acquisition is the obvious first step - I’ve used Coincap.io API for data acquisition purposes. (I have tried CoinMarketCap and CryptoCompare previously, but I find Coincap’s API to be better for acquiring historical data.)

I’m focussed on cryptos with large market cap — greater than USD 5 Billion. In the second data acquisition step, I extract historical data (180 days) from another Coincap API, and hold the data in a master dataframe.

Once I have the historical data for the selected coins in a dataframe, the data needs to be cleaned & transformed. Returns and covariance are then calculated.

After the returns & covariance are calculated, I implement the core of MPT to optimize the portfolio.

Visualization of Efficient frontier :

The goal of this portfolio optimization technique was to find the portfolio that maximizes return and minimizes volatility, which is measured as Sharpe ratio. The weights of the coins, with highest sharpe ratio is below:

In summary, allocating investments in a manner below is the most optimized portfolio — 406% returns

Assumptions of MPT

• Asset returns are normally distributed random variables.
• Investors attempt to maximize economic market returns.
• Investors are rational and avoid risk when possible.
• Investors all have access to the same sources of information for investment decisions.
• Investors share similar views on expected returns.
• Taxes and brokerage commissions are not considered.
• Investors are not large enough players in the market to influence the price.
• Investors have unlimited access to borrow (and lend) money at the risk free rate.

Crypto markets are extremely volatile. Please do your own research & invest at your own risk. All the views expressed in this post are my own and do not represent my current or past employers.

The post should not be construed as financial advise.

Python Notebook :

--

--