Sei sulla pagina 1di 32

[1] Quantitative Finance

(with Python)
Alan Moreira, University of Rochester Simon Graduate School of Business

1
Week 1 road map

Introduction: goals, resources, schedule, course mechanics

Quantitative investing

Computing
o Python: software, resources, and examples

Python basics

Problem set 1

2
Introduction

This is a class about quantitative investing in practice

We will learn how to use data to guide investment decisions

Focus on how to organize, analyze, and investigate financial data sets

We will learn the state of the art in quantitative investing, and learn how
to evaluate new quantitative strategies

Develop tools and programing skills that can be applied widely: asset
management, investment banking, corporate finance, strategy
3
What is quantitative investing?
Use of data (and theory) to systematically construct portfolios

Focus on the statistical properties of asset returns

o Statistical moments: mean, standard deviation, covariance,.

o Use of fundamental data in algorithmic fashion

Often referred to as smart beta in the industry:

4
Does the media attention reflect investor appetite?
Yes, interest among Institutional and Advisory clients is growing

Source: Smart Beta: 2015 global survey findings from asset owners, FTSE Russell 4Q 2015
The number of managers and products is growing rapidly
Investors may be overwhelmed as more asset managers launch products

48%
of US Asset Managers are planning to launch
smart beta strategies to counter the growing
interest in passive investments*

With the increasing number of players, investors may get confused by the variety of labels, along with competing and
overlapping products.

The industry has agreed on little other than the idea that smart beta is generally about investing in factors or styles, but
there is less consensus regarding which factors are valuable.

An open question is whether Smart Beta is a form of index investing or active investing?.

Source: 2015 Product Management & Development Benchmark Survey, Fuse Research Network
Recent Entrants include some well known Asset Managers
Fundamental active managers are entering to compete with passive

Fidelity and FranklinTempleton are among the most recognized firms to announce plans to create new ETFs

Sept 15 Dec 15 Jan 16 Feb 16 April 16

Goldman Sachs Oppenheimer FranklinTempleton T.Rowe Price Fidelity


Launches ActiveBeta ETF Purchases VTL Associates Files for a suite of ETFs to be branded Introduces factor based funds Files for relief to launch
family Franklin LibertyQ branded as QM for Smart Beta ETFs
VTL managed 8 ETFs under the quantitative managed
Strategy is to act as a price brand Revenue Shares
leader in Smart Beta

Assets were converted from


separate accounts

In May of 2016 BlackRock introduced the sub-brand Edge


for the iShares Smart Beta ETFs
US Smart Beta ETF Summary

AUM YTD Flow 1 yr Flow


iShares $ 54,898,745,913.00 $ 9,328,891,051.85 $ 13,297,014,891.45
Vanguard $ 43,537,506,987.00 $ 2,339,875,901.23 $ 2,464,502,994.92
WisdomTree $ 40,234,240,391.00 $ (6,701,163,497.59) $ (7,285,464,464.83)
PowerShares $ 31,492,724,102.00 $ 1,185,913,364.33 $ 1,590,964,010.34
First Trust $ 25,070,097,670.00 $ (1,838,371,404.05) $ 495,537,434.73
Guggenheim $ 16,365,728,972.00 $ (1,355,953,229.35) $ (2,345,280,853.72)

BlackRock has a broad suite of single factor and multi-factor funds and is a leader in Minimum Volatility

Vanguard only offers dividend funds, but dominates flows in the category due to low fee

WisdomTree, First Trust and Guggenheim have all created proprietary index methodologies

Source: Morningstar Direct as of 4/30/15.


What is quantitative investing (or Smart Beta)?

Passive Strategies Active Strategies


hold the market: I buy all the stocks in pick stocks: I bought Apple because it is a
proportion to their total market value good company

Quantitative Investing

Captures well known characteristics of


return--
or styles
Rules based and systematic

transparent

High Capacity

Relatively Low Fee

9
Quantitative investing requires data analysis and computing power

Find new patterns in asset returns

Evaluate an investment strategy

Implement an investment strategy

10
Are you ready?

We will now spend 3 weeks learning how to code and we will slowly
introduce finance concepts

By week 4 we will be in full finance mode, we will still be learning how to


code, but it will be very much in the background

You need to have the will to see this through.

All useful knowledge takes time to build. Trust me when I tell you: These
skills are very useful in the finance world

Lets go! 11
Computing: Why code?

1. To get some task done - we are the user and programmer

o Clean and analyze a data set

2. To produce something for others to use - a programming job

o Portfolio maximizer as a function of investor characteristics

In this class we will mostly focus on 1, but Python is powerful to


accomplish 2 as well
12
What is a code/program?

A sequence of stored instructions

Programs for Humans...

by Charles R. Severance, Python for Everybody (https://www.py4e.com/)


13
Python

We will use the Python language to communicate our orders to our


computer

Why Python?

o Open source, Rich set of packages and libraries

o Very active use community

o Very flexible but still user friendly

o Becoming standard in the financial community


14
Where to Python?

o Interactive
You type directly to Python one line at a time and it responds

Cmd line, IPython

o Script
You enter a sequence of statements (lines) into a file using a text editor and tell Python to
execute the statements in the file

Atom, Spyder, any text processor

o Jupyter notebook
Something in between: interactive, but scale relatively well

We will use Jupyter notebook in this class. I suggest you do the same 15
Python resources

o Coursera: Python for everybody course (https://www.py4e.com/)

o Google Python class: https://developers.google.com/edu/python/

o https://www.codecademy.com/learn/python

o https://lectures.quantecon.org/py/index.html

o Python official page https://www.python.org/

o Anaconda distribution https://www.continuum.io/downloads

o Google any command by writing: python (question?)

16
Course mechanics

Every week
o Powerpoint slides

o Jupyter notebook code

o (Most weeks)Problem sets- Always due Monday night


Group of 4 for problem sets

5 grades: ++,+,0,-,--

You get (_ if you do not deliver anything, (- -) if you cheat (or aided someone cheating)

17
Course mechanics

Two groups
o Rochester students
In-class participation expected

I strongly encourage questions through Piazza forum

o Remote students
Class video available immediately after class

Ask question through Piazza forums: I and TAs promise prompt reply

I will host weekly video office hours, TAs will host office hours dedicated to online students

18
Course mechanics

Piazza
o You can ask questions

o Everyone (Me, TAs , and students) can respond

o Website tracks participation

o Fosters a lot of interaction

o You can also post anonymous, If shy about specific questions

o But I encourage name disclosure so you are rewarded for your participation

o DO NOT post private (to me), unless it is a personal matter


19
Schedule

Module 1: (Week I-III) Python Essentials (Class 1 to 6)

Module 2: (Week IV-V) Portfolios: Theory, Practice and Evaluation (Class 7-10)

Module 3: (Week VI) Market Efficiency and Limits to Arbitrage (Class 11-12)

Module 4: (Week VII): Portfolio construction and Factor investing (Class 13-14)

Module 5: (Week VIII-IX) Time-Series Predictability and (maybe) Asset management

(Class 15-18)

20
Python Basics

21
Some Python code

x = 2
x = x + 2
print(x)

Can you predict the output?


Does your python run this code?
How we call each piece in this paragraph?

22
Some Python code

x = 2 variable
x = x + 2
print(x) constant

Can you predict the output? operator


Does you python run this code?
How we call each piece in this
paragraph?
function

23
Variable Names

How should I name variables?

Do variable names have any meaning?

Does Python interpret these names?

Are there names that I cannot use?

24
Variable Names

How should I name variables?


They should make sense to you and should have the goal of make
the code easier to read for somebody else.

Do variable names have any meaning?

Does Python interpret these names?


Only to humans. Python doesnt care.
Are there names that I cannot use?
Yes. There are some reserved words
25
Reserved Words
You cannot use reserved words as variable names / identifiers

False class return is finally


None if for lambda continue
True def from while nonlocal
and del global not with
as elif try or yield
assert else import pass
break except in raise
(Notebook 1)

27
Appendix

28
Program Flow

Like IKEA furniture assembly instructions, a program is a sequence of


steps to be done in order (add link to ikea furniture instrutions)

Some steps are conditionalthey will only be executed under certain


conditions

Some steps are repeated multiple time

Some steps are stored and used all around through our program

29
Sequential Steps
x=2 Program:
Output:
print(x) x = 2
print(x) 2
x=x+2 x = x + 2 4
print(x)
print(x)

When a program is running, it flows from one step to the next. As


programmers, we set up paths for the program to follow.
x=5
Conditional Steps
Yes
x < 10 ?

print('Smaller') Program:
No Output:
x = 5
Yes if x < 10: Smaller
x > 20 ? print('Smaller') Finis
if x > 20:
print('Bigger') print('Bigger')
No
print('Finis')

print('Finis')
n=5 Repeated Steps
No Yes Output:
n>0? Program:
5
print(n) n = 5 4
while n > 0 :
print(n)
3
n = n -1 n = n 1 2
print('Blastoff!') 1
Blastoff!
Loops (repeated steps) have iteration variables that
print('Blastoff')
change each time through a loop.

Potrebbero piacerti anche