field-theory.org
the blog of wolfram schroers

The Mathematics of Investing

This article is about 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.

The information in this article is for educational purposes only and does not constitute legal or financial advice. Under no circumstances shall the author be liable for any consequences that result from accessing, using, ignoring or following the information below!

Introduction
What is money?
Value of money
Types of investments
Markowitz portfolio theory
Summary

Introduction

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.

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.

Floating currency

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.

The question is if markets in reality are “efficient” or if they do 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

Money supply

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 measurables.

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.

Micro-Economics

The theory 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 literature 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 would be 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.

Bonds

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.

Stocks

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:

Characteristics of two fictional shares. (These are really entirely made-up and just serve illustrative purposes!)
NameVolatility (in %)Expected return (in % p.a.)
NuAS24.510.2
Pear11.64.0

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 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, (to the extend possible) 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 fully correct. The statistical method employed assume 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:

Minimum variance portfolio with expected return greater than 6% per year.
NameContribution (in %)
NuAS36
Pear59
G-Bonds5
Real estate0

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

The calculations and diagrams in the article have been produced using a program written in Python which is available under the GPLv3 from the software section on this site.

The test data from the above examples has been included in two example programs named `example1.py` and `example2.py`. As I cannot include actual historical quotes for legal reasons, I have included a module that can retrieve data from the Yahoo Finance server which allows users to write their own programs and optimize their own portfolio allocations.

The portfolio introduced in the following can also be analyzed with the program, but I did not include the data — if you want to do the analysis yourself, then you need to download and add the data yourself!

As the program is written in Python, it is not optimized for speed. I have included a version of the main library that can be compiled using Cython and will be a little faster; still, for complex portfolios, it is better to use an optimized, native version of the analysis code. Please contact me if you are interested in such a program!

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:

Diversified portfolio as proposed by David Swensen.
Asset classContribution (in %)
Domestic stock30
World-wide developed market stock20
Emerging markets5
Bonds with fixed return15
Real estate20

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 is shown on Icarra's website. That portfolio uses index-based Exchange-traded funds 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 it's value in the recent financial crisis — it has consistently outperformed mutual funds and funds of funds that I have been offered by banks in the past.

Summary

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 by a program written in the Python language that people can download from this site and use for their own purposes. The program is published under the GPLv3 and can be downloaded from the software section on this site.