A practical guide on optimal asset allocation

Antoine Soetewey 2020-01-07 3 minute read

A Shiny app with an example of optimal asset allocation


In his book A Random Walk down Wall Street, Burton G. Malkiel advises readers of an optimal asset allocation depending on age. As an amateur investor, I thought it would be useful to develop a Shiny app which depicts his advice for other interested investors. Here is the link to the app:

How to use this app?

  1. Open the app via this link
  2. Set your age under How old are you?
  3. Indicate how much you are willing to invest

On the right panel (or below depending on the size of your screen) you will see a table and a barplot. The table includes:

  • the different type of assets which represent the different allocations
  • the most common tickers for each type of asset
  • the optimal percentage for each asset
  • the optimal amount for each asset

In the table, the optimal percentage depends on your age (the older you are, the more conservative your portfolio), while the optimal amount depends on your age and the amount you are willing to invest.

The barplot displays the optimal weight (so the optimal percentage of your portfolio) for each type of asset: stocks, bonds, real estate and cash. This is just a visualization of the column “Optimal percentage” displayed in the table above.

It is also possible to compare your portfolio with the optimal portfolio, as recommended by the author. For this comparison, click on the tab “Compare with your portfolio” above How old are you?. In this tab:

  1. Again, indicate your age
  2. Then indicate your portfolio’s value for each asset (if you do not own a specific asset, leave it equal to 0)

On the right panel (or below depending on the size of your screen) you will see your portfolio’s total amount and a barplot comparing your portfolio and the optimal portfolio according to your age. This visualization will instantly give you a clear overview of what type of asset is overrepresented and underrepresented in your current portfolio compared the the optimal one. This will allow you to easily see how to rebalance your assets in accordance to what the author suggests.


Here is the entire code (or see the last version on GitHub) in case you would like to enhance it.

Note that the link may not work if the app has hit the monthly usage limit. Try again later if that is the case.

Disclosure: Note that this practical guide on asset allocation is based on the book A Random Walk down Wall Street by Burton G. Malkiel. This application does not include investment advice or recommendations, nor a financial analysis. This application is intended for information only and you invest at your own risks. I cannot be held liable for any decision made based on the information contained in this application, nor for its use by third parties.


Thanks for reading.

I hope you will find this app useful to quickly replicate the optimal asset allocation suggested by Burton G. Malkiel in his book A Random Walk down Wall Street. If you want to have more information about this investment strategy, I suggest reading his book.

As always, if you have a question or a suggestion related to the topic covered in this article, please add it as a comment so other readers can benefit from the discussion.

Liked this post?

  • Get updates every time a new article is published (no spam and unsubscribe anytime):

  • Support the blog
  • Share on: