Chapter 4. Optimality and Equilibrium

Much of economic theory is based on the premise: given two alternatives, an agent can, and will if able, choose a preferred one.

Darrell Duffie (1988)

A portfolio analysis starts with information concerning individual securities. It ends with conclusions concerning portfolios as a whole. The purpose of the analysis is to find portfolios which best meet the objectives of the investor.

Harry Markowitz (1959)

This chapter is about the modeling of agents and their optimization problems. It presents some of the fundamental building blocks of microeconomic theory (see Varian (1992)) and financial economics (see Eichberger and Harper (1997)). At the core of this chapter is the expected utility maximization paradigm, which is the dominant way of modeling an agent’s preferences in financial economics. Based on this paradigm, two central topics are discussed.

First, we discuss how an agent chooses an optimal investment portfolio given their preferences and the initial wealth. This type of problem is typically called optimal portfolio choice. The approach presented here does not rely on any form of simplification as seen with the mean-variance portfolio (MVP) approach and the Capital Asset Pricing Model (CAPM) that, for example, reduce the problem of choosing investment portfolios to the first and second moments of the return distributions of financial assets as well as their covariance.

Second, while prices for financial assets in the previous two chapters have been given a priori, this chapter derives them from fundamental principles in that it analyzes the pricing of financial assets based on the optimization problem of a so-called representative agent in addition to equilibrium arguments. Loosely speaking, a representative agent can be thought of as the aggregation of (infinitely) many agents acting independently in (financial) markets. Conditions for the existence of such a representative agent are well-known (see chapter 6 in Milne (1995))—however, they are not discussed in this chapter because financial theory in general simply postulates the existence.

The current chapter mainly covers the following topics from finance, mathematics, and Python programming. On the Python side, not that many new elements are introduced. The basic mathematical and Python tool sets for doing finance in discrete models are already introduced and developed in the previous two chapters:

Finance Mathematics Python

Preferences and utility

Utility function

NumPy

Utility maximization

Objective function, budget constraint, Theorem of Lagrange

scipy.optimize.minimize

Indifference curves, budget line

Function

NumPy, matplotlib

Logarithmic utility

Natural logarithm

NumPy, matplotlib

Time-additive utility

Utility function

NumPy, scipy.optimize.minimize

(time-additive) expected utility

Probability measure, Theorem of Lagrange

NumPy, scipy.optimize.minimize

Optimal investment portfolio

Theorem of Lagrange, first-order conditions

NumPy, scipy.optimize.minimize

Equilibrium pricing, representative agent

Theorem of Lagrange, first-order conditions

NumPy, scipy.optimize.minimize, SymPy

Martingale measures in incomplete markets

Set of probability measures

SymPy, sy.Symbol, sy.solve

Market completion by contingent claims

Theorem of Lagrange, first-order conditions

NumPy, scipy.optimize.minimize

Utility Maximization

Formally, an agent is modeled by a utility function, which orders a set of choices the agent is faced with and which is a representation of the agent’s preferences (see chapter 7 in Varian (1992)). Consider the static economy without uncertainty from Chapter 2. In addition, assume that an agent is endowed with some initial wealth, w >0 . The agent can decide how much of this wealth to spend today, t = 0 , and how much to save—via bank deposits—for future consumption. One can think of an agent faced with the question of how much to save for retirement.

The agent receives utility from money today, c 0 , and in one year, c 1 , according to the utility function:

U : ≥0 2 ≥0 , ( c 0 , c 1 ) u ( c 0 , c 1 )

As an example, assume u ( c 0 , c 1 ) = c 0 · c 1 —expressing the idea that money today and in one year are substitutes, although not perfect ones (if either one is zero, utility is zero as well). What is the optimal consumption-saving plan for the agent? Their constrained optimization problem formally is:

max c 0 ,c 1 c 0 · c 1 s.t. c 0 + c 1 = w

According to the Theorem of Lagrange (see chapter 5 in Sundaram (1996)), the constrained optimization problem can be transformed into an unconstrained one of the form:

max c 0 ,c 1 ,λ f ( c 0 , c 1 , λ ) = c 0 · c 1 - λ · ( c 0 + c 1 - w )

The first-order necessary conditions for optimality are:

f c 0 = c 1 - λ = 0 f c 1 = c 0 - λ = 0 f λ = c 0 + c 1 - w = 0

From these, one easily derives c 0 = c 1 = w 2 as the optimal consumption-saving plan.

This optimization problem can be modeled and solved in Python numerically, for which w = 10 shall hold:

In [1]: def u(c):
            return -c[0] * c[1]  1

In [2]: w = 10  2

In [3]: from scipy.optimize import minimize

In [4]: cons = ({'type': 'eq', 'fun': lambda c: c[0] + c[1] - w})  3

In [5]: opt = minimize(u, (1, 1), constraints=cons)  4

In [6]: opt
Out[6]:      fun: -24.999999999999996
             jac: array([-5., -5.])
         message: 'Optimization terminated successfully'
            nfev: 6
             nit: 2
            njev: 2
          status: 0
         success: True
               x: array([5., 5.])

In [7]: opt['x']  5
Out[7]: array([5., 5.])

In [8]: -opt['fun']   6
Out[8]: 24.999999999999996
1

The utility function with a negative sign to accomplish a maximization through minimization.

2

The initial wealth of the agent to be distributed between today and the future.

3

The budget constraint as an equality constraint for the minimize function.

4

The optimization with initial guess and budget constraint.

5

The optimal consumption-saving plan.

6

The maximum utility gained through the optimal plan.

Indifference Curves

The optimal solution from the previous section can be visualized by the means of indifference curves. An indifference curve is formed by all such combinations c = ( c 0 , c 1 ) that give the same utility u ¯ . The equation describing such a curve in ( c 0 , c 1 ) space is:

u ¯ = c 0 · c 1 c 1 = u ¯ c 0

The equation describing the line representing the budget constraint is:

w = c 0 + c 1 c 1 = w - c 0

The optimization problem is visualized in Figure 4-1, where the optimal plan is given by the dot—this is where the indifference curve for u ¯ = 25 is tangent to the line representing the budget constraint.

In Python, this translates into the following code:

In [9]: def iu(u, c0):
            return u / c0  1

In [10]: def c1(c0):
             return w - c0  2

In [11]: import numpy as np
         np.set_printoptions(precision=5)

In [12]: from pylab import mpl, plt
         plt.style.use('seaborn')
         mpl.rcParams['savefig.dpi'] = 300
         mpl.rcParams['font.family'] = 'serif'

In [13]: c0 = np.linspace(1, w)  3

In [14]: plt.figure(figsize=(10, 6))
         plt.plot(c0, c1(c0), label='budget constraint', lw=3.0)
         plt.plot(c0, iu(15, c0), '--', label='$u=15$')
         plt.plot(c0, iu(25, c0), label='$u=25$')
         plt.plot(c0, iu(35, c0), '-.', label='$u=35$')
         plt.plot(opt['x'][0], opt['x'][1], 'ro', label='$c=(5, 5)$')
         plt.legend(loc=0);
1

Function for indifference curve.

2

Function for budget line.

3

The domain over which to plot both.

ftwp 0401
Figure 4-1. The utility maximization problem

Appropriate Utility Functions

In finance, the utility that an agent gains from money they have available at a certain point in time—as a substitute for any other real asset that might be bought with the money, for instance—is typically expressed as a function u: ≥0 , which is assumed to satisfy three conditions:

  1. u ( x ) is twice differentiable

  2. du dx > 0

  3. d 2 u dx 2 0

The first condition is a technical prerequisite for the other two. The second condition formalizes the idea that more money—everything else being equal—is better than less money. Agents are assumed to be insatiable. The third condition states that the marginal utility from an additional unit of money is smaller (or the same at the maximum) than the marginal utility of the previous marginal unit of money. The function is therewith assumed to be increasing and (quasi-)concave.

Logarithmic Utility

This section introduces a type of function that is well suited for financial analyses based on a utility maximizing agent. Such a function—that satisfies the three conditions of the previous section and that is regularly used in finance to model the utility an agent receives from money (or consumption)—is the natural logarithm u ( x ) = ln x . For it, one gets:

  1. du dx = 1 x > 0 for x >0

  2. d 2 u dx 2 = - 1 x 2 < 0 for x >0

Python allows us to visualize the three relevant functions. NumPy is used in combination with vectorized calculations. Figure 4-2 shows the plot as generated by the following code:

In [15]: x = np.linspace(0.5, 10, 50)  1

In [16]: x[:5]  2
Out[16]: array([0.5    , 0.69388, 0.88776, 1.08163, 1.27551])

In [17]: u = np.log(x)  3

In [18]: u1 = 1 / x  4

In [19]: u2 = -1 / x ** 2  5

In [20]: plt.figure(figsize=(10, 6))  6
         plt.plot(x, u, label='$u$')  7
         plt.plot(x, u1, '--', label='$du/dx$')  8
         plt.plot(x, u2, '-.', label='$d^2u/dx^2$')  9
         plt.legend(loc=0);  10
1

Creates an ndarray object with floating point numbers between 0.5 and 10 and a homogeneous spacing to get 50 values.

2

Shows a selection of the resulting numbers.

3

Calculates the values for the utility function.

4

And for its first derivative as well as…

5

…for its second derivative.

6

Creates a new canvas for plotting and provides sizing parameters.

7

Plots the utility function.

8

Plots the first derivative.

9

Plots the second derivative.

10

Puts a legend in the optimal location (loc=0).

ftwp 0402
Figure 4-2. The natural logarithm function and its first and second derivatives

Time-Additive Utility

Using the natural logarithm as a function to model utility of an agent from money, the preferences of an agent over consumption-saving plans c = ( c 0 , c 1 ) can be described as a time-additive function of the following form:

U : ≥0 2 , ( c 0 , c 1 ) ln c 0 + κ · ln c 1

κ ≥0 is assumed to take on values 0 < κ 1 and represents the time preference of the agent. It embodies the idea that money and consumption today are valued higher than in one year. At least weakly, 100 USD now is preferred to 100 USD in one year—no matter what exact function describes utility (assuming consistency of preferences over time). It can be thought of as a nonmonetary discount factor. It is easily verified that this function satisfies the three conditions described previously—it is twice differentiable, increasing, and concave—based on the partial derivatives with regard to both c 0 and c 1 .

If the agent has initial wealth of w , their constrained optimization problem is:

max c 0 ,c 1 ln c 0 + κ · ln c 1 s.t. c 0 + c 1 = w

or

max c 0 ,c 1 ,λ f ( c 0 , c 1 , λ ) = ln c 0 + κ · ln c 1 - λ · ( c 0 + c 1 - w )

The first-order necessary conditions for optimality are:

f c 0 = 1 c 0 - λ = 0 f c 1 = κ · 1 c 1 - λ = 0 f λ = c 0 + c 1 - w = 0

From these, one obtains:

1 c 0 = κ · 1 c 1 c 1 = κ · c 0

The optimal consumption-saving plan now reflects the time preference in that consumption in one year c 1 is set to κ · c 0 . It also holds

c 0 + κ · c 0 = w c 0 = w 1+κ

and

w 1+κ + c 1 = w c 1 = κ·w 1+κ

The budget constraint is binding:

w 1+κ + κ·w 1+κ = w+κ·w 1+κ = w

The following code solves the optimization problem numerically for w = 10 . The optimal plan reflects the time preference:

In [21]: import math

In [22]: from scipy.optimize import minimize

In [23]: kappa = 10 / 11

In [24]: def U(c):
             return -(math.log(c[0]) +  kappa * math.log(c[1]))  1

In [25]: w = 10

In [26]: cons = ({'type': 'eq', 'fun': lambda c: c[0] + c[1] - w})  2

In [27]: opt = minimize(U, (1, 1), constraints=cons)

In [28]: opt
Out[28]:      fun: -3.0747286083026886
              jac: array([-0.19091, -0.19091])
          message: 'Optimization terminated successfully'
             nfev: 18
              nit: 6
             njev: 6
           status: 0
          success: True
                x: array([5.23811, 4.76189])

In [29]: opt['x']  3
Out[29]: array([5.23811, 4.76189])

In [30]: -opt['fun']  4
Out[30]: 3.0747286083026886
1

The utility function with a negative sign to accomplish a maximization through minimization.

2

The budget constraint as an equality constraint for the minimize function.

3

The optimal consumption-saving plan, reflecting the time preference in that c 0 is higher than c 1 —by exactly 10%.

4

The maximum utility gained through the optimal plan.1

Expected Utility

Now consider the static two-state economy with uncertainty. Assume that an agent, endowed with some initial wealth, w >0 , gains utility only through money available in one year—but now distinguished in the two states that are possible then. This shall represent a pure investment problem where all available initial wealth shall be optimally invested in the traded financial assets.

Assume that two financial assets are traded, a risk-less bond with price process

B = B 0 , (B 1 ,B 1 ) T

and a risky stock with price process

S = S 0 , (S 1 u ,S 1 d ) T

Financial assets are a means to transfer the initial wealth from today to a later point in time. The major decision problem of the agent is to decide what to consume in either one of the future states.

A model for the investment problem the agent is faced with under uncertainty is given by the expected utility of the agent that is to be maximized given w . The expected utility function is given by:

U : ≥0 2 , c 1 𝐄 P ( u ( c 1 ) )

With the price vector 0 = (B 0 ,S 0 ) T , the agent can distribute their initial wealth according to

0 · ϕ = w B 0 · b + S 0 · s = w

where ϕ=(b,s) T ≥0 2 represents the portfolio consisting of the risk-less bond and the risky stock as composed by the agent. This budget constraint will always be binding due to the agent being insatiable. Short selling shall not be allowed.

The market payoff matrix is as follows:

= B 1 S 1 u B 1 S 1 d

How much money does the agent have available in either state one year from today? This is determined by the portfolio the agent chooses to compose:

c 1 = · ϕ = B 1 B 1 · b + S 1 u S 1 d · s

This leads to

c 1 = b · B 1 + s · S 1 u b · B 1 + s · S 1 d

or

c 1 u = b · B 1 + s · S 1 u c 1 d = b · B 1 + s · S 1 d

The complete decision-making problem—with regard to optimal portfolio choice—of the agent can then be represented as the following constrained optimization problem:

max c 1 𝐄 P ( u ( c 1 ) ) (i) w = 0 · ϕ (ii) c 1 = · ϕ

or after substituting for c 1

max ϕ 𝐄 P ( u ( · ϕ ) ) w = 0 · ϕ

According to the Theorem of Lagrange, one can transform this problem into an unconstrained optimization problem of the form

max b,s,λ f ( b , s , λ ) = 𝐄 P u ( b · B 1 + s · S 1 ) - λ · ( b · B 0 + s · S 0 - w )

where the agent chooses b and s to maximize expected utility given the budget constraint.

Expected Utility Theory

Decades after its formulation and introduction, expected utility theory (EUT) is still the dominant decision-making paradigm in finance. One of its major assumptions—that agents have full knowledge of possible future states and their probabilities—is hardly ever fulfilled in reality. However, EUT is, to many, intellectually appealing and leads to “nice” results that are often easy to understand and interpret. For more on the problems with this central paradigm in finance, see Hilpisch (2020, chapters 3 and 4).

Optimal Investment Portfolio

What does an optimal solution for the expected utility maximizing agent look like? In general terms, the answer can be given based on the first-order conditions that are necessary and sufficient here for an optimal solution:

f b = 0 f s = 0 f λ = 0

or

f b = p · B 1 · u ' b · B 1 + s · S 1 u + ( 1 - p ) · B 1 · u ' b · B 1 + s · S 1 d - λ · B 0 = 0

and

f s = p · S 1 u · u ' b · B 1 + s · S 1 u + ( 1 - p ) · S 1 d · u ' b · B 1 + s · S 1 d - λ · S 0 = 0

with the usual notation u ' ( x ) du dx as well as

b · B 0 + s · S 0 = w

Assume logarithmic utility and for the price processes of the two traded financial assets B = ( 10 , 11 ) and S = 10 , (20,5) T , respectively. With w = 10 , it holds b + s = 1 such that the portfolio positions represent percent values.

In Python, the minimize function from the scipy.optimize subpackage is also appropriate to solve the investment problem of the agent:

In [31]: B = (10, (11, 11))  1

In [32]: S = (10, (20, 5))  2

In [33]: M0 = np.array((B[0], S[0]))  3

In [34]: M = np.array((B[1], S[1])).T  4

In [35]: p = 0.5  5

In [36]: P = np.array((p, 1-p))  5

In [37]: def U(phi):
             c1 = np.dot(M, phi)  6
             return -np.dot(P, np.log(c1))  6

In [38]: -U((1, 0))  7
Out[38]: 2.3978952727983707

In [39]: -U((0, 1))  7
Out[39]: 2.3025850929940455

In [40]: -U((0.5, 0.5))  7
Out[40]: 2.410140782802518

In [41]: w = 10

In [42]: cons = ({'type': 'eq',
                  'fun': lambda phi: np.dot(M0, phi) - w})  8

In [43]: opt = minimize(U, (1, 1), constraints=cons)  9

In [44]: opt
Out[44]:      fun: -2.4183062699261972
              jac: array([-1.     , -0.99999])
          message: 'Optimization terminated successfully'
             nfev: 15
              nit: 5
             njev: 5
           status: 0
          success: True
                x: array([0.69442, 0.30558])

In [45]: opt['x']  10
Out[45]: array([0.69442, 0.30558])

In [46]: -opt['fun']  11
Out[46]: 2.4183062699261972

In [47]: -U(opt['x'])  11
Out[47]: 2.4183062699261972

In [48]: np.dot(M, opt['x'])  12
Out[48]: array([13.75022,  9.16652])
1

The bond price process and…

2

…the stock price process.

3

The price vector of the two traded financial assets.

4

The market payoff matrix of the two traded financial assets.

5

The physical probability measure for the economy.

6

The expected utility function with logarithmic utility.

7

Some example values for total portfolio weights of 1—diversification pays off.

8

The budget constraint based on the dot product of the price and portfolio vectors.

9

The expected utility maximization problem as a minimization.

10

The optimal allocation between the bond and the stock.

11

The optimal expected utility value.

12

The state-contingent payoff from the optimal portfolio.

Time-Additive Expected Utility

It is possible to formulate the decision-making problem of the agent to include utility from money today as well:

U : R 0 × 0 , ( c 0 , c 1 ) u ( c 0 ) + κ · 𝐄 P ( u ( c 1 ) )
U : R ≥0 × ≥0 , ( c 0 , c 1 ) u ( c 0 ) + κ · 𝐄 P ( u ( c 1 ) )

With initial wealth w , the optimization problem in unconstrained form becomes:

max c 0 ,b,s,λ f ( c 0 , b , s , λ ) = u ( c 0 ) + κ · 𝐄 P u ( b · B 1 + s · S 1 ) - λ · ( c 0 + b · B 0 + s · S 0 - w )

With the assumptions from before, the optimal solution is derived with Python according to the following code:

In [49]: M0 = np.array((1, B[0], S[0]))  1

In [50]: kappa = 10 / 11  2

In [51]: def U(phi):
             c0 = phi[0]  3
             c1 = np.dot(M, phi[1:])  3
             return -(np.log(c0) + kappa * np.dot(P, np.log(c1)))  3

In [52]: opt = minimize(U, (1, 1, 1), constraints=cons)

In [53]: opt
Out[53]:      fun: -3.1799295980286093
              jac: array([-0.19088, -1.90932, -1.90974])
          message: 'Optimization terminated successfully'
             nfev: 32
              nit: 8
             njev: 8
           status: 0
          success: True
                x: array([5.23899, 0.33087, 0.14523])

In [54]: -opt['fun']
Out[54]: 3.1799295980286093

In [55]: opt['x'][0]  4
Out[55]: 5.23898714830318

In [56]: np.dot(M, opt['x'][1:])  5
Out[56]: array([6.54422, 4.36571])
1

The price vector including the price of 1 for consumption today.

2

The time preference factor.

3

The expected utility function taking into account consumption today and the time preference.

4

This is what the agent consumes today from w .

5

This is the state-contingent payoff from the bond and the stock position.

Pricing in Complete Markets

In this section, the analysis is changed to a pricing setting based on optimization principles. Assume that the two Arrow-Debreu securities are traded in the economy with two future states and that the net supply for both is one. The two payoff vectors form a standard basis for 2 , and the market payoff matrix is:

= 1 0 0 1

Assume now that there is a representative agent in the economy that is the only one trading the two securities. In an equilibrium, the representative agent needs to hold the net supply of both securities because there is nobody else. The mechanism that ensures equilibrium is the prices of the two securities today, that is, the price vector:

0 = (γ u ,γ d ) T ≥0 2

The idea of equilibrium pricing is that this price vector needs to be adjusted in a way that the representative agent holds the net supply of all available financial assets. This is because otherwise there would be no equilibrium.

With the investment portfolio ϕ = ϕ u ,ϕ d T , the problem of the expected utility maximizing, representative agent is

max ϕ 𝐄 P ( u ( · ϕ ) ) s.t. 0 · ϕ = w

or

max ϕ,λ 𝐄 P ( u ( · ϕ ) ) - λ · ( 0 · ϕ - w )

Due to the special market payoff matrix, this translates into

max ϕ u ,ϕ d p · u ϕ u + ( 1 - p ) · u ϕ d s.t. γ u · ϕ u + γ d · ϕ d = w

and

max ϕ u ,ϕ d ,λ f ( ϕ u , ϕ d , λ ) = p · u ϕ u + ( 1 - p ) · u ϕ d - λ · γ u · ϕ u + γ d · ϕ d - w

The three first-order conditions for the unconstrained problem are:

f ϕ u = p · u ' ( ϕ u ) - λ · γ u = 0 f ϕ d = ( 1 - p ) · u ' ( ϕ d ) - λ · γ d = 0 f λ = γ u · ϕ u + γ d · ϕ d - w = 0

What consequences for the prices 0 follow from these optimality conditions? The first is with regard to the relative price of the two Arrow-Debreu securities:

γ u γ d = p·u ' (ϕ u ) (1-p)·u ' (ϕ d )

The relative price is fully determined by the probabilities for the two states to occur and the marginal utilities gained from consumption in the two states. Factoring in that in equilibrium ϕ u = ϕ d = 1 must hold, the relative price is determined by the probability measure only:

γ u γ d = p (1-p)

With this additional condition, one also obtains:

γ u + γ d = w

While the relative price is determined by the probability measure in this case, the absolute prices are determined by the initial wealth available. This is intuitively appealing in that the prices should be higher the more initial wealth there is, given that the net supply for two securities is fixed.

Normalizing initial wealth to w = 1 , for instance, fixes the prices via

γ u = 1 - γ d

to finally arrive at the equilibrium prices of

γ u = p γ d = 1 - p

or the equilibrium price vector 0 * = (p,1-p) T .

Arbitrage Pricing

What about arbitrage prices of contingent claims given the equilibrium price vector 0 * ? In complete markets, in which every contingent claim is attainable, the price of any such attainable contingent claim C 1 𝔸= ≥0 2 is then given by:

C 0 = 0 * · C 1 = γ u · C 1 u + γ d · C 1 d

This is because the replication portfolio is simply the state-contingent payoff itself ϕ = C 1 in the special case of two Arrow-Debreu securities. The prices of Arrow-Debreu securities are therefore also called state prices because they represent the price for one unit of currency (consumption) in a certain state.

Martingale Pricing

How does the unique martingale measure look for the current economy? The condition for the martingale measure Q is that it makes all discounted price processes of traded financial assets a martingale. In matrix form, the conditions are:

0 * = 1 1+i · 𝐄 Q ( )

More explicitly, one gets:

p · ( 1 + i ) = q ( 1 - p ) · ( 1 + i ) = 1 - q

From these, i = 0 follows and also q = p . The physical probability measure makes all probabilities already a martingale. The other way around, the prices for the two Arrow-Debreu securities are set in equilibrium in a way such that the discounted price processes are martingales.

Every attainable contingent claim C 1 𝔸 can be priced by simply taking the expectation under the physical probability measure in this special kind of representative agent economy. Formally, this translates into:

C 0 = 𝐄 P ( C 1 )

Risk-Less Interest Rate

Why is the equilibrium risk-less interest rate zero? The answer is quite simple: because there is no risk-less financial asset traded that fixes another interest rate. Consider a risk-less financial asset paying 1 in every state B 1 = (1,1) T . The arbitrage price for this financial asset is

B 0 = 0 * · B 1 = p + ( 1 - p ) = 1

implying a risk-less interest rate of i = 0 . Any other price 0 < B 0 < 1 , implying a positive risk-less interest rate, would also imply arbitrage opportunities.

A Numerical Example (I)

The equilibrium pricing analysis so far rests on a number of simplifying assumptions allowing for elegant solutions and simple relations. Consider now a case with the somehow more realistic numerical assumptions as used multiple times before.

Specifically, assume expected utility maximization based on logarithmic utility for the representative agent. Assume further price processes for the risk-less bond of

B = B 0 , (11,11) T

and for the risky stock of

S = S 0 , (20,5) T

The market payoff matrix accordingly is:

= 11 20 11 5

The physical probability measure is given by P = p,(1-p) T with p = 1 3 . The net supply of the risk-less bond is b = 1 , and it is s = 1 for the risky stock. The initial wealth the agent has available shall be w = 15 .

The problem of the representative agent is

max ϕ,λ f ( ϕ , λ ) = 𝐄 P u ( · ϕ ) - λ · 0 · ϕ - w

or

max b,s,λ f ( b , s , λ ) = 𝐄 P u ( b · B 1 + s · S 1 ) - λ · b · B 0 + s · S 0 - w

The three first-order conditions are:

f b = 𝐄 P B 1 · u ' ( b · B 1 + s · S 1 ) - λ · B 0 = 0 f s = 𝐄 P S 1 · u ' ( b · B 1 + s · S 1 ) - λ · S 0 = 0 f λ = b · B 0 + s · S 0 - w = 0

The relative price for the two financial assets according to the optimality conditions—and taking into account the net supply of one for both financial assets as well as the logarithmic utility—is:

S 0 B 0 = 𝐄 P S 1 ·u ' (b·B 1 +s·S 1 ) 𝐄 P B 1 ·u ' (b·B 1 +s·S 1 ) = 𝐄 P S 1 B 1 +S 1 𝐄 P B 1 B 1 +S 1 ζ

Adding the budget constraint to the mix fixes not only the relative price ζ but also the absolute price levels:

B 0 + ζ · B 0 = w B 0 = w 1+ζ

In Python, these considerations translate into simple vectorized operations using NumPy:

In [57]: p = 1 / 3  1

In [58]: P = np.array((p, (1-p)))  1

In [59]: B1 = np.array((11, 11))

In [60]: S1 = np.array((20, 5))

In [61]: zeta = np.dot(S1 / (B1 + S1), P) / np.dot(B1 / (B1 + S1), P)  2

In [62]: zeta  2
Out[62]: 0.7342657342657343

In [63]: w = 15  3

In [64]: B0 = w / (1 + zeta)  4

In [65]: B0  4
Out[65]: 8.649193548387098

In [66]: S0 = zeta * B0  5

In [67]: S0  5
Out[67]: 6.350806451612904

In [68]: B0 + S0  6
Out[68]: 15.000000000000002

In [69]: i = B1.mean() / B0 - 1  7

In [70]: i  7
Out[70]: 0.2717948717948717

In [71]: mu = np.dot(S1, P) / S0 - 1  8

In [72]: mu  8
Out[72]: 0.5746031746031743
1

The probability measure.

2

The price ratio zeta given optimality conditions.

3

The initial wealth.

4

The equilibrium price level of the risk-less bond given the price ratio zeta and initial wealth w.

5

The resulting equilibrium price level of the risky stock.

6

The budget constraint is binding.

7

The equilibrium interest rate given the price level for the risk-less bond.

8

The equilibrium expected rate of return of the risky stock.

Equilibrium pricing does not lead in this case to the discounted price processes being martingales under the physical probability measure. The martingale measure is easily derived, however. The analysis uses the SymPy package for symbolic computations with Python:

In [73]: import sympy as sy  1

In [74]: q = sy.Symbol('q')  2

In [75]: eq = (q * 20 + (1 - q) * 5) / (1 + i) - S0  3

In [76]: eq  4
Out[76]: 11.7943548387097*q - 2.41935483870968

In [77]: q = sy.solve(eq)[0]  5

In [78]: q  6
Out[78]: 0.205128205128205

In [79]: Q = np.array((q, 1 - q))  6

In [80]: np.dot(B1, Q) / (1 + i)  7
Out[80]: 8.64919354838710

In [81]: np.dot(S1, Q) / (1 + i)  7
Out[81]: 6.35080645161290
1

Imports the symbolic computation package SymPy.

2

Defining the symbol q.

3

Formulating the equation for q given the martingale condition.

4

The equation simplified.

5

This solves the equation numerically.

6

The resulting martingale measure.

7

Both discounted price processes are martingales under Q.

Pricing in Incomplete Markets

How does representative agent pricing work in incomplete markets? The answer fortunately is: exactly the same way as in complete markets.

Assume the two date, three-state economy in which a risk-less bond with price process

B = B 0 , (11,11,11) T

and a risky stock with price process

S = S 0 , (20,10,5) T

are traded. The physical probability measure is P = (p,p,p) T , with p = 1 3 . Everything else shall be as in the previous section.

Formally, the optimization problem of the representative agent does not change:

max b,s,λ f ( b , s , λ ) = 𝐄 P u ( b · B 1 + s · S 1 ) - λ · b · B 0 + s · S 0 - w

Nor does the formula for the relative price change:

S 0 B 0 = 𝐄 P S 1 B 1 +S 1 𝐄 P B 1 B 1 +S 1 ζ

In Python, only the future price vectors of the financial assets and the vector representing the probability measure need to be adjusted:

In [82]: p = 1 / 3  1

In [83]: P = np.array((p, p, p))  1

In [84]: B1 = np.array((11, 11, 11))

In [85]: S1 = np.array((20, 10, 5))

In [86]: zeta = np.dot(S1 / (B1 + S1), P) / np.dot(B1 / (B1 + S1), P)  2

In [87]: zeta  2
Out[87]: 0.9155274934101636

In [88]: w = 15  3

In [89]: B0 = w / (1 + zeta)  4

In [90]: B0  4
Out[90]: 7.8307411674347165

In [91]: S0 = zeta * B0  5

In [92]: S0  5
Out[92]: 7.169258832565284

In [93]: B0 + S0  6
Out[93]: 15.0

In [94]: i = B1.mean() / B0 - 1  7

In [95]: i  7
Out[95]: 0.40472016183411985

In [96]: mu = np.dot(S1, P) / S0 - 1  8

In [97]: mu  8
Out[97]: 0.6273183796451287
1

The probability measure.

2

The relative price zeta given optimality conditions.

3

The initial wealth.

4

The equilibrium price level of the risk-less bond given the price ratio zeta and initial wealth w.

5

The resulting equilibrium price level of the risky stock.

6

The budget constraint is binding.

7

The equilibrium interest rate given the price level for the risk-less bond.

8

The equilibrium expected rate of return of the risky stock.

Representative Agent Pricing

The pricing of securities based on the optimization calculus of a representative agent is one approach that applies to both complete and incomplete markets. Instead of adjusting markets—for example, via market completion based on additional securities—additional assumptions are made with regard to the representative agent. For example, the initial wealth of the agent is required to arrive at specific, absolute prices for the securities instead of only relative prices.

Martingale Measures

Although representative agent pricing works in incomplete markets the same way as in complete ones, it unfortunately does not directly solve the problem of pricing contingent claims that are not attainable. There are still infinitely many martingale measures that are consistent with the market.

The Python code that follows shows that there are infinitely many martingale measures that are consistent with the equilibrium price processes as derived in the previous section:

In [98]: qu = sy.Symbol('qu')  1
         qm = sy.Symbol('qm')  1

In [99]: eq = (qu * 20 + qm * 10 + (1 - qu - qm) * 5) / (1 + i) - S0  2

In [100]: eq  3
Out[100]: 3.55942780337942*qm + 10.6782834101383*qu - 3.60983102918587

In [101]: Q = sy.solve(eq, set=True)  4

In [102]: Q  5
Out[102]: ([qm], {(1.01416048550236 - 3.00000000000001*qu,)})
1

Defining the symbols qu and qm.

2

Formulating the equation for qu and qm given the martingale condition.

3

The equation simplified.

4

This solves the equation numerically, providing a set of solutions as the result; this does not take into account the conditions 0 q u , q d 1 .

5

The relationship between qu and qm as the solution—indicating infinitely many solutions.

Martingale Measure in Incomplete Markets

Martingale pricing is a convenient and elegant approach in complete markets to value contingent claims. In incomplete markets, there are in general infinitely many martingale measures that are consistent with the market. In practice, one often solves this issue by relying on publicly observed market prices for liquidly trading contingent claims, such as plain vanilla European put or call options. These prices are used to calibrate model parameters or the martingale measure directly to be consistent with the market. For more background information and details about model calibration, see Hilpisch (2015).

Equilibrium Pricing

What about pricing contingent claims? If they are attainable through replication portfolios composed of traded financial assets, their price can be fixed by the usual arbitrage argument. What if a contingent claim is not attainable? In the simple incomplete market setting currently under investigation, this can only mean that the payoff vector is linearly independent of the two future price vectors of the traded financial assets. This in turn implies that the introduction of a contingent claim with such a payoff vector is market completing—because three linearly independent vectors form in any case a basis of 3 .

Consider the market payoff matrix from the first two Arrow-Debreu securities, each available at a net supply of one:

= 1 0 0 1 0 0

This market is obviously incomplete because the two securities do not span 3 . Introducing a contingent claim with net supply of one that pays one unit of currency in the d state—that is, a contingent claim that pays exactly what the third Arrow-Debreu security would pay—completes the market as seen by the resulting payoff matrix:

= 1 0 0 0 1 0 0 0 1

The three payoff vectors now form a standard basis of the 3 .

Formally, the optimization problem of the representative agent is the same as before:

max ϕ 𝐄 P ( u ( · ϕ ) ) s.t. 0 · ϕ = w

Here, 0 = γ u ,γ m ,γ d T as the state price vector and ϕ = (1,1,1) T as the market portfolio.

In explicit form, the unconstrained optimization problem according to the Theorem of Lagrange is:

max ϕ u ,ϕ m ,ϕ d ,λ f ( ϕ u , ϕ m , ϕ d , λ ) = p u · u ϕ u + p m · u ϕ m + p d · u ϕ d - λ · γ u · ϕ u + γ m · ϕ m + γ d · ϕ d - w

The four first-order conditions for the unconstrained problem are:

f ϕ u = p u · u ' ( ϕ u ) - λ · γ u = 0 f ϕ m = p m · u ' ( ϕ m ) - λ · γ m = 0 f ϕ d = p d · u ' ( ϕ d ) - λ · γ d = 0 f λ = γ u · ϕ u + γ m · ϕ m + γ d · ϕ d - w = 0

For the relative prices, one gets:

γ u γ m = p u ·u ' (ϕ u ) p m ·u ' (ϕ m ) γ u γ d = p u ·u ' (ϕ u ) p d ·u ' (ϕ d )

Through these, the third relative price is fixed as well. With logarithmic utility and an initial wealth fixed at w = 1 , one finally arrives in this special case at:

γ u = p u γ m = p m γ d = p d

The equilibrium price vector is 0 * = (p u ,p m ,p d ) T , which equals the vector representing the probability measure. This in turn implies that all discounted price processes are martingales under the physical probability measure.

A Numerical Example (II)

Getting back to the numerical example from before: assume expected utility maximization based on logarithmic utility for the representative agent. Assume further price processes for the risk-less bond of

B = B 0 , (11,11,11) T

and for the risky stock of

S = S 0 , (20,10,5) T

The market payoff matrix is:

= 11 20 11 10 11 5

The physical probability measure is given by P = p,p,p T , with p = 1 3 . The net supply of the risk-less bond is b = 1 , and it is s = 1 for the risky stock. The initial wealth the agent has available shall be w = 15 .

A contingent claim is introduced with payoff C 1 = (5,0,0) T and a net supply of c = 1 .

Consequently, the problem of the representative agent is:

max ϕ,λ f ( ϕ , λ ) = 𝐄 P u ( · ϕ ) - λ · 0 · ϕ - w

or

max b,s,c,λ f ( b , s , λ ) = 𝐄 P u ( b · B 1 + s · S 1 + c · C 1 ) - λ · b · B 0 + s · S 0 + c · C 0 - w

The four first-order conditions are:

f b = 𝐄 P B 1 · u ' ( b · B 1 + s · S 1 + c · C 1 ) - λ · B 0 = 0 f s = 𝐄 P S 1 · u ' ( b · B 1 + s · S 1 + c · C 1 ) - λ · S 0 = 0 f c = 𝐄 P C 1 · u ' ( b · B 1 + s · S 1 + c · C 1 ) - λ · C 0 = 0 f λ = b · B 0 + s · S 0 + c · C 0 - w = 0

The relative prices for the three financial assets are fixed through:

S 0 B 0 = 𝐄 P S 1 B 1 +S 1 +C 1 𝐄 P B 1 B 1 +S 1 +C 1 ζ 1 C 0 B 0 = 𝐄 P C 1 B 1 +S 1 +C 1 𝐄 P B 1 B 1 +S 1 +C 1 ζ 2

Adding the budget constraint to the mix fixes not only the relative prices ζ 1 and ζ 2 but also the absolute price levels:

B 0 + ζ 1 · B 0 + ζ 2 · B 0 = w B 0 = w 1+ζ 1 +ζ 2

The adjustments to the Python code are only minor compared to the complete markets case:

In [103]: p = 1 / 3  1

In [104]: P = np.array((p, p, p))  1

In [105]: B1 = np.array((11, 11, 11))  2

In [106]: S1 = np.array((20, 10, 5))  2

In [107]: C1 = np.array((5, 0, 0))  2

In [108]: zeta_1 = (np.dot(S1 / (B1 + S1 + C1), P) /
                    np.dot(B1 / (B1 + S1 + C1), P))  3

In [109]: zeta_1  3
Out[109]: 0.8862001308044474

In [110]: zeta_2 = (np.dot(C1 / (B1 + S1 + C1), P) /
                    np.dot(B1 / (B1 + S1 + C1), P))  4

In [111]: zeta_2  4
Out[111]: 0.09156311314584695

In [112]: w = 15  5

In [113]: B0 = w / (1 + zeta_1 + zeta_2)  6

In [114]: B0  6
Out[114]: 7.584325396825396

In [115]: S0 = zeta_1 * B0  7

In [116]: S0  7
Out[116]: 6.721230158730158

In [117]: C0 = zeta_2 * B0  8

In [118]: C0  8
Out[118]: 0.6944444444444443

In [119]: B0 + S0 + C0  9
Out[119]: 14.999999999999998

In [120]: i = B1.mean() / B0 - 1  10

In [121]: i  10
Out[121]: 0.45035971223021587

In [122]: muS = np.dot(S1, P) / S0 - 1  11

In [123]: muS  11
Out[123]: 0.7357933579335794

In [124]: muC = np.dot(C1, P) / C0 - 1  12

In [125]: muC  12
Out[125]: 1.4000000000000004
1

The probability measure.

2

The payoff vectors.

3

The first relative price.

4

The second relative price.

5

The initial wealth…

6

…and the resulting price for the risk-less bond.

7

The equilibrium price for the risky stock.

8

The equilibrium price for the contingent claim.

9

The budget constraint is binding.

10

The risk-less interest rate.

11

The equilibrium expected rate of return for the risky stock.

12

The equilibrium expected rate of return for the contingent claim.

That the introduction of the contingent claim—as a third traded financial asset—is market completing can be seen by the fact that there is now a unique martingale measure:

In [126]: M = np.array((B1, S1, C1)).T  1

In [127]: M  1
Out[127]: array([[11, 20,  5],
                 [11, 10,  0],
                 [11,  5,  0]])

In [128]: M0 = np.array((B0, S0, C0))  2

In [129]: Q = np.linalg.solve(M.T / (1 + i), M0)  3

In [130]: Q  4
Out[130]: array([0.20144, 0.34532, 0.45324])

In [131]: sum(Q)  4
Out[131]: 1.0

In [132]: np.allclose(np.dot(M.T, Q), M0 * (1 + i))  5
Out[132]: True
1

The new market payoff matrix including the contingent claim.

2

The vector with the prices of the three financial assets/contingent claims.

3

This solves for the vector Q representing the martingale measure Q (note the use of the transpose operator .T).

4

The solution vector whose components add up to 1.

5

A final check whether all discounted price processes are indeed martingales.

Conclusions

This chapter is concerned with the modeling of agents and their optimization problems, mainly on the basis of the expected utility maximization approach. Two central topics are discussed: optimal portfolio choice and equilibrium pricing of financial assets and contingent claims in complete and incomplete markets. While in the first case the prices are given and the quantities in the investment portfolio are chosen, in the latter case the quantities to be held in the investment portfolio are fixed, and the prices are adjusted for this to be optimal for the representative agent. Python proves once again a powerful ecosystem with helpful packages to model and solve the related optimization problems.

Although the model economies in this and the previous two chapters are admittedly simplistic, the techniques and methods introduced carry over to general static model economies, that is, those having many more—even countably infinite—different future states (instead of two or three only). With some additional formalism, they even carry over to dynamic economies with many—potentially countably infinite—relevant points in time (instead of just two).

Further Resources

Books cited in this chapter:

1 Utility is only to be understood in ordinal terms, that is, in terms of bringing different plans into a certain order. A comparison of this numerical value with the optimal one from before does not make any sense because the utility functions are different.

Get Financial Theory with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.