Lab 16 - Optimization - Nonlinear - Part 2
Lab 16 - Optimization - Nonlinear - Part 2
Lab 16 - Optimization - Nonlinear - Part 2
● Presentation
(20 min)
● Demo’s
(20 min)
● Pro-Tips
(20 mins)
Reproducible Finance with R
“Without the BSU courses, I couldn’t do what
I’m doing.”
Success Story
Luis Francisco Gomez
Lopez
#BusinessScienceSuccess
Agenda
2 Parts
Part 1 (Lab 15)
Linear Programming
Nonlinear Programming
Lab 15
R’s Optimization Toolchain, Part 1
Learning Labs
Lab 14
PRO Customer Churn Survival
Analysis
Every 2-Weeks Lab 13
Wrangling 4.6M Rows of
1-Hour Course Financial Data w/ data.table
Lab 9
Finance in R with tidyquant
R in Industry
The power of R for trading
The power of
R for Trading
R is the best language in the
world for doing rapid
financial analysis
https://www.linkedin.com/pulse/power-r-trading-part-1-ralph-sueppel/
Financial Case Study
Optimize Stock Portfolio
Building a Financial Portfolio
https://business-science.github.io/tidyquant/
Modern Portfolio Theory
Minimize Variance
Harry Markowitz - Nobel Prize
Efficient Frontier
What happens when we
adjust the
Portfolio Return Objective?
Quantitative Decision
Making + Optimization
Optimization (Recap)
80/20 Concepts
Terminology
1 2 3
Objectives Constraints Decision Variables
The goal of the model Decision Rules for the Your problem’s Frame of
model Reference
Always Maximize or
Minimize. Restricts the decision The parameters that your
variables to boundaries optimization model
adjusts
Excel
Data
Constraints
Goal
Types of Optimization Models
Part 1 Part 2
Process & Tools
What we need to know
Financial Optimization Modeling
Step-By-Step
Start Finish
1 2 3
Start Finish
1 2 3
● F_objective
○ Minimize portfolio variance calculation
● F_constraint - Functional Constraint
○ Inputs asset weights, outputs port
○ Return objective set to 40% per year
● L_constraint - Linear Constraint
○ Bounding the weights
Nonlinear Super Power #1
Functional Objective
http://roi.r-forge.r-project.org/introduction.html
Nonlinear Super Power #2
Functional Constraints
http://roi.r-forge.r-project.org/introduction.html
Nonlinear Super Power #3
Linear Constraints
http://roi.r-forge.r-project.org/introduction.html
Nonlinear Super Power #4
Put it all together
Can combine linear (matrix) & nonlinear programming (functions)
Demo
Optimizing a Stock Portfolio
AAPL, AMZN, FB, GOOG, NFLX
Optimization
Secret Tactics & Pro Tips
People get frustrated with
Optimization
Because they fail to start simple
Pro Tip
Design in Excel, then Convert to R
Pros: Data
Sometimes Excel is easier to Calculation
conceptualize
Cons:
● Excel cannot scale (try to do
iterative analysis)
● Excel cannot scale (try to add
1 more stock)
● Excel has difficulties with
nonlinear problems
Pro Tip
Design in Excel, then Convert to R
Cons:
Sometimes R is more difficult to
conceptualize
Pros:
● R can scale (try to do iterative
analysis)
● R can scale (try to add 1 more
stock)
● R is really good with
nonlinear problems
Data Science + Decision Science
Learning Plan
Financial Optimization Modeling
Step-By-Step
Start Finish
1 2 3
Lab 13
101
ROI
Lab 16
ggplot2 & purrr
101 + 201
101 + 201
Business Science University
Our program that will TRANSFORM YOU in weeks, not years.
The program that will deliver YOUR Transformation
-TRACK 3-Course R-Track System
Business Analysis with R Data Science For Business with R R Shiny Web Apps For Business
(DS4B 101-R) (DS4B 201-R) (DS4B 102-R)
Visualization
Data Cleaning &
Manipulation
Key Benefits
End-to-End Churn Project Data Science For Business
Understanding the Problem & (DS4B 201-R)
Preparing Data - Weeks 1-4
Machine Learning & Business Consulting
- Project Setup & Framework
- Business Understanding / Sizing
10 Weeks
Problem
- Tidy Evaluation - rlang
- EDA - Exploring Data -GGally, skimr
- Data Preparation - recipes
- Correlation Analysis
- 3 Challenges
-TRACK BUNDLE
Begin Learning Today
university.business-science.io