The Rate of Return of Amazon’s Stock Price

Simple rate of return

rate of return = (ending price – beginning price) / beginning price
(P1 – P0) / P0 = P1 / P0 – 1
Use when dealing with multiple assets over the same timeframe.

Date
2001-07-26 NaN
2001-07-27 -0.014481
2001-07-30 0.024490
2001-07-31 -0.004781
2001-08-01 0.000801
2001-08-02 -0.024800
2001-08-03 -0.003281
2001-08-06 -0.020576
2001-08-07 -0.025210
2001-08-08 -0.042241
2001-08-09 -0.058506
2001-08-10 -0.048757
2001-08-13 0.017085
2001-08-14 0.040514
2001-08-15 -0.042735
2001-08-16 -0.026786
2001-08-17 0.018349
2001-08-20 0.041041
2001-08-21 -0.049038
2001-08-22 0.031345
2001-08-23 -0.055882
2001-08-24 0.062305
2001-08-27 -0.009775
2001-08-28 -0.015795
2001-08-29 -0.078235
2001-08-30 -0.054407
2001-08-31 0.028769
2001-09-04 -0.039150
2001-09-05 -0.109430
2001-09-06 0.065359

2017-05-10 -0.004062
2017-05-11 -0.001402
2017-05-12 0.014489
2017-05-15 -0.003516
2017-05-16 0.008455
2017-05-17 -0.022058
2017-05-18 0.014533
2017-05-19 0.001408
2017-05-22 0.011283
2017-05-23 0.000896
2017-05-24 0.009068
2017-05-25 0.013291
2017-05-26 0.002416
2017-05-30 0.000924
2017-05-31 -0.002087
2017-06-01 0.001337
2017-06-02 0.010824
2017-06-05 0.004579
2017-06-06 -0.008246
2017-06-07 0.007049
2017-06-08 0.000198
2017-06-09 -0.031635
2017-06-12 -0.013697
2017-06-13 0.016457
2017-06-14 -0.004405
2017-06-15 -0.012596
2017-06-16 0.024415
2017-06-19 0.007553
2017-06-20 -0.002593
2017-06-21 0.009712
Name: simple_return, Length: 4000, dtype: float64

0.0015193424705951424

0.3798356176487856

37.984 %

Logarithmic rate of return

ln(Pt / Pt-1)
10.0% = log $116 / $105 = log $116 – log $105
Use when you make calculations about a single asset over time.

Date
2001-07-27 NaN
2001-07-30 0.024195
2001-07-31 -0.004792
2001-08-01 0.000800
2001-08-02 -0.025113
2001-08-03 -0.003287
2001-08-06 -0.020791
2001-08-07 -0.025533
2001-08-08 -0.043159
2001-08-09 -0.060287
2001-08-10 -0.049986
2001-08-13 0.016941
2001-08-14 0.039715
2001-08-15 -0.043675
2001-08-16 -0.027151
2001-08-17 0.018182
2001-08-20 0.040221
2001-08-21 -0.050282
2001-08-22 0.030864
2001-08-23 -0.057504
2001-08-24 0.060441
2001-08-27 -0.009823
2001-08-28 -0.015921
2001-08-29 -0.081465
2001-08-30 -0.055943
2001-08-31 0.028363
2001-09-04 -0.039937
2001-09-05 -0.115893
2001-09-06 0.063312
2001-09-07 0.043224

2017-05-11 -0.001403
2017-05-12 0.014385
2017-05-15 -0.003522
2017-05-16 0.008420
2017-05-17 -0.022305
2017-05-18 0.014428
2017-05-19 0.001407
2017-05-22 0.011220
2017-05-23 0.000896
2017-05-24 0.009027
2017-05-25 0.013204
2017-05-26 0.002413
2017-05-30 0.000923
2017-05-31 -0.002089
2017-06-01 0.001336
2017-06-02 0.010766
2017-06-05 0.004569
2017-06-06 -0.008281
2017-06-07 0.007024
2017-06-08 0.000198
2017-06-09 -0.032146
2017-06-12 -0.013792
2017-06-13 0.016324
2017-06-14 -0.004414
2017-06-15 -0.012676
2017-06-16 0.024122
2017-06-19 0.007524
2017-06-20 -0.002596
2017-06-21 0.009665
2017-06-22 -0.000928
Name: log_return, dtype: float64

0.0010977419081520047

0.2744354770380012

27.444 %

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

ページトップへ