meta-heuristics in finance · 2021. 3. 5. · 3.4 di˘erential evolution. . . . . . . . . . . . . ....

22
Meta-Heuristics in Finance Dietmar Maringer Computational Economics and Finance Business and Economics Faculty, University of Basel SAMSI Metaheuristic Optimization, Machine Learning and AI Virtual Workshop March -,

Upload: others

Post on 18-Mar-2021

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Meta-Heuristics in Finance · 2021. 3. 5. · 3.4 Di˘erential Evolution. . . . . . . . . . . . . . . . . . . . . . .12 4 Algorithmic and Autotrading17 4.1 some types of algorithmic

Meta-Heuristics in FinanceDietmar MaringerComputational Economics and FinanceBusiness and Economics Faculty, University of Basel

SAMSI Metaheuristic Optimization, Machine Learning and AI Virtual WorkshopMarch 8-12, 2021

Page 2: Meta-Heuristics in Finance · 2021. 3. 5. · 3.4 Di˘erential Evolution. . . . . . . . . . . . . . . . . . . . . . .12 4 Algorithmic and Autotrading17 4.1 some types of algorithmic

Contents

1 where’s the problem? 3

2 modeling price processes and risk 4

2.1 example: modeling risk . . . . . . . . . . . . . . . . . . . . . . 4

2.2 further examples . . . . . . . . . . . . . . . . . . . . . . . . . . 5

3 Trading and Asset Management 63.1 portfolio: combination of assets . . . . . . . . . . . . . . . . . 63.2 portfolio optimization . . . . . . . . . . . . . . . . . . . . . . . 73.3 sample-based portfolio optimization . . . . . . . . . . . . . . . 113.4 Dierential Evolution . . . . . . . . . . . . . . . . . . . . . . . 12

4 Algorithmic and Autotrading 174.1 some types of algorithmic trading systems . . . . . . . . . . . . 174.2 machine learning and meta-heuristics techniques . . . . . . . . 18

5 Conclusion 21

Dietmar Maringer, Meta-Heuristics in Finance, SAMSI Metaheuristic Optimization, Machine Learning and AI Virtual WorkshopMarch 8-12, 2021

2

Page 3: Meta-Heuristics in Finance · 2021. 3. 5. · 3.4 Di˘erential Evolution. . . . . . . . . . . . . . . . . . . . . . .12 4 Algorithmic and Autotrading17 4.1 some types of algorithmic

1. where’s the problem?

• typical tasks

⊲ investment decisions

⊲ describing, modelling, (and predicting) risky assets

⊲ dealing with requirements (regulators, investors)

• data: “weather forecast” versus “climate change”

⊲ (ultra-)high frequency: highly liquid assets

» latency (under colocation): < 1 microsecond» relevant for certain types of algo-trading strategies

⊲ low frequency: daily prices or lower

» aggregate over longer stretches of time to reduce noise» thin trading: funds, bonds, ...

⊲ challenges

» statistical / stylized facts» scaling laws» choice of model

• need for meta-heuristics

⊲ non-convex models, challenging contraints

Dietmar Maringer, Meta-Heuristics in Finance, SAMSI Metaheuristic Optimization, Machine Learning and AI Virtual WorkshopMarch 8-12, 2021

3

Page 4: Meta-Heuristics in Finance · 2021. 3. 5. · 3.4 Di˘erential Evolution. . . . . . . . . . . . . . . . . . . . . . .12 4 Algorithmic and Autotrading17 4.1 some types of algorithmic

2. modeling price processes and risk

2.1. example: modeling risk

• stylized fact: volatility clustering in returns

• Engle (1982): ARCH(𝑞), Bollerslev (1986): GARCH(𝑞, 𝑝)

𝑟𝑡 = ` + 𝑒𝑡 where 𝑒𝑡 ∼ 𝑁 (0, 𝜎2𝑡 )and 𝜎 2𝑡 = 𝛼0 +

∑𝑞

𝛼𝑞Y2𝑡−𝑞 +

∑𝑝

𝛽𝑝𝜎2𝑡−𝑝

• estimating the parameters 𝝍 = [`, 𝜶, 𝜷] with log-likelihood

𝝍∗ = argmax𝝍

L = −𝑇2ln(2𝜋) − 1

2

𝑇∑𝑡=1

(ln(�� 2𝑡 ) +

��2𝑡

�� 2𝑡

)• Chris Brooks, Simon P. Burke, and Gita Persand (2001). “Benchmarks and the Accuracy of GARCHModel Estimation”. In: International Journal of Forecasting 17.1, pp. 45–56

⊲ estimate GARCH(1,1) parameters [`, 𝛼0, 𝛼1, 𝛽1] with nine standard software packages⊲ results dier noticeably

• heuristic optimization can easily solve this problem

Dietmar Maringer, Meta-Heuristics in Finance, SAMSI Metaheuristic Optimization, Machine Learning and AI Virtual WorkshopMarch 8-12, 2021

4

Page 5: Meta-Heuristics in Finance · 2021. 3. 5. · 3.4 Di˘erential Evolution. . . . . . . . . . . . . . . . . . . . . . .12 4 Algorithmic and Autotrading17 4.1 some types of algorithmic

2.2. further examples• model estimation e.g., Nelson-Siegel-Svensson for yield of bond with time-to-maturity 𝜏 at 𝑡:min𝜷,𝝀

𝐸(( 𝑦𝑡 − ��𝑡)2)

��𝑡 (𝜏) = 𝛽1,𝑡 + 𝛽2,𝑡𝐹 (𝜏/_1) + 𝛽3,𝑡

(𝐹 (𝜏/_1) − 𝑒−

𝜏/_1)+ 𝛽4,𝑡

(𝐹 (𝜏/_2) − 𝑒−

𝜏/_2)where 𝐹 (𝛾) = 1−𝑒−𝛾

𝛾

• model selection challenging combinatorial problems, e.g., factor (or asset) selection:minF ,𝒃

𝐸((𝑟 − ��)2):

�� =∑𝑓∈F

𝛽𝑓 𝑟𝑓 s.t. F ⊂ M , 𝜷 ∈ D , and ♯F ≤ 𝑘 � ♯M

• joint estimation and selection problem: Vector Error Correction model (VECM) for interest rates:

Δ𝒀 𝑡 = 𝒄 + 𝚷𝒀 𝑡−1 +𝑘∑

�=1𝚪�Δ𝒀 𝑡−� + 𝝐𝑡 with Δ𝒀 𝑡−� = 𝒀 𝑡−� − 𝒀 𝑡−�−1

=

[ 𝑐1...𝑐𝑛

]+[ 𝜋11 ··· 𝜋1𝑛.... . .

...𝜋𝑛1 ··· 𝜋𝑛𝑛

] [ 𝑦1,𝑡−1...

𝑦𝑛,𝑡−1

]+

𝑘∑�=1

[ 𝛾11� ··· 𝛾1𝑛�.... . .

...𝛾𝑛1� ··· 𝛾𝑛𝑛�

] [ Δ𝑦1,𝑡−1−�...

Δ𝑦𝑛,𝑡−1−�

]+[ 𝜖1𝑡...𝜖𝑛𝑡

]

Dietmar Maringer, Meta-Heuristics in Finance, SAMSI Metaheuristic Optimization, Machine Learning and AI Virtual WorkshopMarch 8-12, 2021

5

Page 6: Meta-Heuristics in Finance · 2021. 3. 5. · 3.4 Di˘erential Evolution. . . . . . . . . . . . . . . . . . . . . . .12 4 Algorithmic and Autotrading17 4.1 some types of algorithmic

3. Trading and Asset Management

3.1. portfolio: combination of assets• 𝑁 assets; return of asset are normally distributed

⊲ stock price: 𝑆𝑇 = 𝑆0 · (1 + 𝑟𝑇 )⊲ returns: expectations `𝑖 = 𝐸(𝑟𝑖), standard deviations (“volatility”) 𝜎𝑖 and covariances 𝜎𝑖 𝑗⊲ estimates based on past observations [𝑟𝑡𝑖] and/ or models

• portfolio

⊲ 𝑃0, value at beginning, 𝑡 = 0: 𝑛𝑖 stocks 𝑖 =⇒𝑃0 =∑

𝑖 𝑛𝑖𝑆0,𝑖

⊲ 𝑃𝑇 , value at end of investment period:

𝑃𝑇 =∑𝑖

𝑛𝑖𝑆𝑇,𝑖 =∑𝑖

𝑛𝑖𝑆0𝑖(1 + 𝑟𝑇,𝑖)𝑃𝑇

𝑃0= (1 + 𝑟𝑇,𝑝) =

∑𝑖

𝑛𝑖𝑆0𝑖

𝑃0(1 + 𝑟𝑇,𝑖) = 1 +

∑𝑖

𝑤𝑖𝑟𝑖

hence,

𝐸(𝑟𝑝) =∑𝑖

𝑤𝑖𝐸(𝑟𝑖) = 𝝁𝒘 𝜎𝑝 =

√∑𝑖

𝑤2𝑖𝜎 2𝑖+∑𝑖≠𝑗

𝑤𝑖𝑤𝑗𝜎𝑖 𝑗 =√𝒘′𝚺𝒘

⊲ asset weight: fraction of wealth invested in asset 𝑖, 𝑤𝑖 =𝑛𝑖𝑆0,𝑖

𝑃0

Dietmar Maringer, Meta-Heuristics in Finance, SAMSI Metaheuristic Optimization, Machine Learning and AI Virtual WorkshopMarch 8-12, 2021

6

Page 7: Meta-Heuristics in Finance · 2021. 3. 5. · 3.4 Di˘erential Evolution. . . . . . . . . . . . . . . . . . . . . . .12 4 Algorithmic and Autotrading17 4.1 some types of algorithmic

3.2. portfolio optimization

3.2.1. the problem• objective: find composition that meets investors’ and regulators’ requirements the best

⊲ decision variables: 𝑤𝑖

⊲ risk-adjusted performance

⊲ limitations on composition of portfolio

3.2.2. traditional approach: mean-variance portfolios

• Harry Markowitz: achieve target return with minimum risk:

min𝒘

𝜎 2𝑝 = 𝒘′𝚺𝒘 s.t. 𝐸(𝑟𝑝) = 𝝁𝒘 ≥ 𝑟∗, 𝑤𝑖 ≥ 0,∑𝑖

𝑤𝑖 = 1

max𝒘

(𝝁𝒘 − 𝛾 ·𝒘′𝚺𝒘) s.t. 1𝒘 = 1 and𝒘 ≥ 0

for given 𝛾 ≥ 0 =⇒quadratic programming problem

• James Tobin, William Sharpe: include safe asset (return 𝑟𝑓 ) and maximize “Sharpe ratio”

max 𝑆𝑅 =𝐸(𝑟𝑝) − 𝑟𝑓

𝜎𝑝

• negative positions, 𝑤𝑖 < 0: “short selling”

Dietmar Maringer, Meta-Heuristics in Finance, SAMSI Metaheuristic Optimization, Machine Learning and AI Virtual WorkshopMarch 8-12, 2021

7

Page 8: Meta-Heuristics in Finance · 2021. 3. 5. · 3.4 Di˘erential Evolution. . . . . . . . . . . . . . . . . . . . . . .12 4 Algorithmic and Autotrading17 4.1 some types of algorithmic

3.2.3. extensions

limitations on selection of assets, 𝑤𝑖

• integer contraints on 𝑛𝑖 ∈ {0, 1, 2, ...} =⇒discrete weights 𝑤𝑖 = 𝑛𝑖𝑆0𝑖/𝑃0

• avoid tiny positions:

{𝑤𝑖 = 0 asset 𝑖 not included

𝑤𝑖 ≥ 𝑤� asset 𝑖 included with (more than) minimum amount

• (explicit) cardinality constraint:∑

𝑖 1𝑤𝑖≠0 ≤ 𝑘

additional costs and eects on performance

• additional transaction costs, management fees, bid-ask spreads: 𝑐𝑣 · |𝑛𝑖 | · 𝑆0𝑖 + 𝑐𝑓 · 1𝑛𝑖≠0

• market impact: large order moves price (in non-linear fashion and by uncertain amount)

investors’ preferences

• risk aversion: higher wealth has more utility, but at decreasing rate

⊲ quadratic utility, (e.g., in Markowitz), 𝑤 − 𝑏𝑤2: justifies mean-variance

⊲ more realistically: e.g., power utility with 𝛾 ≥ 0, 𝑢(𝑤, 𝛾) ={ln(𝑤) for 𝛾 = 1(𝑤1−𝛾 − 1)/(1 − 𝛾) otherwise

• loss aversion (Kahnemann & Tversky): not just level of wealth, but also relative to initialendowment

Dietmar Maringer, Meta-Heuristics in Finance, SAMSI Metaheuristic Optimization, Machine Learning and AI Virtual WorkshopMarch 8-12, 2021

8

Page 9: Meta-Heuristics in Finance · 2021. 3. 5. · 3.4 Di˘erential Evolution. . . . . . . . . . . . . . . . . . . . . . .12 4 Algorithmic and Autotrading17 4.1 some types of algorithmic

distribution of returns

• stock returns typically exhibit negative skewness, excess kurtosis

• non-linear dependencies and correlations

additionale / alternative risk- and performance measures

• tail-risk, focusing on losses, 𝐿 = −(𝑃𝑇 − 𝑃0):

⊲ “Value-at-Risk” (VaR): loss that will be exceeded only with probability 𝛼,prob(𝐿 > 𝑉𝑎𝑅𝛼) = 𝛼

⊲ “conditional Value-at-Risk” (cVaR), ≈ “Expected Shortfall” (ES): 𝐸(𝐿|𝐿 > 𝑉𝑎𝑅𝛼)⊲ in portfolio optimization:

» constraint: equity requirements based VaR (regulations)» objective: minimize 𝛼 for giving VaR, minimize VaR for given 𝛼

• Keating and Shadwick: Ω𝜏 =

∫ ∞𝜏

(1−𝐹 (𝑟))d∫ 𝜏

−∞ 𝐹 (𝑟)d =⇒ max𝒘𝐸(max(𝑟𝑝−𝜏,0))−𝐸(min(𝑟𝑝−𝜏,0))

Dietmar Maringer, Meta-Heuristics in Finance, SAMSI Metaheuristic Optimization, Machine Learning and AI Virtual WorkshopMarch 8-12, 2021

9

Page 10: Meta-Heuristics in Finance · 2021. 3. 5. · 3.4 Di˘erential Evolution. . . . . . . . . . . . . . . . . . . . . . .12 4 Algorithmic and Autotrading17 4.1 some types of algorithmic

3.2.4. a quick reality check• Value-at-Risk under normal and empirical distribution

• three assets, daily returns

• constraints: 𝑤𝑖 ≥ 0 for 𝑖 = 1, 2∑

𝑖 𝑤𝑖 = 1 ⇔ 𝑥3 = 1 − 𝑥1 − 𝑥2

Dietmar Maringer, Meta-Heuristics in Finance, SAMSI Metaheuristic Optimization, Machine Learning and AI Virtual WorkshopMarch 8-12, 2021

10

Page 11: Meta-Heuristics in Finance · 2021. 3. 5. · 3.4 Di˘erential Evolution. . . . . . . . . . . . . . . . . . . . . . .12 4 Algorithmic and Autotrading17 4.1 some types of algorithmic

3.3. sample-based portfolio optimization

3.3.1. concept• back-testing, historical simulation:

⊲ get sample based on assets’ past observations

⊲ compute how portfolio would have performed in the past

⊲ evaluate strategy on past observations

• sample-based optimization:

⊲ create (large) sample for assets’ returns that exhibits properties assumed for investmentperiod

⊲ find portfolio / strategy that works best given criteria / objectives / constraints

3.3.2. how to solve it• data: 𝑆 samples for 𝑁 assets, 𝑹

𝑆×𝑁; objective function: 𝑉𝑎𝑅(𝒘|𝑹, 𝛼)

• decision variables: 𝒘 =⇒(in population-based method with 𝑃 individuals): 𝒘𝑁×𝑃

• constraints:

⊲ ideally: repair function,𝒘𝑓 = R(𝒘) s.t. 𝒘𝑓 ∈ D⊲ occasionally: punishment function

Dietmar Maringer, Meta-Heuristics in Finance, SAMSI Metaheuristic Optimization, Machine Learning and AI Virtual WorkshopMarch 8-12, 2021

11

Page 12: Meta-Heuristics in Finance · 2021. 3. 5. · 3.4 Di˘erential Evolution. . . . . . . . . . . . . . . . . . . . . . .12 4 Algorithmic and Autotrading17 4.1 some types of algorithmic

3.4. Dierential Evolution

3.4.1. basic idea• suggested by Storn and Price (1995)

• continuous, 𝑛 dimensional search space

• population size of 𝑃 vectors, representing positions within search space

𝒙𝑝 = 𝑥𝑝 [𝑖] , 𝑖 = 1 . . . 𝑛, 𝑝 = 1 . . . 𝑃

• evolution: repeat creation + tournament:

⊲ generate another 𝑃 solutions (“ospring”) 𝒚𝑞, 𝑞 = 1 . . . 𝑃

⊲ for each current solution 𝒙𝑝, pick one ospring 𝒚𝑞

⊲ compare fitness values of current and new solutions: 𝑓 (𝒚𝑞)?≷ 𝑓 (𝒙𝑝)

⊲ the one with higher fitness survives

𝑓 (𝒙𝑝) < 𝑓 (𝒚𝑞) =⇒ 𝒙𝑝 := 𝒚𝑞

Dietmar Maringer, Meta-Heuristics in Finance, SAMSI Metaheuristic Optimization, Machine Learning and AI Virtual WorkshopMarch 8-12, 2021

12

Page 13: Meta-Heuristics in Finance · 2021. 3. 5. · 3.4 Di˘erential Evolution. . . . . . . . . . . . . . . . . . . . . . .12 4 Algorithmic and Autotrading17 4.1 some types of algorithmic

• creating new candidates

⊲ take one existing vector, 𝒙𝑚1 , and modify it

⊲ perturbations: vector weighted dierence of two othersolutions, 𝒙𝑚2 − 𝒙𝑚3

⊲ cross-over: elements of 4th solution 𝑝

𝑦𝑞 [𝑖] :={��𝑞 [𝑖] = 𝑥𝑚1 [𝑖] + 𝐹 · (𝑥𝑚2 [𝑖] − 𝑥𝑚3 [𝑖]) with prob. 𝜋

𝑥𝑝 [𝑖] otherwise

Minimum

current population (candidate solutions)

x𝑚3x𝑚2 x𝑚1

(x𝑚2 − x𝑚3 )

y𝑞 = x𝑚1 + 𝐹 · (x𝑚2 − x𝑚3 )

new candidate solution

Algorithm 1: DE pseudo-code for maximization and continuous search space1 set: population size 𝑃, scaling factor 𝐹, cross-over probability 𝜋 , halting criterion, etc.2 initialize: 𝒙𝑝 for 𝑝 = 1..𝑃;3 repeat4 foreach parent 𝑝 do5 randomly select individuals 𝑚1, 𝑚2, 𝑚36 create linear combination ��𝑝 := 𝒙𝑚1 + 𝐹 · (𝒙𝑚2 − 𝒙𝑚3 )7 create new ospring: 𝒚𝑝 := cross-over( ��𝑝, 𝒙𝑝, 𝜋 )

8 foreach ospring 𝑝 do9 if 𝑓 (𝒚𝑝) > 𝑓 (𝒙𝑝) then10 𝒙𝑝 := 𝒚𝑝

11 until halting criterion met;12 report elitist 𝒙∗ = argmax

𝑝=1:𝑃𝑓 (𝒙𝑝)

Dietmar Maringer, Meta-Heuristics in Finance, SAMSI Metaheuristic Optimization, Machine Learning and AI Virtual WorkshopMarch 8-12, 2021

13

Page 14: Meta-Heuristics in Finance · 2021. 3. 5. · 3.4 Di˘erential Evolution. . . . . . . . . . . . . . . . . . . . . . .12 4 Algorithmic and Autotrading17 4.1 some types of algorithmic

3.4.2. extended versions• add extra noise with 𝐸(𝒛) = 0:

⊲ jitter: extra noise added to 𝐹, 𝑧1 [𝑖]⊲ extra noise added to dierence vector, 𝑧2 [𝑖]

𝑦𝑞 [𝑖] :={𝑥𝑚1 [𝑖] + (𝐹+𝑧1 [𝑖]) · (𝑥𝑚2 [𝑖] − 𝑥𝑚3 [𝑖]+𝑧2 [𝑖]) with prob. 𝜋

𝑥𝑝 [𝑖] otherwise

• additional dierence vectors

⊲ e.g., using two current solutions, one current member and the elitist, ...

• use elitist as base-vector 𝒙𝑚1

• for more details, see, e.g., Price, Storn, and Lampinen 2005 or Brabazon, O’Neill, and McGarraghy2015, §6 and the literature quoted therein

3.4.3. constraints• repair function to ensure candidate is feasible

• map candidate to feasible space during function evaluation

• punishment term deteriorates OF when candidate is infeasible

Dietmar Maringer, Meta-Heuristics in Finance, SAMSI Metaheuristic Optimization, Machine Learning and AI Virtual WorkshopMarch 8-12, 2021

14

Page 15: Meta-Heuristics in Finance · 2021. 3. 5. · 3.4 Di˘erential Evolution. . . . . . . . . . . . . . . . . . . . . . .12 4 Algorithmic and Autotrading17 4.1 some types of algorithmic

3.4.4. (very) basic version of DE for maximization

1 import numpy as np2 import numpy.random as rd34 def DEmax(f, x0, repair=lambda x:x,5 popSize=30, FE=10000, F=0.7, probXO=.5):6 # initialize7 D = x0.shape[0] # provide x0 with shape (D,)8 xC = rd.randn(popSize,D)910 xC = repair(xC)11 fC = np.array( [f(xC[p]) for p in range(popSize)] )12 fE = np.min(fC)1314 # evolve15 for gen in range(int(FE/popSize)):16 # linear combination17 p = [rd.permutation(popSize) for i in range(3)]18 xN = xC[p[0]] + F * (xC[p[1]] − xC[p[2]])1920 #cross−over21 XO = rd.rand(popSize,D)<probXO22 xN[XO] = +xC[XO]2324 # evaluation and population update25 xN = repair(xN)26 fN = np.array( [f(xN[p]) for p in range(popSize)] )27 improved = fN>=fC28 fC[improved] = +fN[improved]29 xC[improved] = +xN[improved]3031 i = np.argmax(fC)32 return xC[i]

Dietmar Maringer, Meta-Heuristics in Finance, SAMSI Metaheuristic Optimization, Machine Learning and AI Virtual WorkshopMarch 8-12, 2021

15

Page 16: Meta-Heuristics in Finance · 2021. 3. 5. · 3.4 Di˘erential Evolution. . . . . . . . . . . . . . . . . . . . . . .12 4 Algorithmic and Autotrading17 4.1 some types of algorithmic

3.4.5. VaR optimization• constraint on asset weights:

⊲ repair function for 𝑤𝑖 ≥ 𝑤� ,∑

𝑖 𝑤𝑖 = 1

1 def weight_repair(w,wL=0.0) −> np.array: # lower bound for weights: wL2 w = w.T3 while True:4 w /= np.sum(w,0)5 below = w<wL6 if not(np.any(below)):7 break8 w[below] = wL +.5*(wL−w[below])9 w[np.abs(w)<1e−7] = 010 return w.T

• objective function: empirical VaR for simulated returns r and shortfall probability a

1 def VaR(w,r,a):2 rP = r@w3 v = np.percentile(rP,a)4 return v

Dietmar Maringer, Meta-Heuristics in Finance, SAMSI Metaheuristic Optimization, Machine Learning and AI Virtual WorkshopMarch 8-12, 2021

16

Page 17: Meta-Heuristics in Finance · 2021. 3. 5. · 3.4 Di˘erential Evolution. . . . . . . . . . . . . . . . . . . . . . .12 4 Algorithmic and Autotrading17 4.1 some types of algorithmic

4. Algorithmic and Autotrading

4.1. some types of algorithmic trading systems• buy and sell orders are placed by algorithm / machine

• arbitrage

⊲ self-financing portfolio that makes loss in no situation,but profit in some

⊲ prices are out of equilibrium, e.g., currencies

⊲ dierent prices in dierent markets for same asset USD, $

EUR, €

GBP, £

• executing rules

⊲ pre-specified trading rules

⊲ adjustment to market situations, e.g., iceberg orders

• statistical arbitrage: probability of loss converges to 0, prob of profit to 1

⊲ e.g., pairs trading

• self-adapting / learning systems

⊲ selection and/or combination of pre-specified rules, suitable for current situation

⊲ generation of new rules (algorithms)

Dietmar Maringer, Meta-Heuristics in Finance, SAMSI Metaheuristic Optimization, Machine Learning and AI Virtual WorkshopMarch 8-12, 2021

17

Page 18: Meta-Heuristics in Finance · 2021. 3. 5. · 3.4 Di˘erential Evolution. . . . . . . . . . . . . . . . . . . . . . .12 4 Algorithmic and Autotrading17 4.1 some types of algorithmic

4.2. machine learning and meta-heuristics techniques

4.2.1. setup• data: prices, factors, indices, news, etc.

⊲ suciently large sample of historical / generated data

⊲ online learning

• objective: typically some risk-adjusted performance measure

• model estimation and selection

⊲ e.g., genetic algorithms to find combination of indicators

• pattern detection

⊲ e.g., neural network (convolutional, recurrent, long short termmem-ory, anfis, ...) to get trading signal

• rule generation

⊲ e.g., genetic programming, grammatical evolution to generate trading and / or forecastingrules

Dietmar Maringer, Meta-Heuristics in Finance, SAMSI Metaheuristic Optimization, Machine Learning and AI Virtual WorkshopMarch 8-12, 2021

18

Page 19: Meta-Heuristics in Finance · 2021. 3. 5. · 3.4 Di˘erential Evolution. . . . . . . . . . . . . . . . . . . . . . .12 4 Algorithmic and Autotrading17 4.1 some types of algorithmic

4.2.2. example: Genetic Programming• concept: + Koza 1990

⊲ “population” of (valid) lines of code / equations / rules / . . .⊲ evolve over generations by cross-over and mutation

𝑓𝑝𝑖 (𝑥) = sin(𝑥) + 𝑥4

+

sin

𝑥

÷𝑥 4

𝑓𝑝𝑗 (𝑥) = 3 ∗ (2 + 𝑥)*

3 +2 𝑥

𝑓𝑜𝑘 (𝑥) =𝑥4 ∗(2 + 𝑥)*

÷𝑥 4

+2 𝑥

⊲ supervised learning: prefer solutions based on loss function

⊲ unsupervised learning: preference based on some quality criterion

• examples in finance:

⊲ supervised: find pricing model (risk estimation model) that fit observations

⊲ unsupervised: find trading strategy that maximizes utility, Sharpe ratio, etc.ITE

>

MA

C L1

+

MA

C L2

K

L ITE

<

MA

C L1

MA

C L2

K

S N

© D Maringer, 4303110CR Numerical Optimisation and Simulation Learning (55)

08/07/03 02/23/04 09/10/04 03/29/05 10/15/05

−0.4

−0.2

0

0.2

0.4

0.6

0.8

Single tree 1bp, in−sample cumulated profits

Date

Cum

ulat

ed p

rofit

s

05/03/06 08/11/06 11/19/06 02/27/07 06/07/07−0.4

−0.3

−0.2

−0.1

0

0.1

0.2

0.3

Single tree 1bp, out−of−sample cumulated profits

Date

Cum

ulat

ed p

rofit

s

average performance, results from individual runs, 95% and 99% confidence intervals

Dietmar Maringer, Meta-Heuristics in Finance, SAMSI Metaheuristic Optimization, Machine Learning and AI Virtual WorkshopMarch 8-12, 2021

19

Page 20: Meta-Heuristics in Finance · 2021. 3. 5. · 3.4 Di˘erential Evolution. . . . . . . . . . . . . . . . . . . . . . .12 4 Algorithmic and Autotrading17 4.1 some types of algorithmic

4.2.3. example: Grammatical Evolution• concept: + Ryan, Collins, and O’Neill 1998

• distinction genotype (list of integers) vs. phenotype (interpretation via grammar)

• formal description of valid statements, e.g., Backus-Naur form:

⊲ “grammar” G with G = {N ,T ,S,P}⊲ sets: N = non terminals, T = terminals, S = starting symbol, P = production rules

• sequence of numbers, interpreted according to grammar (“lookup table” of functions andterminals)

⊲ grammar:<expr> ::= <var> 0 | ( <expr> <op> <expr> ) 1

<var> ::= x 0 | y 1

<op> ::= + 0 | - 1 | * 2 | ÷ 3

⊲ genotype [0 0 1 . . .]<expr>

[0 0 1] <var>

[0 0 1] x

⊲ genotype [1 0 0 2 0 3 1 . . .]<expr>

[1 0 0 2 0 3 1 . . .] ( <expr> <op> <expr>)

[1 0 0 2 0 3 1 . . .] ( <var> <op> <expr>)

[1 0 0 2 0 3 1 . . .] ( x <op> <expr>)

[1 0 0 2 0 3 1 . . .] ( x * <expr>)

[1 0 0 2 0 3 1 . . .] ( x * <var>)

[1 0 0 2 0 3 1 . . .] ( x * y)

• examples in finance:

⊲ create models for pricing and price impact, trading rules, etc.

Dietmar Maringer, Meta-Heuristics in Finance, SAMSI Metaheuristic Optimization, Machine Learning and AI Virtual WorkshopMarch 8-12, 2021

20

Page 21: Meta-Heuristics in Finance · 2021. 3. 5. · 3.4 Di˘erential Evolution. . . . . . . . . . . . . . . . . . . . . . .12 4 Algorithmic and Autotrading17 4.1 some types of algorithmic

5. Conclusion

• some literature to get started

⊲ Manfred Gilli, Dietmar Maringer, and Enrico Schumann (2019). Numerical Methods andOptimization in Finance. 2nd edition. Academic Press. url: https://www.elsevier.com/books/numerical-methods-and-optimization-in-finance/gilli/978-0-12-815065-8

⊲ Anthony Brabazon, Michael O’Neill, and Séan McGarraghy (2015). Natural ComputingAlgorithms. Springer

⊲ Dietmar Maringer (2005). Portfolio Management with Heuristic Optimization. Advances inComputational Management Science. Springer, Boston, MA. doi:https://doi.org/10.1007/b136219. url: https://doi.org/10.1007/b136219

Dietmar Maringer, Meta-Heuristics in Finance, SAMSI Metaheuristic Optimization, Machine Learning and AI Virtual WorkshopMarch 8-12, 2021

21

Page 22: Meta-Heuristics in Finance · 2021. 3. 5. · 3.4 Di˘erential Evolution. . . . . . . . . . . . . . . . . . . . . . .12 4 Algorithmic and Autotrading17 4.1 some types of algorithmic

Bibliography

Brabazon, Anthony, Michael O’Neill, and Séan McGarraghy(2015). Natural Computing Algorithms. Springer.

Brooks, Chris, Simon P. Burke, and Gita Persand (2001).“Benchmarks and the Accuracy of GARCH ModelEstimation”. In: International Journal of Forecasting 17.1,pp. 45–56.

Gilli, Manfred, Dietmar Maringer, and Enrico Schumann (2019).Numerical Methods and Optimization in Finance. 2ndedition. Academic Press. url:https://www.elsevier.com/books/numerical-methods-and-

optimization-in-finance/gilli/978-0-12-815065-8.Koza, John R. (1990). Genetic Programming: A Paradigm for

Genetically Breeding Populations of Computer Programsto Solve Problems. Tech. rep. STAN-CS-90-1314. StanfordUniversity Computer Science Department. url:http://www.genetic-programming.com/jkpdf/tr1314.pdf.

Maringer, Dietmar (2005). Portfolio Management withHeuristic Optimization. Advances in ComputationalManagement Science. Springer, Boston, MA. doi:https://doi.org/10.1007/b136219. url:https://doi.org/10.1007/b136219.

Poli, Riccardo, William B. Langdon, and Nicholas F. McPhee(2008). A Field Guide to Genetic Programming.http://www.gp-field-guide.org.uk/. url:http://www.gp-field-guide.org.uk/.

Price, Kenneth V., Rainer M. Storn, and Jouni A. Lampinen(2005). Dierential Evolution: A Practical Approach toGlobal Optimization. Springer.

Ryan, Conor, J.J. Collins, and Michael O’Neill (1998).“Grammatical Evolution: Evolving Programs for anArbitrary Language”. In: Lecture Notes in ComputerScience 1391. First European Workshop on GeneticProgramming 1998. url:http://www.grammatical-evolution.org/papers/eurogp98.ps.

Dietmar Maringer, Meta-Heuristics in Finance, SAMSI Metaheuristic Optimization, Machine Learning and AI Virtual WorkshopMarch 8-12, 2021

22