Mathematics of Investing
This post deals with investment and finance, applying practical mathematics and physics to financial markets. I also provide a program written in Python that performs an analysis of a portfolio of assets and finds the best selection available.
I present an investment strategy that I use myself and that is superior to the majority of competing strategies available through banks and financial institutions in Germany.
This article is about the application of mathematical ideas to financial markets. First, I introduce the basic idea of “money” and relate this idea to value. Then, I talk about different classes of investments and how they are relevant to investments. I introduce a program written in Python that analyzes a given portfolio of assets and finds distributions that are optimal based on the Portfolio Theory of [Harry Markowitz](https://en.wikipedia.org/wiki/Harry_Markowitz">.
I conclude with a specific strategy introduced by Yale University's Chief Investment Officer David Swensen that turned out to be superior to the majority of other funds and investment strategies available through banks and financial institutions in Germany.
What is Money?
The answer is both simple, yet also involved. Money is a means for trading/exchanging goods and does not generate value by itself. In former times the value of money was thus closely related to physical goods itself. In such a case the total amount of money available to the economy was bound by the physical resources. A famous example is the gold standard, which directly related the money in circulation to the amount of physical gold stored in government vaults.
The problem with that definition: The total amount of money is equal to the amount of gold available, which is not at all related to the goods available or the value generated! Today, in most economies the gold standard is abolished and replaced by currencies free-floating in value. This means that, essentially, a monetary unit is an arbitrary value assigned by the free market itself. The market will decide what the value of the goods and services is and thus define the value of the currency.
Markets and Information
A key concept is the notion of efficient markets. In an efficient market it is impossible for an investor to make an immediate risk-free profit. If such a possibility did exist, an investor would realize the profit, closing this option for other investors. If all investors have equivalent information and act rationally, then such a loophole would not even come to existence in the first place.
Are markets in reality “efficient” or do they allow for such loopholes? In reality, for large markets small loopholes may exist, but they are typically inaccessible to smaller investors. For smaller markets it may be different and a skilled investor can indeed make an above-average profit if she has more information than other participants. To benefit from such a loophole one needs to invest the time and effort in detecting and exploiting it — this, in turn, attaches a “price-tag” to the market knowledge, which means that the market might well be theoretically efficient if the value of the exclusive information is taken into account.
Value of Money and Goods
Without the gold standard, how can we find the “total amount” of money in circulation? It might be the total amount of cash in circulation. This does not include the value in bank accounts, real estate property or knowledge and services. Thus, an extended definition might also include the total amount of the book currency in real estate, bank accounts, and other assets.
But it gets worse: For companies traded in stock markets one could also multiply the current value of a single stock with the total number of stocks in circulation. Interestingly, the latter definition exceeds the total amount of book money by a factor of 10. For a discussion of how the problem is solved in practice, refer to this article on money supply.
The subject that deals with the relation of money and goods is called Microeconomics. Microeconomics gives specific rules and guides of how goods are valued and priced in a free market, again assuming the markets are efficient. A good and thorough introduction to this field is available through the MIT OpenCourseWare, see the at the end of this article.
Net-worth of a company
So how do we find the value of goods we are interested in as investors: the net-worth of a company? Since this article is about investing and businesses are a predominant option for investments, we need to figure out how much money a share is worth.
The naïve definition of multiplying the stock value by the total number of stocks exceeds the available money by far. One alternative might be to count the money required to buy all stocks. This is called the “market value”. However, part of the stocks may not be available on the free market which makes this definition problematic. Another practical definition is the sum of all assets minus liabilities (“book value”).
In reality, the market will set a price in monetary units for the shares of a company. Obviously, this does not reflect the absolute, total value, but rather the value that other people are currently willing to trade shares for. If we assume that the shares are traded on an efficient market, the value will represent all information that investors have about the company at this point in time.
The important point is: If that value changes relative to the market defined by the entire economy, then the company will be doing better or worse than the entire economy, respectively!
How do we know about this relative value change? Clearly, such a change would require additional information that is unavailable in an efficient market: If the market is efficient, then we cannot know it in advance! If the market is not efficient, then the additional knowledge an investor may have will have a price-tag equivalent to the gain she can make by her information!
Types of Investments
Now we discuss the question: Where does a business get money for investments from?
One option is to invest only their own profits. Often, that is the preferred option. Sometimes, though, a business may want to start a new activity, grow faster or simply need additional resources on a short notice. Then there are two options: They can lend money at a fixed rate or they can invite investors to share both part of the risk and future profits. These two options correspond to corporate bonds and corporate stocks and will be introduced in the following.
An investor borrows money and expects a fixed interest in return and to get paid back eventually. If the company goes bankrupt, the investor still has a right to get her share of the companies' remaining assets. Of course, in the worst case there is a certain risk that the investor doesn’t get his money back, so the likelihood of the company going out of business will have an effect on the interest she expects to get. A measure for this likelihood is the credit rating. The better a credit rating, the lower the risk and the lower the interest one has to pay for loan.
In this case the investor gets to own a part (her “share”) of a business. She is thus entitled to get a part of the annual profits (“dividends”), depending on how well the year went. In case the business fails, she will get nothing in return as she is the owner. Thus, the risk for a stock investor is higher than for a bond investor.
So why should people invest in stocks? The only reason is the expectation of higher profits. The expected profit from the dividend must exceed the interest rates from the bond investment; this will influence the price investors are willing to pay for shares and thus determine the stock value of companies in the market. The stock price thus represents the sum of the (expected) future returns plus a premium for the higher risk that a business may do badly/worse than expected in the future.
Markowitz Portfolio Theory
Different investments have different risks. As we have seen above, investors would only invest with higher risk if they are offered higher profits in return. Risks have different origins — for shareholders it is both the general economy and the business’s performance, for real-estate risks include regional development and natural disasters and for government bonds one risk is inflation.
Key strategy: Diversification
Some of these risks are uncorrelated. For example, even if the regional development is well and inflation is under control, the economy may be experiencing problems. That leads to the crucial insight: Investing in a diversity of assets can reduce the total portfolio risk!
Mathematically, this can happen even by adding assets with higher individual risks, as long as they are uncorrelated or even anti-correlated. As an example, consider two fictional assets with the following risks and expected returns:
|Name||Volatility (in %)||Expected return (in % p.a.)|
The specific numbers have been generated from these historical time series:
From the table it is evident that asset “NuAS” promises a higher return, but also has a higher risk, whereas “Pear” is a little safer, but also does not promise the same returns. If we compute the total portfolio risk and expected return for possible mixing of the two assets we get the following diagram:
When looking at portfolios consisting of both assets, we find that mixing both stocks can produce a portfolio with lower overall risk than each asset would have on their own; the total return of such a “minimum variance” portfolio – mixing 23% of “NuAS” and 77% of “Pear” stocks – is even higher than if had merely used the “safer” choice without adding the “riskier” asset!
This finding is the core idea of Modern Portfolio Theory: Diversification in several, uncorrelated assets leads to a reduced risk without diminishing the expected returns!
Note that the computation of the volatility and the expected return from the history of prices is not actually correct. The statistical method employed assumes that the data has a Gaussian distribution which is not the case for most assets in the real world. Instead, one might rather used models based on system dynamics, neural networks and other means. The crucial insight, however, is unchanged: A diversified portfolio with multiple assets can have lower risk, even if it means adding assets with individually higher risk!
Diversification with Several Assets
The idea of diversification outlined above can easily be extended to more than two assets. We now repeat the calculation with a portfolio of four fictional assets whose time-series are shown here:
Again, we can repeat the analysis, although the space of possible portfolios is larger. A Monte-Carlo-analysis yields the following result:
Here, the portfolio with minimum variance consists of a mixture of only “G-Bonds” and “Real estate” — which means that as long as we are looking for a risk reduction, adding “NuAS” or “Pear” assets is not useful!
Now, the total return of the minimum-variance case may be a little too low and we can ask if we should not accept a slightly higher risk when we can get a higher return. If we decide that we want at least 6% annual returns, then the following portfolio is the best choice with minimum risk:
|Name||Contribution (in %)|
Thus, adding “Real estate” to the portfolio is no use as soon as we are looking for higher returns and we fare best with a mixture similar to the one we had before plus a small contribution from “G-Bonds”.
Investment Portfolio Analysis
For the calculations and diagrams in the article I have written a Python program and put it on github.com.
The test data from the above examples has been included in two example programs named
As I cannot include actual historical quotes for legal reasons, I had included a module that can retrieve data from the Yahoo Finance server. However, this code is now obsolete. In 2020 historical data is much harder to get by and most free resources have been shut down.
The portfolio introduced in the following can also be analyzed with the program, but I did not include the data. Please keep in mind that computing expected returns, volatilities and correlations based on Gaussian distributions is NOT sufficiently accurate for real-world data!
David Swensen Portfolio
This portfolio and the associated investment strategy has been introduced by Yale University’s Chief Investment Officer David Swensen in his book “Unconventional Success”. The basic proposal is a very natural extension of the ideas presented in the previous section.
One practical point is the hypothesis of efficient markets. Observation tells that this hypothesis is largely fulfilled for the large markets of developed countries. With these basic assumptions it follows that it is not possible (or at least not practical without considerable effort) to find an investment strategy that outperforms the markets. It follows that the best strategy is to construct a portfolio that induces minimal fees and diversifies among all assets in such a way that return is maximized and risk is minimized.
Swensen specifically proposed the following allocation:
|Asset class||Contribution (in %)|
|World-wide developed market stock||15|
|Bonds with fixed return||15|
One more ingredient is the idea to re-balance the portfolio if the asset distribution is shifted due to market performance. This idea is very natural: Assets performing well are sold, under-performers are bought. This is simply the idea of “buying cheap, selling expensive”.
A particular implementation of such a portfolio can be done with index-based Exchange-traded funds (ETFs) which have minimal fees associated with them.
This portfolio combines all aspects of successful diversification as outlined above — not only is diversification implemented over a variety of asset classes, but also regionally. The portfolio also hedges against hazards like inflation. On the other hand it also maintains a decent expected return and has proven its value in the recent financial crisis — it has consistently outperformed mutual funds and funds of funds that I had been offered by banks in the past.
I have defined the basic idea and concept of money. From this concept I have shown how money can be invested in an economy. Then I have introduced the basic ideas of Modern Portfolio Theory and given two practical examples with fictitious assets. Finally, I have shown how the lessons learned can be applied to a real-world investment portfolio introduced by the Yale University endowment manager, David Swensen. This portfolio has consistently outperformed the mutual funds and funds of funds offered by banks.
The ideas and lessons can be tested and applied with a Python program that I have posted on github.com.
References and Further Reading
Although the financial literature on the web is vast, many sites are driven by self-interest since they receive funding in return for advertisement of specific funds or investment strategies. Some sites are open about this, but others are not. The following is a collection of resources I have found useful:
- The MIT has published most of their courses and materials online; one of the basics relevant to finance is Principles of Microeconomics.
- The book “Unconventional Success: A Fundamental Approach to Personal Investment (2005)” by David Swensen, available on Amazon (US) and Amazon (Germany).
- An online course (in German) explaining the basics of Portfolio Theory in detail with several examples. In addition, it contains extensive literature suggestions.
- You can also watch a Guest Lecture by David Swensen in ECON 252:Financial Markets on the Open Yale Courses site.