Python for Finance: Part II: 2 Measuring Investment Risk

variance

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

X=15%
X=14%
X=16%
X=13%
X=17%

(14%-15%)2 = 0.01%
(16%-15%)2 = 0.01%
(13%-15%)2 = 0.04%
(17%-15%)2 = 0.04%

Σ=0.1%

S2=0.1% / (4-1)
S2=0.033%
S2=0.00033

standard deviation

S = √S2

√S2 = √0.00033 = 1.8%

Implementation

Calculating the covariance between securities

The correlation coefficient measures the relationship between two variables.

Pxy = ((x-x) * (y-y)) / (σxσy)

x: house size
y: house price

Implementation

Considering the risk of multiple securities in a portfolio

(a+b)2 = a2 + 2ab + b2

Portfolio variance (2 stocks):
(w1σ1 + w2σ2)2 = w12σ12 + 2w1σ1w2σ2p12 + w22σ22

Implementation

Portfolio Variance

1. Variance of securities
2. Correlation (and Covariance)

3. Two types of investment risks
1) Un-diversifiable risk (Systematic risk): cannot be eliminated.
– Recession of the economy
– Low consumer spending
– Wars
– Forces of nature
2) Diversifiable risk (Idiosyncratic risk, company specific risk)
– Automotive
– Construction
– Energy
– Technology

Calculating Diversifiable and Non-Diversifiable Risk of a Portfolio

ページトップへ