Python for Finance: Part II: 7 Monte Carlo Simulations

Monte Carlo simulations

We are interested in observing the different possible realizations of a future event.
– Scenario 1
– Scenario 2
– Scenario 3
– Scenario 4
– Scenario 5
– Scenario 6

Historical data => A larger data set with “fictional” data

Current Revenues = Last Year Revenues * (1 + y-o-y growth rate)
– Revenue growth rate – Historical Data or User Intuition
– Revenue volatility – Historical Data or User Intuition

Cogs (Cost of Goods Sold): Modeled as a percentage of revenues
Opex: Modeled as a percentage of revenues

Revenues – Cogs = Gross Profit
Revenues – Opex = Operating Profit

Asset pricing with Monte Carlo

Price Today = Price Yesterday * er
r: log return of share price between yesterday and today.
In(price today / price yesterday)
e.g. eIn(x) = x
Price Today = Price Yesterday * e

Logarithm Basics

log2(16) = x
2x = 16
x = 4

log100(1) = 0
1000 = 1

log2(2) = 1/3
81/3 = 2

log2(1/8) = -3
2-3 = 1/8

log8(1/2) = -1/3
8-1/3 = 1/81/3 = 1/2

Brownian motion

We can use Brownian motion in order to model r:
– Drift:
=> The direction rates of return have been headed in the past.
In(Current Price / Previous Price)
=> Calculate average, standard deviation and variance of daily returns in the historical period.
Drift = (μ – 1/2σ2)
Drift is the expected daily return of the stock.

– Volatility:
Random variable.
Random variable = σ * Z(Rand(0;1))
Price Today = Price Yesterday * eDrift + Random variable
Repeat the calculation 1,000 times.

Euler’s Method

Differential equations introduction

yII + 2yI = 3y
fII(x) + 2fI(x) = 3f(x)

Leibniz’s notation
d2y / dx2 + 2 (dy / dx) = 3y

An Introduction to Derivative Contracts

A derivative is a financial instrument, whose price is derived based on the development of one or more underlying assets.

Originally, derivatives served as a hedging instrument.

– Hedging
– Speculating
– Aribtrageurs

Four Types of derivatives

– Forwards
Two parties agree that one party will sell to the other an underlying asset at a future point of time.

– Futures
Highly standardized forward contracts.

– Swaps
Two parties agree to exchange cash flows based on an underlying asset.
e.g. Interest rate, Stock Price, Bond Price, Commodity

– Options
An option contract enables its owner to buy or sell an underlying asset at a given price.

The Black Scholes formula

– A tool for derivatives pricing.
– calculates the value of an option.
– The holder of the option may decide he wants to buy the stock, but he may also decide he is better off without doing it. This freedom is valuable to every investor. Hence, it has a price.

A Call Option’s Payoff
– Strike Price vs. Share Price
– Share Price > Strike Price –> Exercise
– Strike Price > Share Price –> Don’t Exercise

The Black Scholes Formula

The Black Scholes formula calculates the value of a call by taking the difference between the amount you get if you exercise the option minus the amount you have to pay if you exercise the option.

Python for Finance: Part II: 6 Multivariate Regression Analysis

Multivariate Regressions

Yi = β0 + β1X1 + β2X2 + βiXi + εi

Python for Finance: Part II: 5 The Capital Asset Pricing Model

The Capital Asset Pricing Model (CAPM)

According to Markowitz, in the CAPM investors are:
– risk-averse
– prefer higher returns
– willing to buy the optimal portfolio

The market portfolio:
– a combination of all the possible investments in the world.

The risk-free asset:
– the CAPM assumes the existence of a risk-free asset.
– an investment with zero risk.
– Why should we assume the risk-free rate has a lower expected rate of return?
=> In efficient markets, investors are only compensated for the added risk they are willing to bear.

The Capital Market Line
– investors will allocate their money between the risk-free and the market portfolio

In the CAPM, investors will invest in:
– depending on their risk preferences, they will choose to buy more of the risk-free asset or more of the market portfolio.

Beta

β = Cov(rx, rm) / σm2
– measures the market risk that cannot be avoided through diversification.

β = 0: No relationship
β < 1: Defensive (Walmart) β > 1: Aggressive (Ford)

The Capital Asset Pricing Model

ri = rf + βim(rm – rf)

rf: risk-free
βim: beta between the stock and the market
rm: market return

Risk-free: Approximate with 10-year US government bond yield: 2.5%
Beta: Approximate the market portfolio with the S&P500: 0.62
Equity Risk Premium: Historically, it has been between 4.5% and 5.5%
r(i) = 2.5% + 0.62 * 5% = 5.6%

Sharpe Ratio

William Sharpe

Sharpe Ratio = (ri – rf) / σi

rf: risk-free rate
ri: rate of return of the stock “i”
σi: standard deviation of the stock “i”

Alpha

The Capital Asset Pricing Model:
ri = α + rf + βim(rm – rf)
– The standard CAPM setting assumes an alpha equal to 0.
– We can only compare the alpha of investments with a similar risk profile.

Python for Finance: Part II: 4 Markowitz Portfolio Optimization

Portfolio Theory

1952, Harry Markowitz published a paper.
– investors should understand the relationship between securities in their portfolio.

Implementation

Python for Finance: Part II: 3 Using Regressions for Financial Analysis

Regression

Mortgage
1. Size: Explanatory variable
2. Price: Dependent variable

Simple regression: Using only one variable
y = mx + b
y = α + βx

Multivariate regression: Using more than one variable

Implementation

Are all regressions created equal? Learning how to distinguish good

Y = α + βx + error

Residuals
– The best fitting line minimizes the sum of the squared residuals
=> OLS (ordinary least square) estimates

Good vs. Bad regressions (a comparison of explanatory power)
– Using the R square

S2 = (Σ (X-X)2) / (N-1)

TSS = Σ(X-X)2

TSS(Total Sum of Squares):
– provides a sense of the variability of data

R2 = 1 – SSR / TSS
– R square varies between 0% – 100%.
– The higher it is, the more predictive power the model has.

ページトップへ