SlideShare ist ein Scribd-Unternehmen logo
1 von 32
Computational Finance
Computational Finance
The design, development, testing, and implementation of software that realizes
quantitative financial models for portfolio management and trading (front office), risk
management (middle office), and financial engineering and pricing (back office).
Machine Learning
Statistical Inference, Inductive Reasoning,
Mathematical Optimization – derive a model from past
experiences from which to understand something.
Computer Science
High Performance
Computing, Data
Structures, Algorithms,
Simulation Methods.
Statistics & Math
Probability theory,
Stochastic Calculus,
Optimization theory,
Numerical methods.
Financial Theory
Micro and Macro
Economics, Modern
Portfolio Theory, Risk
Management, and
Security Analysis.
Securities include Fixed
Income, Equities,
Derivatives, Structured
Products, Alternatives,
Commodities, and more.
“There's no question that the computer
scientist is much more highly valued
today than has ever been the case.”
John Lehoczky professor of statistics at Carnegie Mellon speaking about the
future of Quantitative Finance post the 2008 financial crisis.
Source - http://www.americanbanker.com/news/bank-technology/young-
quants-shift-from-risk-taking-to-risk-management-1074476-1.html
The Back Office
CompFin in the Back Office
• Financial Engineers create products and come up with models to price them.
Derivatives are securities whose value depends on some underlying security.
• Many complex derivatives need to be priced using simulation methods which are
computationally expensive. One solution to this is to implement the models to run
on GPU’s which perform floating point and matrix operations much faster.
• How to price a derivative using simulation methods - calibrate a stochastic
processes to the underlying; simulate the underlying; compute the pay-off from
the derivatives for each simulation; then present value the pay-offs to today.
• Calibration is an optimization problem. Given a stochastic process (and historical
data) what are the optimal parameters for the model? The more complex the
model i.e. the more parameters it has, the more difficult it is to optimize.
EX 1 Model Calibration using Hill Climbers
Background Information I
• Stochastic processes are collections of random variables which describe
the evolution of a system over some period of time.
• One stochastic process is the Ornstein Uhlenbeck process. This process is
mean-reverting and is sometimes used to model interest rates.
• The stochastic differential equation for the Ornstein Uhlenbeck model is:
𝑑𝑟𝑡 = 𝑎 𝑏 − 𝑟𝑡 𝑑𝑡 + 𝜎𝑑𝑊𝑡
where 𝑑𝑟𝑡 is the change in an interest rate; 𝑏 is the average interest rate over time; 𝑎 is the
rate of mean-reversion; 𝜎 is volatility; and 𝑊𝑡 is a Wiener process. Wiener process, also
called Brownian Motion, is just a normally distributed stochastic process.
EX 1 Model Calibration using Hill Climbers
Background Information II
• So how can we find the correct values for 𝑏, 𝑎, and 𝜎? This is where some
machine learning (optimization) can come in handy.
• From the SDE for the Ornstein Uhlenbeck process we saw that there is
some relationship between the previous and the next interest rate.
• Multiple linear regression is a statistical way of expressing the linear
relationship between a dependent variable and independent variables.
𝑦 = 𝛽1 𝑥1 + ⋯ + 𝛽 𝑛 𝑥 𝑛 + 𝜀
• Hill climbing can be used to find the optimal values for 𝛽1 … 𝛽 𝑛 and 𝜀 i.e.
we search for the values which minimize some objective function.
EX 1 Model Calibration using Hill Climbers
Example Output
• The relationship between 𝑟𝑡−1 and 𝑟𝑡
EX 1 Model Calibration using Hill Climbers
Approach taken I
• Generate a random solution 𝑧, whose value represents the vector,
𝛽1, 𝛽2, … , 𝛽 𝑛 . Then generate a set of m neighbors to 𝑧, Z ∈ 𝒛 𝟏
′
, … , 𝒛 𝒎
′
,
calculate the solution with the best fitness, 𝒛∗, and update z ← 𝒛∗. Repeat.
• The fitness is measured by the distance between the regression line and
the points. Remember the points are pairs of (𝑟𝑡−1, 𝑟𝑡). Given any 𝑟𝑡−1 and
a solution we can compute the expected value for 𝑟𝑡′ and vice versa.
• The objective is to minimize the sum
of the product of the distance
between each 𝑟𝑡′ (given 𝑟𝑡−1) and 𝑟𝑡;
and each 𝑟𝑡−1′ (given 𝑟𝑡) and 𝑟𝑡−1. This
is also called the sum of perpendicular
offsets from a regression line.
EX 1 Model Calibration using Hill Climbers
Example Output I
• The result – the hill-climber algorithm finds a nice line between 𝑟𝑡−1 and 𝑟𝑡
EX 1 Model Calibration using Hill Climbers
Approach Taken II
• Now using some pretty fancy mathematics which uses the horizontal,
vertical, and perpendicular offsets … as well as the sum of 𝑟𝑡−1
2
and 𝑟𝑡
2
we
can derive the approximate parameter values for the Ornstein-Uhlenbeck
stochastic process. Then we have successfully calibrated the model .
• For the intrepid student here is a link to the fancy mathematics -
http://www.sitmo.com/article/calibrating-the-ornstein-uhlenbeck-model/
EX 1 Model Calibration using Hill Climbers
Example Output II
• The resulting interest rates have similar statistical properties,
– Known process – {𝑏 = 0.75, 𝑎 = 3.0, 𝜎 = 0.25}
– Regressed values – {𝑏 = 0.72, 𝑎 = 3.2, 𝜎 = 0.25}
The Middle Office
CompFin in the Middle Office
• Quantitative Analysts in the middle office are responsible for managing financial
risks, validating back-office models, and ongoing financial reporting.
• Financial risk can be broken down into many ways. One definition of risk is the
factors which drive return. Factors could include market volatility, interest rate
volatility, foreign exchange rate fluctuations, credit-worthiness of individuals, etc.
• The role of computational finance in this space is to build models which quantify
the factors of financial risk. For example, models would answer questions like:
– What is the maximum one-day loss on this portfolio within a 99% confidence interval? (VaR)
– How sensitive is this portfolio / security to a one basis point increase in interest rates? (PV01)
– What is the probability of our creditors defaulting within the next year? (Credit Scorecards)
• The biggest applications of machine learning in the middle office is credit risk
management (default probabilities) and fraud detection (behaviour analysis).
EX 2 Credit Risk Modelling using Neural Networks
Background Information I
• Credit risk is the risk that somebody will default on their credit. It is important for
banks to predict what the probability of somebody defaulting is prior to them
issuing loans. One technique for credit scoring is to use neural networks.
• The inputs into the neural network is data about the individual – age, income, net
worth, etc. There are example credit data sets on the UCI machine learning page.
• A neural network is a computational model that approximates the relationship
between a set of independent variables (inputs) and some dependent variable
(output). In that way it is very similar to a multiple linear regression.
• In fact, neurons in a neural network are MLR’s which feed into (usually) some non-
linear activation function e.g. sigmoid or tan-h. In other words, a neural network is
a set of non-linear regressions between the inputs and the outputs.
EX 2 Credit Risk Modelling using Neural Networks
Background Information II
One perceptron acts
similarly to a linear / non-
linear regression
Multiple perceptrons
connected together form
a set of linear / non-linear
regression functions
which essentially
approximate a complex
function between the
inputs and outputs
EX 2 Credit Risk Modelling using Neural Networks
Background Information III
• The objective of a neural network is to optimize the weights of the inputs into
each one of the perceptrons such that the error of the network is minimized. This
is often done using the Back-Propagation learning algorithm (gradient descent)
• This technique works by calculating the partial derivative of the sum-squared error
with respect to the weights for each neuron (automatic differentiation) and
adjusting the weights by the negative gradient. Basically it goes down the hill.
Minimize the sum-
squared error
(distance squared
between the expected
values a.k.a targets
and the output
produced by the
neural network an
input pattern)
EX 2 Credit Risk Modelling using Neural Networks
Background Information IV
EX 2 Credit Risk Modelling using Neural Networks
Background Information V
• But … the weights in a neural network can be viewed in vector notation. As such,
you can use any optimization algorithm to train a neural network including hill-
climbers, particle swarm optimization, genetic algorithms, random search, etc.
EX 2 Credit Risk Modelling using Neural Networks
Approach Taken
• Download some historical credit data from the UCI Machine Learning
repository online. This contains data in the form,
– Attributes -> Target Value
• Wrangle the data until it is represented using values (not characters) and
is within the active range of the activation functions in the NN.
• Split the data into a training and a testing (validation) set. Train the neural
network on the testing set until it has learn the relationship between the
input attributes and the target value (credit risk or not credit risk)
• Then test the neural network on the testing set to check for over-fitting.
EX 2 Credit Risk Modelling using Neural Networks
Example Output I
Weight Matrices are a good way to understand (non-deep) neural networks
Initial Weight Matrix Final Weight Matrix
EX 2 Credit Risk Modelling using Neural Networks
Example Output II
Accuracy on Training set = 85.87896253602305 %
Accuracy on Testing set = 83.5734870317003 %
Good! Not over-fitting
The Front Office
CompFin in the Front Office
• Arguably the most exciting (and best compensated) application of computational
finance is the front office. Front office quantitative analysts or traders are mostly
responsible for constructing portfolios and algorithmic trading strategies.
• Portfolio optimization involves trying to determine how much capital to invest into
which assets in the portfolio. This involves forecasting the expected risk and return
of individual assets in the portfolio (can be done using Machine Learning) and then
changing the weights of the portfolio to maximize risk adjusted return.
• Quantitative trading strategies are powered by models which consider different
factors such as momentum, mean reversion, quantitative value, and events to
make trading decisions i.e. what to buy and when. Some firms use neural networks
and other machine learning models but be-warned, markets are dynamic.
EX 3 Portfolio Optimization using PSO
Background Information I
• Portfolio optimization is the problem of apportioning a given amount of capital
between the constituent assets of a portfolio such that the expected risk-adjusted
return of the portfolio is maximized over some future period of time.
– Inputs – future expectations of risk and return for each asset
– Inputs – expected correlation matrix between each one of the assets
– Outputs – the weight of capital which should be allocated to each asset
– Objective – maximize the expected risk-adjusted-return of the portfolio e.g. Sharpe Ratio
• There are many different measures of risk-adjusted-return. The first phase of my
Masters research involves characterizing these functions in high dimensional space
(a large number of assets) under various equality and inequality constraints.
• The most popular measure of risk adjusted return is the Sharpe Ratio
𝑠ℎ𝑎𝑟𝑝𝑒 =
𝐸(𝑟𝑃 − 𝑟𝑓)
𝜎 𝑃
EX 3 Portfolio Optimization using PSO
Background Information II
• How do you calculate the expected returns for each asset?
– Option 1 – use historical mean return assuming that the distribution is stationary
– Option 2 – forecast expected returns using some technique e.g. neural networks / quant method
• How do you calculate the expected risk of each asset?
– Option 1 – use historical volatility again assuming that the distribution is stationary
– Option 2 – use a model e.g. stochastic process to simulate how the asset evolves over time
• How do you get the expected risk and return of the portfolio?
– Expected return is equal to the sum product of the expected return on the assets and the weights
𝑟𝑃 =
𝑖=1
𝑛
𝑤𝑖 𝐸(𝑟𝑖)
– The expected risk of the portfolio is equal to the sum product of the volatilities minus diversification
𝜎 𝑃
2
=
𝑖=1
𝑛
𝑗=1
𝑛
𝑤𝑖 𝑤𝑗 𝑐𝑜𝑣(𝑟𝑖 𝑟𝑗) =
𝑖=1
𝑛
𝑗=1
𝑛
𝑤𝑖 𝑤𝑗 𝜎𝑖 𝜎𝑗 𝜌𝑖𝑗
EX 3 Portfolio Optimization using PSO
Background Information III
• Particle Swarm Optimization is a meta-heuristic population-based global nature-
inspired optimization algorithm … whew!
• The algorithm essentially uses direct-search (line-of-sight) method to update the
solutions in the swarm. I.e. a solution is directed towards two points – it’s personal
best position to date; and the global best-position (the best personal best)
• The position update rule for the canonical g-best PSO is,
𝑥𝑖 𝑡 + 1 = 𝑥𝑖 𝑡 + 𝑣𝑖 𝑡 + 1 where
𝑣𝑖𝑗 𝑡 + 1 = 𝑣𝑖𝑗 𝑡 + 𝑐1 𝑟1𝑗 𝑡 𝑦𝑖𝑗 𝑡 − 𝑥𝑖𝑗 𝑡 + 𝑐2 𝑟2𝑗(𝑡)[𝑦′𝑖𝑗(𝑡) − 𝑥𝑖𝑗(𝑡)]
• That’s complicated, but basically it boils down to :- next solution = current solution
plus velocity; where next velocity = current velocity + cognitive component (move
towards the personal best) + social component (move towards the global best)
EX 3 Portfolio Optimization using PSO
Background Information IV
• Illustration of how PSO works in a ‘two dimensional’ case
• Each particle (vector – green dot) moves (in high dimensional space) towards it’s best
historical position (grey dot) and the best position from the swarm.
• For portfolio optimization each dot (vector) is a portfolio (weight vector)
EX 3 Portfolio Optimization using PSO
Approach Taken
• Download some historical JSE price data from Quandl.com for our portfolio of blue
chip stocks: {SBK, ANG, BIL, SHP, WHL, VOD, MTN, DSY, SLM}
• Define a strategy for predicting what the future returns for each asset will be. Our
strategy is that the previous six months = the next six months.
• Slice the data into six-monthly segments, optimize the portfolio weights on the
historical six months, then calculate the returns in the next six months.
• Doing this from 2010 – 2015, 10 six-month periods, therefore results in 10
optimization problems that happen over-time. Avoid any biases!
• Compare these results to a benchmark portfolio such as an equally weighted
portfolio of the stocks i.e. each stock has an equal weight.
EX 3 Portfolio Optimization using PSO
Example Output
• This is the output produced from a silly trend-following strategy.
Eq s = 0.0003904503493283587 r = 0.006431238387474281 f = 0.35289313566293007
Op s = 0.0007074653788236298 r = 0.00875007503958214 f = 0.2548364776503159
EX 3 Portfolio Optimization using PSO
Problems with Portfolio Optimization
• In this strategy the assets are expected to produce similar returns in the next six
months as they did in the previous six months. As such the portfolio is optimized
over historical data and the returns from this are calculated and compounded.
• The problem with portfolio optimization is that it maximizes errors. In other words,
garbage-in = garbage-out. The quality of your optimized portfolio is directly
proportional to the accuracy of your model and it’s predictions.
• Other problems with portfolio optimization include biases such as look-ahead bias,
data-mining bias, sample selection bias, random number generator biases, etc.
For more information
• www.Quandl.com – a website with tones of free financial data and a great API.
• www.QuantStart.com – a website dedicated to helping you start your quant career.
• www.Quantocracy.com – an aggregation of mostly quantitative trading blogs.
• www.Quantopian.com – an online python back-testing and paper trading platform.
• www.StuartReid.co.za – where computer science and quantitative finance meet.
• The code used in this lecture is available
https://github.com/StuartGordonReid/Comp-Fin-Lecture

Weitere ähnliche Inhalte

Was ist angesagt?

Lecture 18: Gaussian Mixture Models and Expectation Maximization
Lecture 18: Gaussian Mixture Models and Expectation MaximizationLecture 18: Gaussian Mixture Models and Expectation Maximization
Lecture 18: Gaussian Mixture Models and Expectation Maximizationbutest
 
CREDIT CARD FRAUD DETECTION
CREDIT CARD FRAUD DETECTION CREDIT CARD FRAUD DETECTION
CREDIT CARD FRAUD DETECTION K Srinivas Rao
 
Stock Market Prediction
Stock Market Prediction Stock Market Prediction
Stock Market Prediction SalmanShezad
 
RMMM-Risk Management,Mitigation and Monitoring.
RMMM-Risk Management,Mitigation and Monitoring.RMMM-Risk Management,Mitigation and Monitoring.
RMMM-Risk Management,Mitigation and Monitoring.Aparna Nayak
 
Mixed Effects Models - Autocorrelation
Mixed Effects Models - AutocorrelationMixed Effects Models - Autocorrelation
Mixed Effects Models - AutocorrelationScott Fraundorf
 
Anomaly Detection - Real World Scenarios, Approaches and Live Implementation
Anomaly Detection - Real World Scenarios, Approaches and Live ImplementationAnomaly Detection - Real World Scenarios, Approaches and Live Implementation
Anomaly Detection - Real World Scenarios, Approaches and Live ImplementationImpetus Technologies
 
Stock Market Prediction using Machine Learning
Stock Market Prediction using Machine LearningStock Market Prediction using Machine Learning
Stock Market Prediction using Machine LearningAravind Balaji
 
Machine learning prediction of stock markets
Machine learning prediction of stock marketsMachine learning prediction of stock markets
Machine learning prediction of stock marketsNikola Milosevic
 
Role of a Software Tester
Role of a Software TesterRole of a Software Tester
Role of a Software TesterQAI Global
 
Prediction of House Sales Price
Prediction of House Sales PricePrediction of House Sales Price
Prediction of House Sales PriceAnirvan Ghosh
 
laptop price prediction presentation
laptop price prediction presentationlaptop price prediction presentation
laptop price prediction presentationNeerajNishad4
 
Logistic regression
Logistic regressionLogistic regression
Logistic regressionVARUN KUMAR
 
COCOMO Model For Effort Estimation
COCOMO Model For Effort EstimationCOCOMO Model For Effort Estimation
COCOMO Model For Effort Estimationgrandhiprasuna
 

Was ist angesagt? (20)

Lecture 18: Gaussian Mixture Models and Expectation Maximization
Lecture 18: Gaussian Mixture Models and Expectation MaximizationLecture 18: Gaussian Mixture Models and Expectation Maximization
Lecture 18: Gaussian Mixture Models and Expectation Maximization
 
CREDIT CARD FRAUD DETECTION
CREDIT CARD FRAUD DETECTION CREDIT CARD FRAUD DETECTION
CREDIT CARD FRAUD DETECTION
 
Stock Market Prediction
Stock Market Prediction Stock Market Prediction
Stock Market Prediction
 
RMMM-Risk Management,Mitigation and Monitoring.
RMMM-Risk Management,Mitigation and Monitoring.RMMM-Risk Management,Mitigation and Monitoring.
RMMM-Risk Management,Mitigation and Monitoring.
 
Mixed Effects Models - Autocorrelation
Mixed Effects Models - AutocorrelationMixed Effects Models - Autocorrelation
Mixed Effects Models - Autocorrelation
 
Anomaly Detection - Real World Scenarios, Approaches and Live Implementation
Anomaly Detection - Real World Scenarios, Approaches and Live ImplementationAnomaly Detection - Real World Scenarios, Approaches and Live Implementation
Anomaly Detection - Real World Scenarios, Approaches and Live Implementation
 
Software quality
Software qualitySoftware quality
Software quality
 
Stock Market Prediction using Machine Learning
Stock Market Prediction using Machine LearningStock Market Prediction using Machine Learning
Stock Market Prediction using Machine Learning
 
Machine learning prediction of stock markets
Machine learning prediction of stock marketsMachine learning prediction of stock markets
Machine learning prediction of stock markets
 
Role of a Software Tester
Role of a Software TesterRole of a Software Tester
Role of a Software Tester
 
White box testing
White box testingWhite box testing
White box testing
 
Prediction of House Sales Price
Prediction of House Sales PricePrediction of House Sales Price
Prediction of House Sales Price
 
laptop price prediction presentation
laptop price prediction presentationlaptop price prediction presentation
laptop price prediction presentation
 
Spm chapter 1
Spm chapter 1Spm chapter 1
Spm chapter 1
 
Loan prediction
Loan predictionLoan prediction
Loan prediction
 
Requirement Engineering
Requirement EngineeringRequirement Engineering
Requirement Engineering
 
Housing price prediction
Housing price predictionHousing price prediction
Housing price prediction
 
Introduction to Compiler design
Introduction to Compiler design Introduction to Compiler design
Introduction to Compiler design
 
Logistic regression
Logistic regressionLogistic regression
Logistic regression
 
COCOMO Model For Effort Estimation
COCOMO Model For Effort EstimationCOCOMO Model For Effort Estimation
COCOMO Model For Effort Estimation
 

Ähnlich wie Computational Finance Introductory Lecture

Unit 3 – AIML.pptx
Unit 3 – AIML.pptxUnit 3 – AIML.pptx
Unit 3 – AIML.pptxhiblooms
 
Machine learning Module-2, 6th Semester Elective
Machine learning Module-2, 6th Semester ElectiveMachine learning Module-2, 6th Semester Elective
Machine learning Module-2, 6th Semester ElectiveMayuraD1
 
Machine Learning techniques used in AI.
Machine Learning  techniques used in AI.Machine Learning  techniques used in AI.
Machine Learning techniques used in AI.ArchanaT32
 
Study on Evaluation of Venture Capital Based onInteractive Projection Algorithm
	Study on Evaluation of Venture Capital Based onInteractive Projection Algorithm	Study on Evaluation of Venture Capital Based onInteractive Projection Algorithm
Study on Evaluation of Venture Capital Based onInteractive Projection Algorithminventionjournals
 
Md simulation and stochastic simulation
Md simulation and stochastic simulationMd simulation and stochastic simulation
Md simulation and stochastic simulationAbdulAhad358
 
MACHINE LEARNING AND ITS APPLICATIONS (2).pptx
MACHINE LEARNING AND ITS APPLICATIONS (2).pptxMACHINE LEARNING AND ITS APPLICATIONS (2).pptx
MACHINE LEARNING AND ITS APPLICATIONS (2).pptxssuser442651
 
Introduction to machine learning
Introduction to machine learningIntroduction to machine learning
Introduction to machine learningSanghamitra Deb
 
Multiple-Linear-Regression-Model-Analysis.pptx
Multiple-Linear-Regression-Model-Analysis.pptxMultiple-Linear-Regression-Model-Analysis.pptx
Multiple-Linear-Regression-Model-Analysis.pptxNaryCasila
 
Summer 07-mfin7011-tang1922
Summer 07-mfin7011-tang1922Summer 07-mfin7011-tang1922
Summer 07-mfin7011-tang1922stone55
 
Predicting Employee Attrition
Predicting Employee AttritionPredicting Employee Attrition
Predicting Employee AttritionShruti Mohan
 
cs 601 - lecture 1.pptx
cs 601 - lecture 1.pptxcs 601 - lecture 1.pptx
cs 601 - lecture 1.pptxGopalPatidar13
 
An application of artificial intelligent neural network and discriminant anal...
An application of artificial intelligent neural network and discriminant anal...An application of artificial intelligent neural network and discriminant anal...
An application of artificial intelligent neural network and discriminant anal...Alexander Decker
 
Machine learning in credit risk modeling : a James white paper
Machine learning in credit risk modeling : a James white paperMachine learning in credit risk modeling : a James white paper
Machine learning in credit risk modeling : a James white paperJames by CrowdProcess
 
Codecamp Iasi 7 mai 2011 Monte Carlo Simulation
Codecamp Iasi 7 mai 2011 Monte Carlo SimulationCodecamp Iasi 7 mai 2011 Monte Carlo Simulation
Codecamp Iasi 7 mai 2011 Monte Carlo SimulationCodecamp Romania
 
Machine Learning Essentials Demystified part2 | Big Data Demystified
Machine Learning Essentials Demystified part2 | Big Data DemystifiedMachine Learning Essentials Demystified part2 | Big Data Demystified
Machine Learning Essentials Demystified part2 | Big Data DemystifiedOmid Vahdaty
 

Ähnlich wie Computational Finance Introductory Lecture (20)

Unit 3 – AIML.pptx
Unit 3 – AIML.pptxUnit 3 – AIML.pptx
Unit 3 – AIML.pptx
 
Machine learning Module-2, 6th Semester Elective
Machine learning Module-2, 6th Semester ElectiveMachine learning Module-2, 6th Semester Elective
Machine learning Module-2, 6th Semester Elective
 
Machine Learning techniques used in AI.
Machine Learning  techniques used in AI.Machine Learning  techniques used in AI.
Machine Learning techniques used in AI.
 
Study on Evaluation of Venture Capital Based onInteractive Projection Algorithm
	Study on Evaluation of Venture Capital Based onInteractive Projection Algorithm	Study on Evaluation of Venture Capital Based onInteractive Projection Algorithm
Study on Evaluation of Venture Capital Based onInteractive Projection Algorithm
 
Md simulation and stochastic simulation
Md simulation and stochastic simulationMd simulation and stochastic simulation
Md simulation and stochastic simulation
 
MACHINE LEARNING AND ITS APPLICATIONS (2).pptx
MACHINE LEARNING AND ITS APPLICATIONS (2).pptxMACHINE LEARNING AND ITS APPLICATIONS (2).pptx
MACHINE LEARNING AND ITS APPLICATIONS (2).pptx
 
Introduction to machine learning
Introduction to machine learningIntroduction to machine learning
Introduction to machine learning
 
Multiple-Linear-Regression-Model-Analysis.pptx
Multiple-Linear-Regression-Model-Analysis.pptxMultiple-Linear-Regression-Model-Analysis.pptx
Multiple-Linear-Regression-Model-Analysis.pptx
 
Summer 07-mfin7011-tang1922
Summer 07-mfin7011-tang1922Summer 07-mfin7011-tang1922
Summer 07-mfin7011-tang1922
 
Machine_Learning.pptx
Machine_Learning.pptxMachine_Learning.pptx
Machine_Learning.pptx
 
Predicting Employee Attrition
Predicting Employee AttritionPredicting Employee Attrition
Predicting Employee Attrition
 
cs 601 - lecture 1.pptx
cs 601 - lecture 1.pptxcs 601 - lecture 1.pptx
cs 601 - lecture 1.pptx
 
An application of artificial intelligent neural network and discriminant anal...
An application of artificial intelligent neural network and discriminant anal...An application of artificial intelligent neural network and discriminant anal...
An application of artificial intelligent neural network and discriminant anal...
 
Machine learning in credit risk modeling : a James white paper
Machine learning in credit risk modeling : a James white paperMachine learning in credit risk modeling : a James white paper
Machine learning in credit risk modeling : a James white paper
 
Or ppt,new
Or ppt,newOr ppt,new
Or ppt,new
 
MACHINE LEARNING.pptx
MACHINE LEARNING.pptxMACHINE LEARNING.pptx
MACHINE LEARNING.pptx
 
Codecamp Iasi 7 mai 2011 Monte Carlo Simulation
Codecamp Iasi 7 mai 2011 Monte Carlo SimulationCodecamp Iasi 7 mai 2011 Monte Carlo Simulation
Codecamp Iasi 7 mai 2011 Monte Carlo Simulation
 
Ml ppt at
Ml ppt atMl ppt at
Ml ppt at
 
Machine Learning Essentials Demystified part2 | Big Data Demystified
Machine Learning Essentials Demystified part2 | Big Data DemystifiedMachine Learning Essentials Demystified part2 | Big Data Demystified
Machine Learning Essentials Demystified part2 | Big Data Demystified
 
Credit scorecard
Credit scorecardCredit scorecard
Credit scorecard
 

Kürzlich hochgeladen

Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfMarket Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfRachmat Ramadhan H
 
Midocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxMidocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxolyaivanovalion
 
Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFxolyaivanovalion
 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% SecurePooja Nehwal
 
BabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxBabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxolyaivanovalion
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxJohnnyPlasten
 
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...amitlee9823
 
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...SUHANI PANDEY
 
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...shambhavirathore45
 
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779Delhi Call girls
 
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightCheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightDelhi Call girls
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz1
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Researchmichael115558
 
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort ServiceBDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort ServiceDelhi Call girls
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfMarinCaroMartnezBerg
 

Kürzlich hochgeladen (20)

Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfMarket Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
 
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
 
Midocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxMidocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFx
 
Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFx
 
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get CytotecAbortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
 
BabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxBabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptx
 
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts ServiceCall Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptx
 
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
 
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
 
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...
 
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
 
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightCheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signals
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Research
 
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort ServiceBDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdf
 

Computational Finance Introductory Lecture

  • 2. Computational Finance The design, development, testing, and implementation of software that realizes quantitative financial models for portfolio management and trading (front office), risk management (middle office), and financial engineering and pricing (back office). Machine Learning Statistical Inference, Inductive Reasoning, Mathematical Optimization – derive a model from past experiences from which to understand something. Computer Science High Performance Computing, Data Structures, Algorithms, Simulation Methods. Statistics & Math Probability theory, Stochastic Calculus, Optimization theory, Numerical methods. Financial Theory Micro and Macro Economics, Modern Portfolio Theory, Risk Management, and Security Analysis. Securities include Fixed Income, Equities, Derivatives, Structured Products, Alternatives, Commodities, and more.
  • 3. “There's no question that the computer scientist is much more highly valued today than has ever been the case.” John Lehoczky professor of statistics at Carnegie Mellon speaking about the future of Quantitative Finance post the 2008 financial crisis. Source - http://www.americanbanker.com/news/bank-technology/young- quants-shift-from-risk-taking-to-risk-management-1074476-1.html
  • 5. CompFin in the Back Office • Financial Engineers create products and come up with models to price them. Derivatives are securities whose value depends on some underlying security. • Many complex derivatives need to be priced using simulation methods which are computationally expensive. One solution to this is to implement the models to run on GPU’s which perform floating point and matrix operations much faster. • How to price a derivative using simulation methods - calibrate a stochastic processes to the underlying; simulate the underlying; compute the pay-off from the derivatives for each simulation; then present value the pay-offs to today. • Calibration is an optimization problem. Given a stochastic process (and historical data) what are the optimal parameters for the model? The more complex the model i.e. the more parameters it has, the more difficult it is to optimize.
  • 6. EX 1 Model Calibration using Hill Climbers Background Information I • Stochastic processes are collections of random variables which describe the evolution of a system over some period of time. • One stochastic process is the Ornstein Uhlenbeck process. This process is mean-reverting and is sometimes used to model interest rates. • The stochastic differential equation for the Ornstein Uhlenbeck model is: 𝑑𝑟𝑡 = 𝑎 𝑏 − 𝑟𝑡 𝑑𝑡 + 𝜎𝑑𝑊𝑡 where 𝑑𝑟𝑡 is the change in an interest rate; 𝑏 is the average interest rate over time; 𝑎 is the rate of mean-reversion; 𝜎 is volatility; and 𝑊𝑡 is a Wiener process. Wiener process, also called Brownian Motion, is just a normally distributed stochastic process.
  • 7. EX 1 Model Calibration using Hill Climbers Background Information II • So how can we find the correct values for 𝑏, 𝑎, and 𝜎? This is where some machine learning (optimization) can come in handy. • From the SDE for the Ornstein Uhlenbeck process we saw that there is some relationship between the previous and the next interest rate. • Multiple linear regression is a statistical way of expressing the linear relationship between a dependent variable and independent variables. 𝑦 = 𝛽1 𝑥1 + ⋯ + 𝛽 𝑛 𝑥 𝑛 + 𝜀 • Hill climbing can be used to find the optimal values for 𝛽1 … 𝛽 𝑛 and 𝜀 i.e. we search for the values which minimize some objective function.
  • 8. EX 1 Model Calibration using Hill Climbers Example Output • The relationship between 𝑟𝑡−1 and 𝑟𝑡
  • 9. EX 1 Model Calibration using Hill Climbers Approach taken I • Generate a random solution 𝑧, whose value represents the vector, 𝛽1, 𝛽2, … , 𝛽 𝑛 . Then generate a set of m neighbors to 𝑧, Z ∈ 𝒛 𝟏 ′ , … , 𝒛 𝒎 ′ , calculate the solution with the best fitness, 𝒛∗, and update z ← 𝒛∗. Repeat. • The fitness is measured by the distance between the regression line and the points. Remember the points are pairs of (𝑟𝑡−1, 𝑟𝑡). Given any 𝑟𝑡−1 and a solution we can compute the expected value for 𝑟𝑡′ and vice versa. • The objective is to minimize the sum of the product of the distance between each 𝑟𝑡′ (given 𝑟𝑡−1) and 𝑟𝑡; and each 𝑟𝑡−1′ (given 𝑟𝑡) and 𝑟𝑡−1. This is also called the sum of perpendicular offsets from a regression line.
  • 10. EX 1 Model Calibration using Hill Climbers Example Output I • The result – the hill-climber algorithm finds a nice line between 𝑟𝑡−1 and 𝑟𝑡
  • 11. EX 1 Model Calibration using Hill Climbers Approach Taken II • Now using some pretty fancy mathematics which uses the horizontal, vertical, and perpendicular offsets … as well as the sum of 𝑟𝑡−1 2 and 𝑟𝑡 2 we can derive the approximate parameter values for the Ornstein-Uhlenbeck stochastic process. Then we have successfully calibrated the model . • For the intrepid student here is a link to the fancy mathematics - http://www.sitmo.com/article/calibrating-the-ornstein-uhlenbeck-model/
  • 12. EX 1 Model Calibration using Hill Climbers Example Output II • The resulting interest rates have similar statistical properties, – Known process – {𝑏 = 0.75, 𝑎 = 3.0, 𝜎 = 0.25} – Regressed values – {𝑏 = 0.72, 𝑎 = 3.2, 𝜎 = 0.25}
  • 14. CompFin in the Middle Office • Quantitative Analysts in the middle office are responsible for managing financial risks, validating back-office models, and ongoing financial reporting. • Financial risk can be broken down into many ways. One definition of risk is the factors which drive return. Factors could include market volatility, interest rate volatility, foreign exchange rate fluctuations, credit-worthiness of individuals, etc. • The role of computational finance in this space is to build models which quantify the factors of financial risk. For example, models would answer questions like: – What is the maximum one-day loss on this portfolio within a 99% confidence interval? (VaR) – How sensitive is this portfolio / security to a one basis point increase in interest rates? (PV01) – What is the probability of our creditors defaulting within the next year? (Credit Scorecards) • The biggest applications of machine learning in the middle office is credit risk management (default probabilities) and fraud detection (behaviour analysis).
  • 15. EX 2 Credit Risk Modelling using Neural Networks Background Information I • Credit risk is the risk that somebody will default on their credit. It is important for banks to predict what the probability of somebody defaulting is prior to them issuing loans. One technique for credit scoring is to use neural networks. • The inputs into the neural network is data about the individual – age, income, net worth, etc. There are example credit data sets on the UCI machine learning page. • A neural network is a computational model that approximates the relationship between a set of independent variables (inputs) and some dependent variable (output). In that way it is very similar to a multiple linear regression. • In fact, neurons in a neural network are MLR’s which feed into (usually) some non- linear activation function e.g. sigmoid or tan-h. In other words, a neural network is a set of non-linear regressions between the inputs and the outputs.
  • 16. EX 2 Credit Risk Modelling using Neural Networks Background Information II One perceptron acts similarly to a linear / non- linear regression Multiple perceptrons connected together form a set of linear / non-linear regression functions which essentially approximate a complex function between the inputs and outputs
  • 17. EX 2 Credit Risk Modelling using Neural Networks Background Information III • The objective of a neural network is to optimize the weights of the inputs into each one of the perceptrons such that the error of the network is minimized. This is often done using the Back-Propagation learning algorithm (gradient descent) • This technique works by calculating the partial derivative of the sum-squared error with respect to the weights for each neuron (automatic differentiation) and adjusting the weights by the negative gradient. Basically it goes down the hill. Minimize the sum- squared error (distance squared between the expected values a.k.a targets and the output produced by the neural network an input pattern)
  • 18. EX 2 Credit Risk Modelling using Neural Networks Background Information IV
  • 19. EX 2 Credit Risk Modelling using Neural Networks Background Information V • But … the weights in a neural network can be viewed in vector notation. As such, you can use any optimization algorithm to train a neural network including hill- climbers, particle swarm optimization, genetic algorithms, random search, etc.
  • 20. EX 2 Credit Risk Modelling using Neural Networks Approach Taken • Download some historical credit data from the UCI Machine Learning repository online. This contains data in the form, – Attributes -> Target Value • Wrangle the data until it is represented using values (not characters) and is within the active range of the activation functions in the NN. • Split the data into a training and a testing (validation) set. Train the neural network on the testing set until it has learn the relationship between the input attributes and the target value (credit risk or not credit risk) • Then test the neural network on the testing set to check for over-fitting.
  • 21. EX 2 Credit Risk Modelling using Neural Networks Example Output I Weight Matrices are a good way to understand (non-deep) neural networks Initial Weight Matrix Final Weight Matrix
  • 22. EX 2 Credit Risk Modelling using Neural Networks Example Output II Accuracy on Training set = 85.87896253602305 % Accuracy on Testing set = 83.5734870317003 % Good! Not over-fitting
  • 24. CompFin in the Front Office • Arguably the most exciting (and best compensated) application of computational finance is the front office. Front office quantitative analysts or traders are mostly responsible for constructing portfolios and algorithmic trading strategies. • Portfolio optimization involves trying to determine how much capital to invest into which assets in the portfolio. This involves forecasting the expected risk and return of individual assets in the portfolio (can be done using Machine Learning) and then changing the weights of the portfolio to maximize risk adjusted return. • Quantitative trading strategies are powered by models which consider different factors such as momentum, mean reversion, quantitative value, and events to make trading decisions i.e. what to buy and when. Some firms use neural networks and other machine learning models but be-warned, markets are dynamic.
  • 25. EX 3 Portfolio Optimization using PSO Background Information I • Portfolio optimization is the problem of apportioning a given amount of capital between the constituent assets of a portfolio such that the expected risk-adjusted return of the portfolio is maximized over some future period of time. – Inputs – future expectations of risk and return for each asset – Inputs – expected correlation matrix between each one of the assets – Outputs – the weight of capital which should be allocated to each asset – Objective – maximize the expected risk-adjusted-return of the portfolio e.g. Sharpe Ratio • There are many different measures of risk-adjusted-return. The first phase of my Masters research involves characterizing these functions in high dimensional space (a large number of assets) under various equality and inequality constraints. • The most popular measure of risk adjusted return is the Sharpe Ratio 𝑠ℎ𝑎𝑟𝑝𝑒 = 𝐸(𝑟𝑃 − 𝑟𝑓) 𝜎 𝑃
  • 26. EX 3 Portfolio Optimization using PSO Background Information II • How do you calculate the expected returns for each asset? – Option 1 – use historical mean return assuming that the distribution is stationary – Option 2 – forecast expected returns using some technique e.g. neural networks / quant method • How do you calculate the expected risk of each asset? – Option 1 – use historical volatility again assuming that the distribution is stationary – Option 2 – use a model e.g. stochastic process to simulate how the asset evolves over time • How do you get the expected risk and return of the portfolio? – Expected return is equal to the sum product of the expected return on the assets and the weights 𝑟𝑃 = 𝑖=1 𝑛 𝑤𝑖 𝐸(𝑟𝑖) – The expected risk of the portfolio is equal to the sum product of the volatilities minus diversification 𝜎 𝑃 2 = 𝑖=1 𝑛 𝑗=1 𝑛 𝑤𝑖 𝑤𝑗 𝑐𝑜𝑣(𝑟𝑖 𝑟𝑗) = 𝑖=1 𝑛 𝑗=1 𝑛 𝑤𝑖 𝑤𝑗 𝜎𝑖 𝜎𝑗 𝜌𝑖𝑗
  • 27. EX 3 Portfolio Optimization using PSO Background Information III • Particle Swarm Optimization is a meta-heuristic population-based global nature- inspired optimization algorithm … whew! • The algorithm essentially uses direct-search (line-of-sight) method to update the solutions in the swarm. I.e. a solution is directed towards two points – it’s personal best position to date; and the global best-position (the best personal best) • The position update rule for the canonical g-best PSO is, 𝑥𝑖 𝑡 + 1 = 𝑥𝑖 𝑡 + 𝑣𝑖 𝑡 + 1 where 𝑣𝑖𝑗 𝑡 + 1 = 𝑣𝑖𝑗 𝑡 + 𝑐1 𝑟1𝑗 𝑡 𝑦𝑖𝑗 𝑡 − 𝑥𝑖𝑗 𝑡 + 𝑐2 𝑟2𝑗(𝑡)[𝑦′𝑖𝑗(𝑡) − 𝑥𝑖𝑗(𝑡)] • That’s complicated, but basically it boils down to :- next solution = current solution plus velocity; where next velocity = current velocity + cognitive component (move towards the personal best) + social component (move towards the global best)
  • 28. EX 3 Portfolio Optimization using PSO Background Information IV • Illustration of how PSO works in a ‘two dimensional’ case • Each particle (vector – green dot) moves (in high dimensional space) towards it’s best historical position (grey dot) and the best position from the swarm. • For portfolio optimization each dot (vector) is a portfolio (weight vector)
  • 29. EX 3 Portfolio Optimization using PSO Approach Taken • Download some historical JSE price data from Quandl.com for our portfolio of blue chip stocks: {SBK, ANG, BIL, SHP, WHL, VOD, MTN, DSY, SLM} • Define a strategy for predicting what the future returns for each asset will be. Our strategy is that the previous six months = the next six months. • Slice the data into six-monthly segments, optimize the portfolio weights on the historical six months, then calculate the returns in the next six months. • Doing this from 2010 – 2015, 10 six-month periods, therefore results in 10 optimization problems that happen over-time. Avoid any biases! • Compare these results to a benchmark portfolio such as an equally weighted portfolio of the stocks i.e. each stock has an equal weight.
  • 30. EX 3 Portfolio Optimization using PSO Example Output • This is the output produced from a silly trend-following strategy. Eq s = 0.0003904503493283587 r = 0.006431238387474281 f = 0.35289313566293007 Op s = 0.0007074653788236298 r = 0.00875007503958214 f = 0.2548364776503159
  • 31. EX 3 Portfolio Optimization using PSO Problems with Portfolio Optimization • In this strategy the assets are expected to produce similar returns in the next six months as they did in the previous six months. As such the portfolio is optimized over historical data and the returns from this are calculated and compounded. • The problem with portfolio optimization is that it maximizes errors. In other words, garbage-in = garbage-out. The quality of your optimized portfolio is directly proportional to the accuracy of your model and it’s predictions. • Other problems with portfolio optimization include biases such as look-ahead bias, data-mining bias, sample selection bias, random number generator biases, etc.
  • 32. For more information • www.Quandl.com – a website with tones of free financial data and a great API. • www.QuantStart.com – a website dedicated to helping you start your quant career. • www.Quantocracy.com – an aggregation of mostly quantitative trading blogs. • www.Quantopian.com – an online python back-testing and paper trading platform. • www.StuartReid.co.za – where computer science and quantitative finance meet. • The code used in this lecture is available https://github.com/StuartGordonReid/Comp-Fin-Lecture