This document discusses machine learning applications in financial engineering and quantitative investing. It covers machine learning techniques for curve construction, model calibration, instrument valuation, and risk measurement in quantitative finance. Specifically, it discusses using machine learning methods for yield curve construction, volatility surface calibration, discount curve calibration, and model parameter estimation from historical data. The goal is to apply machine learning to automate quantitative finance tasks and improve the accuracy of pricing and risk models.
Multi objective optimization and Benchmark functions resultPiyush Agarwal
Implemented Strength Pareto Evolutionary Algorithm (SPEA 2) and Non Dominated Sorting Genetic Algorithm (NSGA II) in MATLAB, Guide Assistant Prof. Divy Kumar, MNNIT Allahabad.
The two algorithms are use to solve multiobjective functions. Tested the algorithms on all the benchmark functions.
Applied both the algorithms to solve Portfolio Optimization satisfying different types of constraints to derive the optimal portfolio.
I am Ben R. I am a Statistics Assignment Expert at statisticshomeworkhelper.com. I hold a Ph.D. in Statistics, from University of Denver, USA. I have been helping students with their homework for the past 5 years. I solve assignments related to Statistics.
Visit statisticshomeworkhelper.com or email info@statisticshomeworkhelper.com.
You can also call on +1 678 648 4277 for any assistance with Statistics Assignments.
I am Simon M. I am a Data Analysis Assignment Expert at statisticsassignmenthelp.com. I hold a Masters in Statistics from, Nottingham Trent University, UK
I have been helping students with their homework for the past 8 years. I solve assignments related to Data Analysis.
Visit statisticsassignmenthelp.com or email info@statisticsassignmenthelp.com.
You can also call on +1 678 648 4277 for any assistance with Data Analysis Assignments.
I am Ronald G. I am a Statistics Assignment Expert at statisticshomeworkhelper.com. I have done Ph.D Statistics from New York University, USA. I have been helping students with their statistics assignments for the past 5 years. You can hire me for any of your statistics assignments.
Visit statisticshomeworkhelper.com or email info@statisticshomeworkhelper.com.
You can also call on +1 678 648 4277 for any assistance with statistics.
I am Nelson. I am a Probability Assignment Expert at statisticsassignmenthelp.com. I hold a Masters in Statistics from, City University of London.
I have been helping students with their homework for the past 5 years. I solve assignments related to Probability. Visit statisticsassignmenthelp.com or email info@statisticsassignmenthelp.com.
You can also call on +1 678 648 4277 for any assistance with Probability Assignments.
Multi objective optimization and Benchmark functions resultPiyush Agarwal
Implemented Strength Pareto Evolutionary Algorithm (SPEA 2) and Non Dominated Sorting Genetic Algorithm (NSGA II) in MATLAB, Guide Assistant Prof. Divy Kumar, MNNIT Allahabad.
The two algorithms are use to solve multiobjective functions. Tested the algorithms on all the benchmark functions.
Applied both the algorithms to solve Portfolio Optimization satisfying different types of constraints to derive the optimal portfolio.
I am Ben R. I am a Statistics Assignment Expert at statisticshomeworkhelper.com. I hold a Ph.D. in Statistics, from University of Denver, USA. I have been helping students with their homework for the past 5 years. I solve assignments related to Statistics.
Visit statisticshomeworkhelper.com or email info@statisticshomeworkhelper.com.
You can also call on +1 678 648 4277 for any assistance with Statistics Assignments.
I am Simon M. I am a Data Analysis Assignment Expert at statisticsassignmenthelp.com. I hold a Masters in Statistics from, Nottingham Trent University, UK
I have been helping students with their homework for the past 8 years. I solve assignments related to Data Analysis.
Visit statisticsassignmenthelp.com or email info@statisticsassignmenthelp.com.
You can also call on +1 678 648 4277 for any assistance with Data Analysis Assignments.
I am Ronald G. I am a Statistics Assignment Expert at statisticshomeworkhelper.com. I have done Ph.D Statistics from New York University, USA. I have been helping students with their statistics assignments for the past 5 years. You can hire me for any of your statistics assignments.
Visit statisticshomeworkhelper.com or email info@statisticshomeworkhelper.com.
You can also call on +1 678 648 4277 for any assistance with statistics.
I am Nelson. I am a Probability Assignment Expert at statisticsassignmenthelp.com. I hold a Masters in Statistics from, City University of London.
I have been helping students with their homework for the past 5 years. I solve assignments related to Probability. Visit statisticsassignmenthelp.com or email info@statisticsassignmenthelp.com.
You can also call on +1 678 648 4277 for any assistance with Probability Assignments.
I am Racheal W. I am a Probability Assignment Expert at statisticsassignmenthelp.com. I hold a Masters in Statistics from, Massachusetts Institute of Technology, USA.
I have been helping students with their homework for the past 7 years. I solve assignments related to probability.
Visit statisticsassignmenthelp.com or email info@statisticsassignmenthelp.com.
You can also call on +1 678 648 4277 for any assistance with probability assignments.
When Classifier Selection meets Information Theory: A Unifying ViewMohamed Farouk
Classifier selection aims to reduce the size of an
ensemble of classifiers in order to improve its efficiency and
classification accuracy. Recently an information-theoretic view
was presented for feature selection. It derives a space of possible
selection criteria and show that several feature selection criteria
in the literature are points within this continuous space. The
contribution of this paper is to export this information-theoretic
view to solve an open issue in ensemble learning which is
classifier selection. We investigated a couple of informationtheoretic
selection criteria that are used to rank classifiers.
I am Josh U. I am a Probability Assignment Expert at statisticsassignmenthelp.com. I hold a Masters in Statistics from St. Edward’s University, USA.
I have been helping students with their homework for the past 5 years. I solve assignments related to Probability. Visit statisticsassignmenthelp.com or email info@statisticsassignmenthelp.com.
You can also call on +1 678 648 4277 for any assistance with Probability Assignments.
This a set of slides explaining the search methods by
Gradient Descent
Simulated Annealing
Hill Climbing
They are still not great, but they are good enough
First part of my NYU Tandon course "Numerical and Simulation Techniques in Fi...Edward D. Weinberger
Aside from showing the framework for my course, these slides show the importance of mathematical theory in solving practical problems. It also discusses engineering aspects of numerical methods.
Natural Language Processing: L03 maths fornlpananth
This presentation discusses probability theory basics, Naive Bayes Classifier with some practical examples. This also introduces graph models for representing joint probability distributions.
Deep Learning: Introduction & Chapter 5 Machine Learning BasicsJason Tsai
Given lecture for Deep Learning 101 study group with Frank Wu on Dec. 9th, 2016.
Reference: https://www.deeplearningbook.org/
Initiated by Taiwan AI Group (https://www.facebook.com/groups/Taiwan.AI.Group/)
Abstract : For many years, Machine Learning has focused on a key issue: the design of input features to solve prediction tasks. In this presentation, we show that many learning tasks from structured output prediction to zero-shot learning can benefit from an appropriate design of output features, broadening the scope of regression. As an illustration, I will briefly review different examples and recent results obtained in my team.
I am Racheal W. I am a Probability Assignment Expert at statisticsassignmenthelp.com. I hold a Masters in Statistics from, Massachusetts Institute of Technology, USA.
I have been helping students with their homework for the past 7 years. I solve assignments related to probability.
Visit statisticsassignmenthelp.com or email info@statisticsassignmenthelp.com.
You can also call on +1 678 648 4277 for any assistance with probability assignments.
When Classifier Selection meets Information Theory: A Unifying ViewMohamed Farouk
Classifier selection aims to reduce the size of an
ensemble of classifiers in order to improve its efficiency and
classification accuracy. Recently an information-theoretic view
was presented for feature selection. It derives a space of possible
selection criteria and show that several feature selection criteria
in the literature are points within this continuous space. The
contribution of this paper is to export this information-theoretic
view to solve an open issue in ensemble learning which is
classifier selection. We investigated a couple of informationtheoretic
selection criteria that are used to rank classifiers.
I am Josh U. I am a Probability Assignment Expert at statisticsassignmenthelp.com. I hold a Masters in Statistics from St. Edward’s University, USA.
I have been helping students with their homework for the past 5 years. I solve assignments related to Probability. Visit statisticsassignmenthelp.com or email info@statisticsassignmenthelp.com.
You can also call on +1 678 648 4277 for any assistance with Probability Assignments.
This a set of slides explaining the search methods by
Gradient Descent
Simulated Annealing
Hill Climbing
They are still not great, but they are good enough
First part of my NYU Tandon course "Numerical and Simulation Techniques in Fi...Edward D. Weinberger
Aside from showing the framework for my course, these slides show the importance of mathematical theory in solving practical problems. It also discusses engineering aspects of numerical methods.
Natural Language Processing: L03 maths fornlpananth
This presentation discusses probability theory basics, Naive Bayes Classifier with some practical examples. This also introduces graph models for representing joint probability distributions.
Deep Learning: Introduction & Chapter 5 Machine Learning BasicsJason Tsai
Given lecture for Deep Learning 101 study group with Frank Wu on Dec. 9th, 2016.
Reference: https://www.deeplearningbook.org/
Initiated by Taiwan AI Group (https://www.facebook.com/groups/Taiwan.AI.Group/)
Abstract : For many years, Machine Learning has focused on a key issue: the design of input features to solve prediction tasks. In this presentation, we show that many learning tasks from structured output prediction to zero-shot learning can benefit from an appropriate design of output features, broadening the scope of regression. As an illustration, I will briefly review different examples and recent results obtained in my team.
This is the slide that Terry. T. Um gave a presentation at Kookmin University in 22 June, 2014. Feel free to share it and please let me know if there is some misconception or something.
(http://t-robotics.blogspot.com)
(http://terryum.io)
Can machine think like human being : A Godelian perspective Jaynarayan Tudu
Presentation is an attempt to build an approach to solve the "Man and Machine" problem looking from various perspectives. Most importantly, the problem is to be built upon the Vedic understanding of life and matter.
A pre conference workshop on Machine Learning was organized as a part of #doppa17, DevOps++ Global Summit 2017. The workshop was conducted by Dr. Vivek Vijay and Dr. Sandeep Yadav. All the copyrights are reserved with the author.
An introduction on how machine learning can assist you in finding, how much is enough to test. Covering the risk formula, and references to how to assess impact, and calculate probabilities across a complex domain.
Chap 8. Optimization for training deep modelsYoung-Geun Choi
연구실 내부 세미나 자료. Goodfellow et al. (2016), Deep Learning, MIT Press의 Chapter 8을 요약/발췌하였습니다. 깊은 신경망(deep neural network) 모형 훈련시 목적함수 최적화 방법으로 흔히 사용되는 방법들을 소개합니다.
Seminar: Gender Board Diversity through Ownership NetworksGRAPE
Seminar on gender diversity spillovers through ownership networks at FAME|GRAPE. Presenting novel research. Studies in economics and management using econometrics methods.
US Economic Outlook - Being Decided - M Capital Group August 2021.pdfpchutichetpong
The U.S. economy is continuing its impressive recovery from the COVID-19 pandemic and not slowing down despite re-occurring bumps. The U.S. savings rate reached its highest ever recorded level at 34% in April 2020 and Americans seem ready to spend. The sectors that had been hurt the most by the pandemic specifically reduced consumer spending, like retail, leisure, hospitality, and travel, are now experiencing massive growth in revenue and job openings.
Could this growth lead to a “Roaring Twenties”? As quickly as the U.S. economy contracted, experiencing a 9.1% drop in economic output relative to the business cycle in Q2 2020, the largest in recorded history, it has rebounded beyond expectations. This surprising growth seems to be fueled by the U.S. government’s aggressive fiscal and monetary policies, and an increase in consumer spending as mobility restrictions are lifted. Unemployment rates between June 2020 and June 2021 decreased by 5.2%, while the demand for labor is increasing, coupled with increasing wages to incentivize Americans to rejoin the labor force. Schools and businesses are expected to fully reopen soon. In parallel, vaccination rates across the country and the world continue to rise, with full vaccination rates of 50% and 14.8% respectively.
However, it is not completely smooth sailing from here. According to M Capital Group, the main risks that threaten the continued growth of the U.S. economy are inflation, unsettled trade relations, and another wave of Covid-19 mutations that could shut down the world again. Have we learned from the past year of COVID-19 and adapted our economy accordingly?
“In order for the U.S. economy to continue growing, whether there is another wave or not, the U.S. needs to focus on diversifying supply chains, supporting business investment, and maintaining consumer spending,” says Grace Feeley, a research analyst at M Capital Group.
While the economic indicators are positive, the risks are coming closer to manifesting and threatening such growth. The new variants spreading throughout the world, Delta, Lambda, and Gamma, are vaccine-resistant and muddy the predictions made about the economy and health of the country. These variants bring back the feeling of uncertainty that has wreaked havoc not only on the stock market but the mindset of people around the world. MCG provides unique insight on how to mitigate these risks to possibly ensure a bright economic future.
how to sell pi coins at high rate quickly.DOT TECH
Where can I sell my pi coins at a high rate.
Pi is not launched yet on any exchange. But one can easily sell his or her pi coins to investors who want to hold pi till mainnet launch.
This means crypto whales want to hold pi. And you can get a good rate for selling pi to them. I will leave the telegram contact of my personal pi vendor below.
A vendor is someone who buys from a miner and resell it to a holder or crypto whale.
Here is the telegram contact of my vendor:
@Pi_vendor_247
how to sell pi coins effectively (from 50 - 100k pi)DOT TECH
Anywhere in the world, including Africa, America, and Europe, you can sell Pi Network Coins online and receive cash through online payment options.
Pi has not yet been launched on any exchange because we are currently using the confined Mainnet. The planned launch date for Pi is June 28, 2026.
Reselling to investors who want to hold until the mainnet launch in 2026 is currently the sole way to sell.
Consequently, right now. All you need to do is select the right pi network provider.
Who is a pi merchant?
An individual who buys coins from miners on the pi network and resells them to investors hoping to hang onto them until the mainnet is launched is known as a pi merchant.
debuts.
I'll provide you the Telegram username
@Pi_vendor_247
when will pi network coin be available on crypto exchange.DOT TECH
There is no set date for when Pi coins will enter the market.
However, the developers are working hard to get them released as soon as possible.
Once they are available, users will be able to exchange other cryptocurrencies for Pi coins on designated exchanges.
But for now the only way to sell your pi coins is through verified pi vendor.
Here is the telegram contact of my personal pi vendor
@Pi_vendor_247
Lecture slide titled Fraud Risk Mitigation, Webinar Lecture Delivered at the Society for West African Internal Audit Practitioners (SWAIAP) on Wednesday, November 8, 2023.
If you are looking for a pi coin investor. Then look no further because I have the right one he is a pi vendor (he buy and resell to whales in China). I met him on a crypto conference and ever since I and my friends have sold more than 10k pi coins to him And he bought all and still want more. I will drop his telegram handle below just send him a message.
@Pi_vendor_247
The European Unemployment Puzzle: implications from population agingGRAPE
We study the link between the evolving age structure of the working population and unemployment. We build a large new Keynesian OLG model with a realistic age structure, labor market frictions, sticky prices, and aggregate shocks. Once calibrated to the European economy, we quantify the extent to which demographic changes over the last three decades have contributed to the decline of the unemployment rate. Our findings yield important implications for the future evolution of unemployment given the anticipated further aging of the working population in Europe. We also quantify the implications for optimal monetary policy: lowering inflation volatility becomes less costly in terms of GDP and unemployment volatility, which hints that optimal monetary policy may be more hawkish in an aging society. Finally, our results also propose a partial reversal of the European-US unemployment puzzle due to the fact that the share of young workers is expected to remain robust in the US.
how to sell pi coins on Bitmart crypto exchangeDOT TECH
Yes. Pi network coins can be exchanged but not on bitmart exchange. Because pi network is still in the enclosed mainnet. The only way pioneers are able to trade pi coins is by reselling the pi coins to pi verified merchants.
A verified merchant is someone who buys pi network coins and resell it to exchanges looking forward to hold till mainnet launch.
I will leave the telegram contact of my personal pi merchant to trade with.
@Pi_vendor_247
how to sell pi coins in South Korea profitably.DOT TECH
Yes. You can sell your pi network coins in South Korea or any other country, by finding a verified pi merchant
What is a verified pi merchant?
Since pi network is not launched yet on any exchange, the only way you can sell pi coins is by selling to a verified pi merchant, and this is because pi network is not launched yet on any exchange and no pre-sale or ico offerings Is done on pi.
Since there is no pre-sale, the only way exchanges can get pi is by buying from miners. So a pi merchant facilitates these transactions by acting as a bridge for both transactions.
How can i find a pi vendor/merchant?
Well for those who haven't traded with a pi merchant or who don't already have one. I will leave the telegram id of my personal pi merchant who i trade pi with.
Tele gram: @Pi_vendor_247
#pi #sell #nigeria #pinetwork #picoins #sellpi #Nigerian #tradepi #pinetworkcoins #sellmypi
The Evolution of Non-Banking Financial Companies (NBFCs) in India: Challenges...beulahfernandes8
Role in Financial System
NBFCs are critical in bridging the financial inclusion gap.
They provide specialized financial services that cater to segments often neglected by traditional banks.
Economic Impact
NBFCs contribute significantly to India's GDP.
They support sectors like micro, small, and medium enterprises (MSMEs), housing finance, and personal loans.
5. Mean
Machine
1.1 What is Machine Learning? - Type
Agent
Environment
ActionReward State
Input
Layer
Output
Layer
Hidden
Layer 1
Hidden
Layer 2
Supervised Learning Unsupervised Learning
Semi-supervised Learning Reinforcement Learning
Deep Learning
6. Mean
Machine
1.2 What is Learning Problem?
Unknown Target Function
c: X Y
Training Examples
(x(1), y(1)), (x(2), y(2)),…, (x(n), y(n))
Learning
Algorithm
A
Hypothesis Set
H = {h1, h2,…, hM}
Final Hypothesis
g c
ideal loan approval formula
historical records of applicants
a set of candidate formulas
learned loan approval formula
7. Mean
Machine
1.3 Is Learning Feasible? - No Free Lunch Theorem
Feature x Label y Model A Model B Model C
Training
Data
[0, 0] 0 0 0 0
[1, 1] 1 1 1 1
Test
Data
[1, 0] ? 1 0 1
[0, 1] ? 0 0 1
Model A = random guess
Model B = support vector machine
Model C = deep neural network
Is Model C > Model B > Model A?
c(x) = x1 ⋁ x2 : Model C wins
o The 3rd data x = [1, 0], so y = 1 ⋁ 0 = 1
o The 4th data x = [0, 1], so y = 0 ⋁ 1 = 1
c(x) = x1 ⋀ x2 : Model B wins
o The 3rd data x = [1, 0], so y = 1 ⋀ 0 = 0
o The 4th data x = [0, 1], so y = 0 ⋀ 1 = 0
c(x) = x1: Model A wins
o The 3rd data x = [1, 0], so y = 1
o The 4th data x = [0, 1], so y = 0
Model A is as good as Model C! Anything needs to learn?
All Models are expected to have equivalent performance!
The c is an unknown function, the performance on training data is
not indicative of the performance on test data.
The performance on test data is all that matters in learning!
Can we really learn something? Learning seems to be doomed but …
8. Mean
Machine
1.3 Is Learning Feasible? - No Free Lunch Proof
It is meaningless to discuss the superiority of algorithm given no specific problems.
Define
A = algorithm
xin = in-sample data
xout = out-of-sample data (N)
c = unknown target function
h = hypothesis function
Consider all cases of c, the expected out-of-sample
error under algorithm A is the same.
E A xin, c
=
c
h
xout
P xout
PDF of xout
∙ I h xout ≠ c xout
error of h on xout
∙ P h xin, A
PDF of h given A and xin
=
xout
P xout ∙
h
P h xin, A ∙
c
I h xout ≠ c xout
=
xout
P xout ∙
h
P h xin, A ∙
1
2
2N
= 2N−1
xout
P xout ∙
h
P h xin, A
= 2N−1
xout
P xout
The error is independent of algorithm A!
E[random guess|xin, c] = E[state-of-the-art|xin, c]
9. Mean
Machine
1.3 Is Learning Feasible? - Add Probability Distribution
Unknown Target Function
c: X Y
Training Examples
(x(1), y(1)), (x(2), y(2)),…, (x(n), y(n))
Learning
Algorithm
A
Hypothesis Set
H = {h1, h2,…, hM}
Final Hypothesis
g c
Input Distribution
P(X)
x
x(1),
x(2),
…,
x(n)
10. Mean
Machine
1.3 Is Learning Feasible? - Logic Chain of Proof
learning
feasibleProve
target
function
c
Learn g closest
to cFind Etrue(g)
smallShow
Etrain(g) ≈
Etrue(g)
Etrain(g)
small
GivenEtrue(g)
small Showg ≈ c Showlearning
feasible Show
God’s Gift: Etrain(g) ≈ Etrue(g)
Your Capability: Etrain(g) is small
Target function c is UNKNOWN
True error Etrue(g) is IMPOSSIBLE to compute
11. Mean
Machine
1.3 Is Learning Feasible? - From Unknown to Known
Can we infer u from v?
No, people from sample might all support Clinton
but Trump eventually win!
The above statement is POSSIBLE but not
PROBABLE. When sample size is big enough,
“v ≈ u” is probably approximately correct (PAC)
P( v − u > ε) ≤ 2e−2ε2nHoeffding’s
inequality
• No u appears to be at RHS of above formula
• A link from unknown u to known v
u is deterministic unknown, v is stochastic known.Population Sampleu v = 2/5
12. Mean
Machine
1.3 Is Learning Feasible? - From Polling to Learning
Polling Learning
Label
Support Trump
Support Clinton
Correct classification
Incorrect classification
Aim Get vote percentage for Trump Learn target function c(x) = y
Data US citizens Examples
Data Distribution Every citizen is i.i.d Every example is i.i.d
In-Sample Sample Training set
In-Sample
Statistics
v = vote percentage for Trump in-sample training error Etrain h =
1
n
σi=1
n
I{h 𝐱 i
≠ c 𝐱 i
}
Out-of-Sample
Statistics
u = vote percentage for Trump out-of-sample true error Etrue h = P(h 𝐱 ≠ c(𝐱))
P( v − u > ε) ≤ 2e−2ε2n P( Etrain(h) − Etrue(h) > ε) ≤ 2e−2ε2n
Polling Learning
simplify
P(bad h) ≤ 2e−2ε2n
analogy
Are we done? No!
This is verification,
not learning
13. Mean
Machine
1.3 Is Learning Feasible? - From One to Many
Unknown Target Function
c: X Y
Verify Training Examples
(x(1), y(1)), (x(2), y(2)),…, (x(n), y(n))
A Fixed Hypothesis function
h
Verification
h c or h ≠ c
Input Distribution
P(X)
x
x(1),
x(2),
…,
x(n)
The entire flowchart assumed a FIXED h and
then came the data.
In order to be real learning, we have to choose
g among a hypothesis set {h1, h2, …, hM} instead
of fixing a single h
P Etrain g − Etrue g > ε
= P bad g
≤ P bad h1 or bad h2 or ⋯ or bad hM
≤ P bad h1 + P bad h2 + ⋯ + P bad hM
≤ 2e−2ε2n + 2e−2ε2n + ⋯ + 2e−2ε2n
= 2Me−2ε2n
P(bad h) ≤ 2e−2ε2n
P(bad g) ≤ 2Me−2ε2n
From h to g
Are we done? No!
M can be very huge,
infinite-huge
14. Mean
Machine
1.3 Is Learning Feasible? - From Finite to Infinite
When M ∞
P bad g ≤ 2Me−2ε2n = 2
M
e2ε2n
= very large number
Congratulations!
Even primary student knows P(bad g) ≤ 1
What went wrong?
15. Mean
Machine
1.3 Is Learning Feasible? - From Infinite to Finite
h1
h2
h3
The hypothesis h1, h2 and h3 are effective equivalent!
Dichotomy
Growth
function
Shattered
Break
Point
VC
Dimension
P Etrain g − Etrue g > ε ≤ 4
2n dvc + 1
e
1
8
ε2n
16. Mean
Machine
1.3 Is Learning Feasible? - Learning is Feasible
P Etrain g − Etrue g > ε ≤ 4
2n dvc + 1
e
1
8
ε2n
We can reach above conclusion by not knowing
• algorithm A
• input distribution P(X)
• target function c
We just need
• training examples D
• hypothesis set H
to find final hypothesis g to learn c.
Learning is feasible
when VC dimension is finite
Unknown Target Function
c: X Y
Training Examples
(x(1), y(1)), (x(2), y(2)),…, (x(n), y(n))
Learning
Algorithm
A
Hypothesis Set
H = {h1, h2,…, hM}
Final Hypothesis
g c
Input Distribution
P(X)
x
x(1),
x(2),
…,
x(n)
17. Mean
Machine
1.4 How to Learn Well? - Over-learn vs Under-learn
Exercise Exam
Both are leaves Which one is leaf?
When you learn too much:
This is not leaf, since
leaves must be serrated
When you learn too little:
This is leaf, since leaves
are green
21. Mean
Machine
2.2 Data, Parameter
• Deposit rates, futures rates and swap rates (yield curve construction)
• Cap and swaption implied volatilities (IR volatility calibration)
• FX swap point and volatilities (FX volatility calibration)
• CDS spread curve (hazard rate calibration)
Θmkt(t)
Daily observable market data
• Libor fixing (historical data point)
• Correlation between CMS and FX (historical time series)
• Short rate mean reversion speed (κ = 0.01)
Θprm(t)
Indirectly observed or
estimated from historical data
or treated as “exotic” constants
• Number of Monte Carlo paths (N = 50,000)
• Number of node points in finite difference grid (N = 1,000)
• Tolerance of errors in optimization (ε = 10-5)
Θnum(t)
Parameters that control the
numerical schemes
22. Mean
Machine
2.3 Curve Construction
Benchmark Curve
Deposit
ED Futures
FRA
Swap
2
Benchmark Curve
USD USD
FX Swap Point
CRX Basis Swap
Deposit
ED Futures
FRA
Swap
4
Index Curve
CUR CUR CUR
4
1
Discount Curve
USD
OIC
OIS
USD
2
IR Basis Swap
USD
Index Curve
USD
FX Discount Curve
CUR
CURUSD
3 3
IR Basis Swap
CUR
3
1
Discount Curve
CUR
OIC
OIS
CUR
2
2
3
4
24. Mean
Machine
2.5 Instrument Valuation - Fundamentals
No
Arbitrage
Numeraire
Change
Measure
Pricing
Formula V 0 = N 0 × EN
V T
N T
Numeraire Probability Measure
Bank Account Risk-neutral Measure
Zero-Coupon Bond Forward Measure
Annuity Swap Measure
Given two assets A and B with their
payoff f and g at T, if f = g, then A = B
dP
dQ
=
Q 0
P 0
∙
P T
Q T
25. Mean
Machine
2.5 Instrument Valuation - Fundamentals (No-Arbitrage Principle)
Given two assets A and B with their payoff f and g at T, by no-arbitrage principle, if f = g, then A = B.
• When A > B :At t = 0 buy B sell A with profit A – B > 0, at T sell B buy A with profit g – f = 0
• When A < B :At t = 0 sell B buy A with profit B – A > 0, at T buy B sell A with profit f – g = 0
B0 = A0 =
1
1 + r T
𝐝𝐢𝐬𝐜𝐨𝐮𝐧𝐭
∙ pu ∙ h uS0 + pd ∙ h(dS0)
𝐞𝐱𝐩𝐞𝐜𝐭𝐞𝐝 𝐩𝐚𝐲𝐨𝐟𝐟
A0 = xS0 − yC
AT = ൝
xuS0 − y 1 + r T
C stock ↑ uS0
xdS0 − y 1 + r T
C stock ↓ dS0
BT = ቊ
h(uS0) stock ↑ uS0
h(dS0) stock ↓ dS0
AT = BT
xuS0 − y 1 + r TC = h(uS0) stock ↑ uS0
xdS0 − y 1 + r TC = h(dS0) stock ↓ dS0
x =
h uS0 − h(dS0)
(u − d)S0
y =
1
1 + r TC
∙
d ∙ h uS0 − u ∙ h(dS0)
u − d
Use no-arbitrage principle to price any financial instrument B at time 0, B0
Construct
Express
Equal
Link
Solve
Present Value = Discount Factor × Expected Payoff
26. Mean
Machine
2.5 Instrument Valuation - Fundamentals (Numeraire and Probability Measure)
Numeraire Numeraire is unit, and it can be money, tradeable asset or even apple.
Probability
Measure
Probability measure is a set of probabilities for certain event.
Q(H) = 0.8, Q(T) = 0.2
P(H) = P(T) = 0.5Fair Coin
Biased Coin
A 0 = φ1A1 T + φ2A2 T + ⋯ + φKAK T =
k=1
K
φkAk(T)
B 0 = φ1B1 T + φ2B2 T + ⋯ + φKBK T =
k=1
K
φkBk(T)
A 0
B 0
=
σk=1
K
φkAk T
σk=1
K
φkBk T
=
k=1
K
φk
b
Ak T =
k=1
K
φkBk T
b
×
Ak T
Bk T
=
k=1
K
φkBk T
σk=1
K
φkBk T
×
Ak T
Bk T
=
k=1
K
πk ×
Ak T
Bk T
= EB
A T
B T
A 0 = B 0 × EB
A T
B T
B is a numeraire, EB is the expectation with probability measure induced by B
Numeraire Probability Measure Instrument
Bank Account Risk-neutral Measure FX, Equity, Commodity Option
Zero-Coupon Bond Forward Measure Cap, Floor
Annuity Swap Measure Swaption
27. Mean
Machine
2.5 Instrument Valuation - Fundamentals (Change of Probability Measure)
EP X = p1x1 + p2x2 = q1
p1
q1
x1 + q2
p2
q2
x2 = EQ Z ∙ X
q1 = 0.8, q2 = 0.2
p1 = p2 = 0.5Fair Coin
Biased Coin
Z is Radon-Nikodym derivative,
denoted as Z = dP/dQQuestion 1:
Relationship between two
probability measures
Numeraire
Probability
Measure
corresponds Change
Numeraire
Change
Probability
Measure
corresponds
What is the relationship between two probability measures
What is the relationship between two numeraires
Why change of measure
28. Mean
Machine
2.5 Instrument Valuation - Fundamentals (Change of Probability Measure)
Question 2:
Relationship between
two numeraires
Question 3:
Why change of measure
A 0
B 0
= EB
A T
B T
EP X = EQ
dP
dQ
∙ XE1 E2
EQ
A T
Q T
∙
Q 0
P 0
=
A 0
Q 0
𝐁𝐲 𝐄𝟏
𝐐=𝐁
∙
Q 0
P 0
=
A 0
P 0
= EP
𝐁𝐲 𝐄𝟏
𝐏=𝐁
A T
P T
= EQ
dP
dQ
∙
A T
P T
𝐁𝐲 𝐄2
dP
dQ
=
Q 0
P 0
∙
P T
Q T
Risk-Neutral Measure EQ Forward Measure ET
Numeraire Bank Account β(t) Zero Coupon Bond P(t, T)
Property β(0) = 1 P(T, T) = 1
Martingale
Formula
V 0
β 0
= EQ
V T
β T
V 0
P 0, T
= ET
V T
P T, T
Simplified
Formula
V 0 = EQ
V T
β T
V 0 = P 0, T ∙ ET V T
29. Mean
Machine
2.5 Instrument Valuation - Pricing Methods
V t = N t × Et
N
V T
N T
1. Find the PDF of V(T)/N(T) under measure N.
2. Use integration to represent expectation.
3. Simplify it to closed-form if possible, or leave it as
numerical integration otherwise.
1. Change measure N to risk-neutral measure.
2. Use Feynman-Kac Theorem to derive PDE of V.
3. Fix solution domain, construct grid, set terminal and
boundary conditions, discretize derivatives in spatial
and time dimension, adopt finite difference scheme.
1. By law of large number, compute E[V/N] by taking
the average of Vi/Ni as approximation.
2. Adopt variance reduction technique to enhance
Monte Carlo efficiency.
Closed-Form,
Numerical
Integration
PDE Finite
Difference
Method
Monte Carlo
Method
30. Mean
Machine
2.5 Instrument Valuation - Closed-Form, Numerical Integration
dS t
)S(t
= [r − q]dt + σdB(t)
൞
dS t
S t
= r − q dt + v t dB1 t
dv t = κ θ − v t dt + η v t dB2 t
Closed-Form
V = ω ∙ [e−qT
∙ S0Φ(ωd+) − e−rT
∙ KΦ(ωd−)]
• d =
1
σ T
ln
S0e r−q T
K
σ T
2
Numerical Integration
V = ω ∙ [e−qT
∙ S0P1(ω) − e−rT
∙ KP2(ω)]
• P1 ω = ½ 1 − + P1 S0, v0, T, K
• P2 ω = ½ 1 − + P2 S0, v0, T, K
• Pj x, v, T, y =
1
2
+
1
π
0
∞
Re
Cj T,ϕ −Dj T,ϕ v+ln(
x
y
)ϕi
ϕi
dϕ
• Dj T, ϕ =
bj−ρηϕi+dj−(bj−ρηϕi−dj)gje
djT
η2(1−gje
djT
)
• Cj T, ϕ = r − q Tϕi +
κθ
η2 bj − ρηϕi + dj T − 2ln
1−gje
djT
1−gj
• dj = (bj − ρηϕi)2−η2(2ujϕi − ϕ2), gj =
bj−ρηϕi+dj
bj−ρηϕi−dj
• b1 = - η, b2 = , u1 = 0.5, u2 = -0.5
Black-Scholes Model
Heston Model
Technique Used:
• Itô's Formula
• Girsanov’s Theorem
• Moment Matching
• Drift Interpolation
• Parameter Averaging
31. Mean
Machine
2.5 Instrument Valuation - PDE Finite Difference Method (SDE to PDE)
Given the SDE of x(t) and payoff function V of a derivative at maturity T:
)dx t = μ t, x dt + σ t, x dB(t
V x(T), T = h(x T )
The V(x, t) satisfies the following PDE:
𝜕V
𝜕t
+ μ t, x
𝜕V
𝜕x
+
1
2
σ2
t, x
𝜕2V
𝜕x2
− rV = 0
V x, t = e−r T−t ∙ Et h(x T )
By no-arbitrage principle:
SDE
PDE
Feynman-Kac
32. Mean
Machine
2.5 Instrument Valuation - PDE Finite Difference Method (Grid Construction)
t
X
t0
tn = T
x0 Xm+1
Terminal Condition
Xj-1 Xj Xj+1
ti-1
ti
ti+1
Interior Points
BoundaryCondition
BoundaryCondition
x ∈ xj j=0
m+1
⇨ xj = xmin + j∆x, ∆x=
xmax −xmin
m + 1
t ∈ ti i=0
m
⇨ ti = i∆t, ∆t=
T
n
33. Mean
Machine
2.5 Instrument Valuation - PDE Finite Difference Method (Discretization and Scheme)
t
X
Fully Explicit (θ = 0)
(xj, ti)(xj-1, ti) (xj+1, ti)
(xj, ti-1)
t
X
(xj, ti)(xj-1, ti) (xj+1, ti)
(xj, ti+1)
Fully Implicit (θ = 1) t
X
(xj, ti+1)(xj-1, ti+1) (xj+1, ti+1)
(xj, ti)(xj-1, ti) (xj+1, ti)
Crank-Nicolson (θ = ½)
Order Spatial Dimension Time Dimension
1st
𝜕Vj t
𝜕x
≈
Vj+1 t − Vj−1 t
2∆x
𝜕𝐕
𝜕t
≈
𝐕 ti+1 − 𝐕 ti
∆t
2nd
𝜕Vj
2
t
𝜕x2
≈
Vj+1 t − 2Vj t + Vj−1 t
∆x
2
Nodes in relation Node at discretization Nodes not in relation
Use central difference on
∂Vj/∂xand ∂2Vj/∂x2 at xj
Discretize ∂Vj/∂tat tθ
i,i+1 =
θti + (1 - θ)ti+1
34. Mean
Machine
2.5 Instrument Valuation - PDE Finite Difference Method (Representation)
The difference equation at (tθ
i,i+1, xj) is
Vj ti+1 − Vj ti
∆t
= − μ ti,i+1
θ
, xj ·
Vj+1 ti,i+1
θ
− Vj−1 ti,i+1
θ
2∆x
−
σ2 ti,i+1
θ
, xj
2
·
Vj+1 ti,i+1
θ
− 2Vj ti,i+1
θ
+ Vj−1 ti,i+1
θ
∆x
2
+ r ti,i+1
θ
, xj · Vj(ti,i+1
θ
)
𝐈 − θ∆t 𝐀 ti,i+1
θ
∙ 𝐕 ti = 𝐈 + 1 − θ ∆t 𝐀 ti,i+1
θ
∙ 𝐕 ti+1 + θ𝛀 ti + 1 − θ 𝛀 ti+1
Write the algebraic form to matrix form
Identity Matrix Tri-Diagonal Matrix Boundary Value Vector
35. Mean
Machine
2.5 Instrument Valuation - Monte Carlo Method (Fundamentals)
Consider a derivative V with time T payout
V(T) = g(T), by no-arbitrage principle
V t = N t × Et
N
g T
N T
Law of Large Numbers
Let Y1, Y2, …, Yn be a sequence of independent identically distributed (i.i.d.)
random variables with finite expectation . Define the sample mean
ഥY n =
1
n
σi=1
n
Yi → lim
n→∞
ฑഥY n
sample
mean
= lim
n→∞
1
n
σi=1
n
Yi = ฎμ
population
mean
V t ≈ ഥV t = N t ×
1
n
i=1
n
gi
Ni
Central Limit Theorem
Let Y1, Y2, …, Yn be a sequence of i.i.d. random variables with finite
expectation and standard deviation σ. Then for n → ∞
ฑഥY n
sample
mean
− ฎμ
population
mean
s(n)
n
~ N 0,1
where
s2 n =
1
n−1
σi=1
n
[Yi − ഥY n ]2 =
n
n−1
σ2
V(t) ∈ ഥV t − zα
2
∙
s n
n
, ഥV t + zα
2
∙
s n
n
ฑs n
n
𝐬𝐭𝐚𝐧𝐝𝐚𝐫𝐝 𝐞𝐫𝐫𝐨𝐫 ↓
=
n − 1
n
ฏσY
𝐯𝐚𝐫𝐢𝐚𝐧𝐜𝐞 ↓
ดn
𝐬𝐚𝐦𝐩𝐥𝐞 𝐬𝐢𝐳𝐞 ↑
36. Mean
Machine
2.5 Instrument Valuation - Monte Carlo Method (Variance Reduction)
E Ynew = E Y
Variance Reduction
Yi
av
= (Yi
1
+ Yi
2
)/2
E Ynew = E
Yi
1
+ Yi
2
2
= E Y
Var Ynew = Var
Yi
1
+ Yi
2
2
=
Var Y
2n
1 + ρ <
Var Y
2
)Ynew
= Y + c(Ycv
− μcv
E Ynew
= E Y] + cE[Ycv
− μcv
= E Y
Var Ynew
= min
c
Var Y + c Ycv
− μcv
= (1 − ρY,Ycv)Var Y ≤ Var Y
Ynew
= E Y Z
E Ynew = E E Y Z = E[Y]
Var Y = E Var Y Z + Var E Y Z
≥ Var E Y Z = Var Ynew
Ynew
= E Y Z
E Ynew = E E Y Z = E[Y]
Var Ynew
= min
Nj
E Var Y Z
≤ E Var Y Z ≤ Var Y
Var Ynew < Var Y
Ef )V(X = නV x f x dx
= න
V x f x
g x
g(x)dx = Eg
V X f X
g X
Varf
V X − Varg
V X f X
g X
= න V2 x f x 1 −
f x
g x
dx > 0
൝
g x > f x , when V2
x f x large
g x < f x when V2
x f x small
Antithetic
Variate
Control
Variate
Conditioning
Sampling
Stratified
Sampling
Importance Sampling
37. Mean
Machine
2.6 Risk Measurement - Sensitivity
𝜕V
𝜕Θk
=
V Θ1, Θ1, … , Θk + ∆, … , ΘK − V Θ1, Θ1, … , Θk, … , ΘK
∆
Bump and
Revaluation
Compute delta of European Option in Monte Carlo
Pathwise Differentiation
Compute delta of Digital Option in Monte Carlo
Likelihood Ratio
𝜕V
𝜕S0
= E
)𝜕g(ST
𝜕ST
∙
𝜕ST
𝜕S0
= E
𝜕 ST − K +
𝜕ST
∙
𝜕ST
𝜕S0
= E 1{ST > K} ∙
𝜕ST
𝜕S0
𝜕V
𝜕S0
=
𝜕 g(ST) ∙ f(ST; S0)dST
𝜕S0
= න g(ST) ∙
)𝜕f(ST; S0
𝜕S0
dST
= න g(ST) ∙
൯fS0
(ST; S0
)f(ST; S0
f(ST; S0)dST
= E g(ST) ∙
൯fS0
(ST; S0
)f(ST; S0
38. Mean
Machine
2.6 Risk Measurement - Value-at-Risk
Window: 1 Year
Holding Period: 10 Day
Confidence Level: 99%
Risk Factors
Historical Time Series Perturbations Historical Scenarios
Simulated PVs Simulated P&Ls
S1
1
S1
m
…
S1
250
…
S2
1
S2
m
…
S2
250
…
Sn
1
Sn
m
…Sn
250
…
PV1
PVm
…
PV250
…
P&L1
P&Lm
…
P&L250
…
Δ1
1
Δ1
m
…
Δ1
250
…
Δ2
1
Δ2
m
…
Δ2
250
…
Δn
1
Δn
m
…
Δn
250
…
RF1
1
RF1
m
…
RF1
260
…
RF2
1
RF2
m
…
RF2
260
…
RFn
1
RFn
m
…
RFn
260
…
RF1
RFn
…
…
…
RF2
……
Portfolio VaR
(100 - )% VaR PnL0
ProfitLoss
Loss < VaR
%
42. Mean
Machine
3.3 Data Preprocessing - Data Collection
date = '2018-1-4'
stocks = all_instruments(type="CS", date=date).order_book_id.tolist()
data = get_fundamentals(
query(
fundamentals.eod_derivative_indicator.pb_ratio,
fundamentals.eod_derivative_indicator.market_cap
).filter(
fundamentals.income_statement.stockcode.in_(stocks)
), date, '1d').major_xs(date).dropna()
data['BP'] = 1/data['pb_ratio']
data.head(3).append(data.tail(3))
43. Mean
Machine
3.3 Data Preprocessing - Outlier handling
def filter_extreme_MAD(series,n):
median = series.quantile(0.5)
new_median = ((series - median).abs()).quantile(0.50)
max_range = median + n*new_median
min_range = median - n*new_median
return np.clip(series,min_range,max_range)
def filter_extreme_3sigma(series,n=3):
mean = series.mean()
std = series.std()
max_range = mean + n*std
min_range = mean - n*std
return np.clip(series,min_range,max_range)
def filter_extreme_percentile(series,min = 0.025,max = 0.975):
series = series.sort_values()
q = series.quantile([min,max])
return np.clip(series,q.iloc[0],q.iloc[1])
MAD
3 Sigma
Percentile
44. Mean
Machine
3.3 Data Preprocessing - Standardization
def standardize_series(series):
return (series-series.mean()) / series.std()
new = filter_extreme_3sigma(data['BP'])
ax = standardize_series(new).plot.kde(label = 'Standardized Raw Factor')
ax.legend();
ax = standardize_series(new.rank()).plot.kde(label = 'Standardized
Ranked Factor')
ax.legend();
zi =
Xi − μ
σ
zi =
Yi − μ
σ
, Y = Rank(X)
Standardized Raw Factor
Standardized Ranked Factor
45. Mean
Machine
3.4 Stock Selection - Traditional Approach
ri = βi1f1 + ⋯ + βiKfK + εi =
k=1
K
βikfk + εi
Multi-Factor
Model
The basic premise of multi-factor model is
that similar assets display similar returns.
Factor
Exposure
Factor
Premium
Specified
Return
Excess
Return
Estimate Factor Premium
Consider the following stocks and factors:
Stock 1: Apple Stock 2: Facebook Stock 3: Google
Factor 1: PE (price-to-earnings) Factor 2: DY (dividend yield)
For each t
1. Collect the factor exposures i1(t-1) and i2(t-1),
2. Collect the stock price at t-1 and t, and compute excess return ri(t)
3. Perform cross-sectional regression to get factor premiums f1(t) and f2(t)
r1(t) = β11(t − 1)f1(t) + β12(t − 1)f2(t)
r2(t) = β21(t − 1)f1(t) + β22(t − 1)f2(t)
r3(t) = β31(t − 1)f1(t) + β32(t − 1)f2(t)
)f1(1 )f2(1 ⋯ )fK(1
)f1(2 f2(2) ⋱ )fK(2
⋮ ⋱ ⋱ ⋮
)f1(T )f2(T ⋯ )fK(T
f1 T + 1 f2 T + 1 ⋯ fK T + 1
Collect
Time Series
From 0 to T
Predict
Factor
Premium
at T+1
AR(p)
MA(q)
ARMA(p, q)
…
46. Mean
Machine
3.4 Stock Selection - Traditional Approach
Factor Premium
Factor Exposure
Excess Return
•Rank and Select
𝐁(T + 1) =
൯β1,1(T + 1 ൯β1,2(T + 1 ⋯ ൯β1,K(T + 1
൯β2,1(T + 1 ൯β2,2(T + 1 ⋱ ൯β2,K(T + 1
⋮ ⋱ ⋱ ⋮
൯βN,1(T + 1 ൯βN,2(T + 1 ⋯ ൯βN,K(T + 1
𝐟(T + 1) = f1 T + 1 f2 T + 1 ⋯ fK T + 1 T
ri(T + 1) =
k=1
K
βi,k(T + 1) · fk T + 1
𝐫(T + 1) = r1 T + 1 r2 T + 1 ⋯ rN T + 1 T
47. Mean
Machine
3.4 Stock Selection - Machine Learning Approach
Import Package
Parameter
Setting
Data Labeling Model Training
Model Setting
Data Splitting
Model
Assessment
Strategy
Implementation
Strategy
Assessment
48. Mean
Machine
3.4 Stock Selection - Machine Learning Approach (Import Package)
import numpy as np # Matrix Computation
import pandas as pd # Handle Dataframe
# Show plot in this notebook
%matplotlib inline
import matplotlib.pyplot as plt # Plotting
from sklearn.model_selection import train_test_split # Split training and test set
from sklearn.model_selection import GridSearchCV # Select hyper-parameter by cross-validation error
from sklearn.model_selection import KFold # CV model for binary class or balanced class
from sklearn.model_selection import StratifiedKFold # CV model for multi-class or inbalanced class
from sklearn import metrics as me
# Machine Learning Model
from sklearn.svm import SVC # Support Vector Machine
from sklearn.ensemble import RandomForestClassifier as RFC # Random Forest
from sklearn.ensemble import GradientBoostingClassifier as GBC # Gradient Boosted
49. Mean
Machine
3.4 Stock Selection - Machine Learning Approach (Parameter Setting)
class PARA:
method = 'SVM' # Specify the method, can be 'RF', 'GBT'
month_train = range(1, 84+1) # In-sample 84 data points = 84 training examples
month_test = range(85, 120+1) # Out-of-sample 36 data points = 36 test examples
percent_select = [0.5, 0.5] # 50% positive examples,50% negative examples
cv = 10 # 10-fold cross-validation
seed = 1 # Random seed, for results reproduction
para = PARA()
50. Mean
Machine
3.4 Stock Selection - Machine Learning Approach (Data labelling)
def label_data( data ):
data['Label'] = np.nan # Initialization
data = data.sort_values( by='Return', ascending=False ) # Sort excess return in descending order
n_stock = np.multiply( para.percent_select, data.shape[0] ) # Compute the number for stocks for pos and neg class
n_stock = np.around(n_stock).astype(int) # Round number of stocks to integer
data.iloc[0:n_stock[0], -1] = 1 # Assign 1 to those stocks with best performace
data.iloc[-n_stock[1]:, -1] = 0 # Assign 0 to those stocks with worst performace
data = data.dropna(axis=0) # Delete examples with NaN value
return data
Data Format: m × n matrix, first row
contains labels, next m-1 rows contains
the information of m-1 stocks.
• Column 1 - 3: basic information
• Column 4: excess return of next month
• Column 5 - n: factor exposure
csv file
51. Mean
Machine
3.4 Stock Selection - Machine Learning Approach (Data Splitting)
for i in para.month_train: # load csv month by month
file_name = str(i) + ’.csv'
data_curr_month = pd.read_csv( file_name, header=0 )
para.n_stock = data_curr_month.shape[0]
data_curr_month = data_curr_month.dropna(axis=0) # remove NaN
data_curr_month = label_data( data_curr_month ) # label data
# merger to a single dataframe
if i == para.month_train[0]: # first month
data_train = data_curr_month
else:
data_train = data_train.append(data_curr_month)
X = data_train.loc[:, 'EP':'BIAS'];
y = data_train.loc[:, 'Label'];
X_train, X_cv, y_train, y_cv = train_test_split( X, y, test_size=1.0/para.cv, random_state=para.seed )
52. Mean
Machine
3.4 Stock Selection - Machine Learning Approach (Model Setting)
if para.method == 'SVM': # Support Vector Machine
model = SVC( kernel = 'linear', C = 1 )
elif para.method == 'RF': # Random Forest
model = RFC( n_estimators=200, max_depth=6, random_state=para.seed )
elif para.method == 'GBT': # Gradient Boosted Tree
model = GBC( n_estimators=200, max_depth=6, random_state=para.seed )
54. Mean
Machine
3.4 Stock Selection - Machine Learning Approach (Model Training)
best_model = grid_result.best_estimator_
# summarize results
print("Best: %f using %s" % (grid_result.best_score_, grid_result.best_params_))
means = grid_result.cv_results_['mean_test_score']
stds = grid_result.cv_results_['std_test_score']
params = grid_result.cv_results_['params']
for mean, stdev, param in zip(means, stds, params):
print("%f (%f) with: %r" % (mean, stdev, param))
# plot results
scores = np.array(means).reshape(len(kernel), len(C))
for i, value in enumerate(kernel):
plt.plot(C, scores[i], label='depth: ' + str(value))
plt.legend()
plt.xlabel('C')
plt.ylabel('kernel')
plt.savefig('kernel_vs_C.png')
55. Mean
Machine
3.4 Stock Selection - Machine Learning Approach (Model Assessment)
for i in para.month_test: # Print accuracy and AUC for each test example
y_true_i_month = pd.DataFrame( {'Return':y_true_test.iloc[:,i-1]} )
y_pred_i_month = y_pred_test.iloc[:,i-1]
y_score_i_month = y_score_test.iloc[:,i-1]
y_true_i_month = y_true_i_month.dropna(axis=0) # remove NaN
y_i_month = label_data( y_true_i_month )['Label']
y_pred_i_month = y_pred_i_month[ y_i_month.index ].values
y_score_i_month = y_score_i_month[ y_i_month.index ].values
print( 'test set, month %d, accuracy = %.2f' %(i, me.accuracy_score( y_i_month, y_pred_i_month ) ) )
print( 'test set, month %d, AUC = %.2f' %(i, me.roc_auc_score( y_i_month, y_score_i_month ) ) )
…
56. Mean
Machine
3.4 Stock Selection - Machine Learning Approach (Strategy Implementation)
n_stock = 15
strategy = pd.DataFrame( {'Return':[0]*para.month_test[-1], 'Value':[1]*para.month_test[-1]} )
for i in para.month_test:
y_true_i_month = y_true_test.iloc[:,i-1]
y_score_i_month = y_score_test.iloc[:,i-1]
y_score_i_month = y_score_i_month.sort_values(ascending=False) # Sort the score (probability) in descending order
i_index = y_score_i_month[0:n_stock].index # Find the index of the first 15 stocks
strategy.loc[i-1,'Return'] = np.mean(y_true_i_month[i_index])/100 # Compute the mean return of the 15 stocks
strategy['Value'] = (strategy['Return']+1).cumprod() # Mutiply the mean return each test month to get total return
58. Mean
Machine
3.5 Portfolio Construction
Expected Return and
Variance Known?
Yes
MVO
No
Any View on Risk?
No
Any View on Return?
Yes
RB
Yes
BL
RP
EMV
Zero
Correlation
MDP
GMV EW
Same
Sharpe
Ratio
• MVO: Mean-Variance Optimization
• MDP: Most Diversified Portfolio
• GMV: Global Minimum Variance
• EMV: Equal Marginal Volatility
• EW: Equal Weight
• RB: Risk Budgeting
• RP: Risk Parity
• BL: Black-Litterman
Same
Risk
Budget
Same
Volatility
Same VolatilitySame
Expected
Return
Zero
Average
Correlation