Financial Returns. Dakota Wixom Quantitative Analyst QuantCourse.com INTRO TO PORTFOLIO RISK MANAGEMENT IN PYTHON

Similar documents
Dakota Wixom Quantitative Analyst QuantCourse.com

Mean GMM. Standard error

A Tale of Two Project

Diploma Part 2. Quantitative Methods. Examiner s Suggested Answers

Lecture 6: Non Normal Distributions

JZ Assignment Page 1 of 5

Terms & Characteristics

Financial Econometrics

IMPORTING & MANAGING FINANCIAL DATA IN PYTHON. Summarize your data with descriptive stats

Quantitative Introduction ro Risk and Uncertainty in Business Module 5: Hypothesis Testing Examples

Financial Time Series and Their Characteristics

Statistics 431 Spring 2007 P. Shaman. Preliminaries

The Bernoulli distribution

Chapter 3 Discrete Random Variables and Probability Distributions

Data Distributions and Normality

Chapter 7: SAMPLING DISTRIBUTIONS & POINT ESTIMATION OF PARAMETERS

Web Science & Technologies University of Koblenz Landau, Germany. Lecture Data Science. Statistics and Probabilities JProf. Dr.

7. For the table that follows, answer the following questions: x y 1-1/4 2-1/2 3-3/4 4

Chapter 7. Inferences about Population Variances

Kevin Dowd, Measuring Market Risk, 2nd Edition

2018 AAPM: Normal and non normal distributions: Why understanding distributions are important when designing experiments and analyzing data

Tests for One Variance

Some Characteristics of Data

Hypothesis Tests: One Sample Mean Cal State Northridge Ψ320 Andrew Ainsworth PhD

David Tenenbaum GEOG 090 UNC-CH Spring 2005

Lecture Data Science

AP Statistics Chapter 6 - Random Variables

Descriptive Analysis

Overview/Outline. Moving beyond raw data. PSY 464 Advanced Experimental Design. Describing and Exploring Data The Normal Distribution

Financial Econometrics (FinMetrics04) Time-series Statistics Concepts Exploratory Data Analysis Testing for Normality Empirical VaR

No, because np = 100(0.02) = 2. The value of np must be greater than or equal to 5 to use the normal approximation.

Analysis of 2x2 Cross-Over Designs using T-Tests for Non-Inferiority

Diploma in Business Administration Part 2. Quantitative Methods. Examiner s Suggested Answers

Statistical Analysis of Data from the Stock Markets. UiO-STK4510 Autumn 2015

The Capital Asset Pricing Model

Implied Volatility using Python s Pandas Library

Modern Methods of Data Analysis - SS 2009

Quantitative Methods for Economics, Finance and Management (A86050 F86050)

درس هفتم یادگیري ماشین. (Machine Learning) دانشگاه فردوسی مشهد دانشکده مهندسی رضا منصفی

NCSS Statistical Software. Reference Intervals

Discrete Probability Distribution

Lecture 1: Empirical Properties of Returns

PyFlux Documentation. Release Ross Taylor

Simple Descriptive Statistics

Fundamentals of Statistics

Contents. An Overview of Statistical Applications CHAPTER 1. Contents (ix) Preface... (vii)

Pricing Barrier Options Using Monte Carlo Simulation Pricing Options with Python

Standardized Data Percentiles, Quartiles and Box Plots Grouped Data Skewness and Kurtosis

(And getting familiar with R) Jan. 8th, School of Information, University of Michigan. SI 544 Descriptive Statistics

Moments and Measures of Skewness and Kurtosis

Module Tag PSY_P2_M 7. PAPER No.2: QUANTITATIVE METHODS MODULE No.7: NORMAL DISTRIBUTION

minimize f(x) subject to f(x) 0 h(x) = 0, 14.1 Quadratic Programming and Portfolio Optimization

Booth School of Business, University of Chicago Business 41202, Spring Quarter 2016, Mr. Ruey S. Tsay. Solutions to Midterm

CHAPTER 6 Random Variables

Tests for Two Variances

Introduction to Statistics I

Statistical Intervals. Chapter 7 Stat 4570/5570 Material from Devore s book (Ed 8), and Cengage

Week 2 Quantitative Analysis of Financial Markets Hypothesis Testing and Confidence Intervals

Model Paper Statistics Objective. Paper Code Time Allowed: 20 minutes

Non-Inferiority Tests for Two Means in a 2x2 Cross-Over Design using Differences

2.1 Properties of PDFs

2.4 STATISTICAL FOUNDATIONS

A Study of Stock Return Distributions of Leading Indian Bank s

Two-Sample T-Test for Superiority by a Margin

Manager Comparison Report June 28, Report Created on: July 25, 2013

1) 3 points Which of the following is NOT a measure of central tendency? a) Median b) Mode c) Mean d) Range

An Empirical Research on Chinese Stock Market Volatility Based. on Garch

Two-Sample T-Test for Non-Inferiority

Chapter 3. Numerical Descriptive Measures. Copyright 2016 Pearson Education, Ltd. Chapter 3, Slide 1

MAKING SENSE OF DATA Essentials series

IOP 201-Q (Industrial Psychological Research) Tutorial 5

M3S1 - Binomial Distribution

4.2 Probability Distributions

Key Objectives. Module 2: The Logic of Statistical Inference. Z-scores. SGSB Workshop: Using Statistical Data to Make Decisions

Financial Economics. Runs Test

Lecture 8: Single Sample t test

ECE 340 Probabilistic Methods in Engineering M/W 3-4:15. Lecture 10: Continuous RV Families. Prof. Vince Calhoun

Two Hours. Mathematical formula books and statistical tables are to be provided THE UNIVERSITY OF MANCHESTER. 22 January :00 16:00

FV N = PV (1+ r) N. FV N = PVe rs * N 2011 ELAN GUIDES 3. The Future Value of a Single Cash Flow. The Present Value of a Single Cash Flow

SSVI. Antoine Jacquier. SSVI Author: Title:

Two Populations Hypothesis Testing

The Binomial Probability Distribution

Chapter 3 Discrete Random Variables and Probability Distributions

Exchange rate. Level and volatility FxRates

Financial Data Analysis, WS08/09. Roman Liesenfeld, University of Kiel 1

In a binomial experiment of n trials, where p = probability of success and q = probability of failure. mean variance standard deviation

Financial Risk Forecasting Chapter 1 Financial markets, prices and risk

L04: Homework Answer Key

Point Estimation. Stat 4570/5570 Material from Devore s book (Ed 8), and Cengage

Notice that X2 and Y2 are skewed. Taking the SQRT of Y2 reduces the skewness greatly.

Chapter 5 Discrete Probability Distributions. Random Variables Discrete Probability Distributions Expected Value and Variance

Basic Procedure for Histograms

MATH 264 Problem Homework I

Lecture 8. The Binomial Distribution. Binomial Distribution. Binomial Distribution. Probability Distributions: Normal and Binomial

source experience distilled PUBLISHING BIRMINGHAM - MUMBAI

Probability. An intro for calculus students P= Figure 1: A normal integral

Financial Econometrics Jeffrey R. Russell. Midterm 2014 Suggested Solutions. TA: B. B. Deng

Statistical Tables Compiled by Alan J. Terry

Mr. Orchard s Math 141 WIR 8.5, 8.6, 5.1 Week 13

Measures of Central tendency

Transcription:

INTRO TO PORTFOLIO RISK MANAGEMENT IN PYTHON Financial Returns Dakota Wixom Quantitative Analyst QuantCourse.com

Course Overview Learn how to analyze investment return distributions, build portfolios and reduce risk, and identify key factors which are driving portfolio returns. Univariate Investment Risk Portfolio Investing Factor Investing Forecasting and Reducing Risk

Investment Risk What is Risk? Risk in financial markets is a measure of uncertainty Dispersion or variance of financial returns How do you typically measure risk? Standard deviation or variance of daily returns Kurtosis of the daily returns distribution Skewness of the daily returns distribution Historical drawdown

Financial Risk RETURNS PROBABILITY

A Tale of Two Returns Returns are derived from stock prices Discrete returns (simple returns) are the most commonly used, and represent periodic (e.g. daily, weekly, monthly, etc.) price movements Log returns are often used in academic research and financial modeling. They assume continuous compounding.

Calculating Stock Returns Discrete returns are calculated as the change in price as a percentage of the previous period s price

Calculating Log Returns Log returns are calculated as the difference between the log of two prices Log returns aggregate across time, while discrete returns aggregate across assets

Calculating Stock Returns in Python STEP 1: Load in stock prices data and store it as a pandas DataFrame organized by date: In [1]: import pandas as pd In [2]: StockPrices = pd.read_csv('stockdata.csv', parse_dates=['date']) In [3]: StockPrices = StockPrices.sort_values(by='Date') In [4]: StockPrices.set_index('Date', inplace=true)

Calculating Stock Returns in Python STEP 2: Calculate daily returns of the adjusted close prices and append the returns as a new column in the DataFrame: In [1]: StockPrices["Returns"] = StockPrices["Adj Close"].pct_change() In [2]: StockPrices["Returns"].head()

Visualizing Return Distributions In [1]: import matplotlib.pyplot as plt In [2]: plt.hist(stockprices["returns"].dropna(), bins=75, density=false) In [3]: plt.show()

INTRO TO PORTFOLIO RISK MANAGEMENT IN PYTHON Let's practice!

INTRO TO PORTFOLIO RISK MANAGEMENT IN PYTHON Mean, Variance, and Normal Distributions Dakota Wixom Quantitative Analyst QuantCourse.com

Moments of Distributions Probability distributions have the following moments: 1) Mean (μ) 2) Variance ( σ 2 ) 3) Skewness 4) Kurtosis

The Normal Distribution There are many types of distributions. Some are normal and some are nonnormal. A random variable with a Gaussian distribution is said to be normally distributed. Normal Distributions have the following properties: Mean = μ Variance = σ Skewness = 0 Kurtosis = 3 2

The Standard Normal Distribution The Standard Normal is a special case of the Normal Distribution when: σ = 1 μ = 0

Comparing Against a Normal Distribution Normal distributions have a skewness near 0 and a kurtosis near 3. Financial returns tend not to be normally distributed Financial returns can have high kurtosis

Comparing Against a Normal Distribution

Calculating Mean Returns in Python To calculate the average daily return, use the np.mean() function: In [1]: import numpy as np In [2]: np.mean(stockprices["returns"]) Out [2]: 0.0003 To calculate the average annualized return assuming 252 trading days in a year: In [1]: import numpy as np In [2]: ((1+np.mean(StockPrices["Returns"]))**252)-1 Out [2]: 0.0785

Standard Deviation and Variance Standard Deviation (Volatility) Variance = σ 2 Often represented in mathematical notation as σ, or referred to as volatility An investment with higher σ is viewed as a higher risk investment Measures the dispersion of returns

Standard Deviation and Variance in Python Assume you have pre-loaded stock returns data in the StockData object. To calculate the periodic standard deviation of returns: In [1]: import numpy as np In [2]: np.std(stockprices["returns"]) Out [2]: 0.0256 To calculate variance, simply square the standard deviation: In [1]: np.std(stockprices["returns"])**2 Out [2]: 0.000655

Scaling Volatility Volatility scales with the square root of time You can normally assume 252 trading days in a given year, and 21 trading days in a given month

Scaling Volatility in Python Assume you have pre-loaded stock returns data in the StockData object. To calculate the annualized volatility of returns: In [1]: import numpy as np In [2]: np.std(stockprices["returns"]) * np.sqrt(252) Out [2]: 0.3071

INTRO TO PORTFOLIO RISK MANAGEMENT IN PYTHON Let's practice!

INTRO TO PORTFOLIO RISK MANAGEMENT IN PYTHON Skewness and Kurtosis Dakota Wixom Quantitative Analyst QuantCourse.com

Skewness Skewness is the third moment of a distribution. Negative Skew: The mass of the distribution is concentrated on the right. Usually a right-leaning curve Positive Skew: The mass of the distribution is concentrated on the left. Usually a left-leaning curve In finance, you would tend to want positive skewness

Skewness in Python Assume you have pre-loaded stock returns data in the StockData object. To calculate the skewness of returns: In [1]: from scipy.stats import skew In [2]: skew(stockdata["returns"].dropna()) Out [2]: 0.225 Note that the skewness is higher than 0 in this example, suggesting non-normality.

Kurtosis Kurtosis is a measure of the thickness of the tails of a distribution Most financial returns are leptokurtic Leptokurtic: When a distribution has positive excess kurtosis (kurtosis greater than 3) Excess Kurtosis: Subtract 3 from the sample kurtosis to calculate Excess Kurtosis

Excess Kurtosis in Python Assume you have pre-loaded stock returns data in the StockData object. To calculate the excess kurtosis of returns: In [1]: from scipy.stats import kurtosis In [2]: kurtosis(stockdata["returns"].dropna()) Out [2]: 2.44 Note the excess kurtosis greater than 0 in this example, suggesting non-normality.

Testing for Normality in Python How do you perform a statistical test for normality? The null hypothesis of the Shapiro-Wilk test is that the data are normally distributed. To run the Shapiro-Wilk normality test in Python: In [1]: from scipy import stats In [2]: p_value = stats.shapiro(stockdata["returns"].dropna())[1] In [3]: if p_value <= 0.05: In [4]: print("null hypothesis of normality is rejected.") In [5]: else: In [6]: print("null hypothesis of normality is accepted.") The p-value is the second variable returned in the list. If the p-value is less than 0.05, the null hypothesis is rejected because the data are most likely non-normal.

INTRO TO PORTFOLIO RISK MANAGEMENT IN PYTHON Let's practice!