quantitative analysis of dual moving average...

58
Q A D M A I A T S Doug Service May , CFRM Program Applied Mathematics University of Washington ©Doug Service cbna R/Finance

Upload: buiquynh

Post on 02-Sep-2018

228 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Quantitative Analysis of Dual Moving Average Indicators inAutomated Trading Systems

Doug ServiceMay 21, 2016

CFRM ProgramApplied MathematicsUniversity of Washington

©Doug Service 2016 cbna R/Finance 2016 1

Page 2: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Outline

1. Introduction

2. Assumptions

3. Continuous Time Model

4. Strategy Definition

5. Evaluation Criteria

6. Example

7. Strategy Analysis

Exponentially Filtered Logarithm of Asset Price

Difference Indicator

Transient Behavior

Steady State

Log Return

8. Summary

©Doug Service 2016 cbna R/Finance 2016 2

Page 3: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Introduction

Page 4: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Luxor

Dual Moving Average Technical Trading Strategy [Jaekle and Tomasini(2009)]

Apr 0113:30

Apr 0114:00

Apr 0114:30

Apr 0115:00

Apr 0115:30

Apr 0116:00

Apr 0116:30

Apr 0117:00

Apr 0117:30

Apr 0118:00

Apr 0118:30

Apr 0119:00

Apr 0119:30

Apr 0119:59

Goldman Sachs 2016−04−01 13:30:00 / 2016−04−01 19:59:00

155.5

156.0

156.5

157.0

157.5

158.0

158.5

159.0

159.5

160.0

155.5

156.0

156.5

157.0

157.5

158.0

158.5

159.0

159.5

160.0

Long position - fast MA above slow MA Short position - fast MA below slow MA

©Doug Service 2016 cbna R/Finance 2016 3

Page 5: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Introduction

Luxor dual moving average trading strategyLuxor historically analyzed via inferential statistics

• Discrete time setting• Historical data [Jaekle and Tomasini(2009)]• Bootstrapped resampled [Efron(1979)]) [William Brock(1992)]

to determine

• Expected returns• Draw down• Select strategy parameters etc.

Our goalAssume price dynamics are controlled by a stochastic differential equation (SDE) andderive the Luxor closed form expected log returns in a continuous time setting

• Inspired by work in options pricing [Black and Scholes(1973), Merton(1973)]• Gain analytical tractability by using the natural logarithm of the price• Build frame work for analyzing trading strategies

©Doug Service 2016 cbna R/Finance 2016 4

Page 6: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Assumptions

Page 7: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Assumptions

To gain analytical tractability we assume a frictionless market

1. Difference between the bid and ask price is infinitesimal2. Transaction costs are zero3. Transaction execution is instantaneous4. Buy (sell) transactions fully execute at the current ask (bid) price5. Market contains a single risky asset with price St

©Doug Service 2016 cbna R/Finance 2016 5

Page 8: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Continuous Time Model

Page 9: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Continuous Time Model

Price Dynamics

• Let(

Ω,F , Ftt≥0 ,P)

be a complete filtered probability space

• Dynamics of St under P is controlled by the SDE

dSt = µStdt + σStdWt µ, σ ∈ R constant

• Wt is one dimensional Brownian motion whose history up to time t contained inthe filtration Ftt≥0

• For each ω ∈ Ω there exits a function

Wt(ω) :R+ × Ω→ R+ (the samples)

• W0(ω) = 0, disjoint increments of Wt(ω) are independent, increments W∆t(ω)

are normally distributed with mean zero and variance ∆t, and Wt(ω) iscontinuous on [0, t].

©Doug Service 2016 cbna R/Finance 2016 6

Page 10: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Continuous Time Model

SDE SolutionLet

f(s) = ln s, f ′(s) =1s, f ′′(s) = −

1s2

(dt)2 = 0, (dt)(dWt) = 0, (dWt)2 = dt ([W,W]t = t)

Apply Ito’s formula [Shreve(2004)] to d ln St where dSt = µStdt + σStdWt

df(St) = f ′(St) dSt +12f ′′(St) (dSt)2

d ln St =1StdSt +

12

(−

1S2t

)(dSt)2

=1St

(µStdt + σStdWt) +12

(−

1S2t

)(σ2S2

tdt)

=

(µ−

σ2

2

)dt + σdWt (1)

©Doug Service 2016 cbna R/Finance 2016 7

Page 11: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Continuous Time Model

SDE SolutionIntegrate equation 1 from 0 to t and apply exponential function to both sides

ˆ t

0d ln St =

ˆ t

0

(µ−

σ2

2

)du +

ˆ t

0σdWu

ln St = ln S0 +

(µ−

σ2

2

)t + σWt

St = S0 e(µ−σ22 ) t+σ Wt (2)

The solution St is known as geometric Brownian motion.

©Doug Service 2016 cbna R/Finance 2016 8

Page 12: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Continuous Time Model

ModelDividing both sides of the SDE by St, it can be rewritten as

dStSt

= µdt + σdWt (3)

In essence, the instantaneous return is a constant term plus a volatility term

• If we knew that either µ >> σ22 or µ << σ2

2 and the SDE model is accurate,investing would be easy; thus, we assume |µ− σ2

2 | is not large and µ is not easyto determine for a given asset over a short time frame

©Doug Service 2016 cbna R/Finance 2016 9

Page 13: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Continuous Time Model

Exponentially Filtered Stochastic ProcessAn exponentially filtered stochastic process Υt[Xt; τ ] where τ > 0 is a convolution ofthe exponential kernel function 1

τe−

1τt with the stochastic process Xt.

Υt[Xt; τ ] =

ˆ t

0

1τe−

(t−u)Xudu (4)

Note:

• Υt[Xt; τ ] is a path dependent time series operator• Υt[Xt; τ ] is Ftt≥0 measurable - can calculate Υt[Xt; τ ] given filtration at time t• Lower limit is usually defined as −∞; however, we work with processes on [0, T]

and assume a steady state is reached in finite time at t > tss

©Doug Service 2016 cbna R/Finance 2016 10

Page 14: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Strategy Definition

Page 15: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Strategy Definition

Strategy Components [Peterson(2015)]

• Filters - select instruments• Indicators - quantitative values derived from market data• Signals - respond to interactions between filters, market data, and indicators• Rules - make path dependent actionable decisions when signals fire

Formulate Luxor as a set of equations following this model

©Doug Service 2016 cbna R/Finance 2016 11

Page 16: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Strategy Definition

Difference IndicatorThe difference indicator Ψt : R→ R is the difference of two exponential filtersapplied to a stochastic process Xt where 0 < τ1 < τ2.

Ψt[Xt; τ1, τ2] = Υt[Xt; τ1]−Υt[Xt; τ2]

• Use natural logarithm of the asset price Xt = ln St to gain analytical tractability• Ψt[Xt; τ1, τ2] known as moving average convergence divergence (MACD) oscillator

in technical analysis.

©Doug Service 2016 cbna R/Finance 2016 12

Page 17: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Strategy Definition

Position IndicatorThe position indicator %t : R→ −1,0, 1 is the composition of the signum functionwith the difference indicator and indicates potential long or short positionopportunities.

%t = (sgn Ψ)t = sgn (Ψt) =

1 Ψt ≥ 0 long0 Ψt = 0 previous−1 Ψt < 0 short

(5)

©Doug Service 2016 cbna R/Finance 2016 13

Page 18: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Strategy Definition

Position Entry/Exit SignalsPosition indicator transitions

• (−1→ +1) or (−1→ 0→ +1) exit any short position and enter a long position• (1→ −1) or (1→ 0→ −1) exit any long position and enter short position

Initial entry/final exit occur on first position indicator entry/exit signal after steadystate is reached at t > tss

©Doug Service 2016 cbna R/Finance 2016 14

Page 19: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Strategy Definition

RulesAlways act on position indicator signals (identity function)

• Gain analytical tractability• Efficient implementation uses rules to define

• When and how to enter or exit the market• Determine position size• Manage risk

©Doug Service 2016 cbna R/Finance 2016 15

Page 20: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Evaluation Criteria

Page 21: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Evaluation Criteria

Luxor Log Return

The log return rt of the Luxor strategy on [0, t] is given by the integral of the positionindicator % with respect to the change of the logarithm of the asset price.

rt =

ˆ t

0%ud ln Su (6)

Assumes equal size positions in the asset

©Doug Service 2016 cbna R/Finance 2016 16

Page 22: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Example

Page 23: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Example

Apr 0113:30

Apr 0114:00

Apr 0114:30

Apr 0115:00

Apr 0115:30

Apr 0116:00

Apr 0116:30

Apr 0117:00

Apr 0117:30

Apr 0118:00

Apr 0118:30

Apr 0119:00

Apr 0119:30

Apr 0119:59

Goldman Sachs 2016−04−01 13:30:00 / 2016−04−01 19:59:00

155.5

156.0

156.5

157.0

157.5

158.0

158.5

159.0

159.5

160.0

155.5

156.0

156.5

157.0

157.5

158.0

158.5

159.0

159.5

160.0

lret 0.00038

−0.004

−0.002

0.000

0.002

0.004

−0.004

−0.002

0.000

0.002

0.004

−4e−04−2e−04 0e+00 2e−04 4e−04 6e−04

−0.0015−0.0010−0.0005 0.0000 0.0005 0.0010 0.0015 0.0020

dind/sc 0.12395

−1.0

−0.5

0.0

0.5

1.0

−1.0

−0.5

0.0

0.5

1.0

−1.0

−0.5

0.0

0.5

1.0

sret 0.00038

−0.002−0.001 0.000 0.001 0.002 0.003 0.004

−0.002−0.001 0.000 0.001 0.002 0.003 0.004

csum 0.10798

0.000.020.040.060.080.100.12

0.000.020.040.060.080.100.12

©Doug Service 2016 cbna R/Finance 2016 17

Page 24: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Strategy Analysis

Page 25: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Strategy Analysis

Exponentially Filtered Logarithm of Asset PriceConstruct the exponentially filtered logarithm of the asset price Υt[ln St, τ ] bysubstituting the logarithm of the SDE solution St from equation 2 for Xt in the filterdefinition in equation 4.

Υt[ln St, τ ] =

ˆ t

0

1τe−

(t−u)

[ln S0 +

(µ−

σ2

2

)u + σWu

]du

=e−

1τt

τ

[ln S0

ˆ t

0e

1τudu +

(µ−

σ2

2

) ˆ t

0u e

1τudu + σ

ˆ t

0e

1τuWudu

](7)

First two integrals in Υt[ln St, τ ] are deterministic Riemann integrals wrt time andhave explicit solutions. The last integral is a stochastic Riemann integral of Brownianmotion wrt time.

©Doug Service 2016 cbna R/Finance 2016 18

Page 26: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Strategy Analysis

Exponentially Filtered Logarithm of Asset PriceFirst integral in Υt[ln St, τ ], equation is solved using the fundamental theorem ofcalculus.

ˆ t

0e

1τudu = τ

[e

1τu]t

0

= τ(e

1τt − 1

)(8)

The second integral requires in addition to the fundamental theorem of calculusintegration by parts where

´xdy = xy −

´ydx. Let x = u which implies dx = du, and

let

dy = e1τudu

y =

ˆe

1τudu

= τe1τu (9)

©Doug Service 2016 cbna R/Finance 2016 19

Page 27: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Strategy Analysis

Exponentially Filtered Logarithm of Asset PriceUsing the results from equation 9 to complete the integration by parts solves thesecond integral in Υt[ln St, τ ] from equation 7.

ˆ t

0u e

1τudu = τ

[ue

1τu]t

0−ˆ t

0τe

1τudu

= τ te1τt − τ 2

[e

1τu]t

0

= τ[te

1τt − τ

(e

1τt − 1

)](10)

©Doug Service 2016 cbna R/Finance 2016 20

Page 28: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Strategy Analysis

Exponentially Filtered Logarithm of Asset PriceInserting the results of equations 8 and 10 into Υt[ln St, τ ], equation 7, results in anequation with two deterministic terms and a stochastic term which is a Riemannintegral of scaled Brownian motion wrt time.

Υt[ln St, τ ] =e−

1τt

τ

[τ ln S0

(e

1τt − 1

)+ τ

(µ−

σ2

2

)[te

1τt − τ

(e

1τt − 1

)]+ σ

ˆ t

0e

1τuWudu

]= ln S0

(1− e−

1τt)

+

(µ−

σ2

2

)[t− τ

(1− e−

1τt)]

+σe−

1τt

τ

ˆ t

0e

1τuWudu (11)

©Doug Service 2016 cbna R/Finance 2016 21

Page 29: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Strategy Analysis

Difference IndicatorLet 0 < τ1 < τ2, the difference indicator Ψt[ln St, τ1, τ2] is formed from the differenceof two versions of Υ with different values of τ applied to ln St.

Ψt[ln St, τ1, τ2] = Υt[ln St, τ1]−Υt[ln St, τ2]

= ln S0(

1− e−1τ1t)

+

(µ−

σ2

2

)[t− τ1

(1− e−

1τ1t)]

+σe−

1τ1t

τ1

ˆ t

0e

1τ1uWudu

− ln S0(

1− e−1τ2t)−(µ−

σ2

2

)[t− τ2

(1− e−

1τ2t)]−σe−

1τ2t

τ2

ˆ t

0e

1τ2uWudu

= ln S0(e−

1τ2t − e−

1τ1t)

+

(µ−

σ2

2

)[τ2(

1− e−1τ2t)− τ1

(1− e−

1τ1t)]

+ σ

ˆ t

0

( 1τ1e−

1τ1

(t−u) −1τ2e−

1τ2

(t−u))Wu du (12)

From this point forward Ψt = Ψt[ln St, τ1, τ2].

©Doug Service 2016 cbna R/Finance 2016 22

Page 30: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Strategy Analysis: Difference Indicator

Convert to Ito IntegralWhen ft is deterministic, the Ito product rule [Oksendal(2000)], reduces to

d(ftWt) = (dft)Wt + ftdWt + (dft)(dWt)

= f ′t dtWt + ftdWt

Rearranging terms and integrating both sides from 0 to t gives an integration byparts formula that converts a Riemann integral of Brownian motion wrt time to ascaled Brownian motion term and an Ito integral

f ′tWtdt = d(ftWt)− ftdWtˆ t

0f ′uWudu =

ˆ t

0d(fuWu)−

ˆ t

0fudWu

ˆ t

0f ′uWudu = [fuWu]t0 −

ˆ t

0fudWu (13)

©Doug Service 2016 cbna R/Finance 2016 23

Page 31: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Strategy Analysis: Difference Indicator

Convert to Ito IntegralLet

d fud u

= σ

( 1τ1e−

1τ1

(t−u) −1τ2e−

1τ2

(t−u))

ˆdfu = σ

ˆ ( 1τ1e−

1τ1

(t−u) −1τ2e−

1τ2

(t−u))du

ft = σ(e−

1τ1

(t−u) − e−1τ2

(t−u))

(14)

Rearrange terms as in equation 13

σ

ˆ t

0

( 1τ1e−

1τ1

(t−u) −1τ2e−

1τ2

(t−u))Wu du

=

:0

σ[(e−

1τ1

(t−u) − e−1τ2

(t−u))Wu]t

0− σˆ t

0

(e−

1τ1

(t−u) − e−1τ2

(t−u))dWu

= σ

ˆ t

0

(e−

1τ2

(t−u) − e−1τ1

(t−u))dWu (15)

©Doug Service 2016 cbna R/Finance 2016 24

Page 32: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Strategy Analysis: Difference Indicator

Ito ProcessSubstituting the results of the integration by parts into equation 12 converts Ψt to anIto process

Ψt = ln S0(e−

1τ2t − e−

1τ1t)

+

(µ−

σ2

2

)[τ2(

1− e−1τ2t)− τ1

(1− e−

1τ1t)]

+ σ

ˆ t

0

(e−

1τ2

(t−u) − e−1τ1

(t−u))dWu (16)

©Doug Service 2016 cbna R/Finance 2016 25

Page 33: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Strategy Analysis: Difference Indicator

Transient BehaviorDefine the first two terms of Ψt equation 16 as

bt,1 = ln S0[e−

1τ2t − e−

1τ1t]

(17)

bt,2 =

(µ−

σ2

2

)[τ2(

1− e−1τ2t)− τ1

(1− e−

1τ1t)]

(18)

©Doug Service 2016 cbna R/Finance 2016 26

Page 34: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Strategy Analysis: Difference Indicator

Plot of bt,1 and bt,2 with µ = 0, σ = 0.1, τ1 = 5, and τ2 = 10

0.0

0.4

0.8

b(t,1

),b'

(t,1

),b'

'(t,1

)

bt1

dbt1

dtd2bt1

d2t

bt1

dbt1

dtd2bt1

d2t

bt1

dbt1

dtd2bt1

d2t

0 20 40 60 80 100

Time

−0.

025

−0.

015

−0.

005

b(t,2

)

©Doug Service 2016 cbna R/Finance 2016 27

Page 35: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Strategy Analysis: Difference Indicator

Steady State AssumptionsWe assume that for S0 > 1 and 0 < τ1 < τ2 there exists a tss such that for all t > tssthe transient behavior of the deterministic terms bt,1 and bt,2 is insignificant to theanalysis and can be ignored.

limt→∞

[bt,1 + bt,2]

= limt→∞

[ln S0

(e−

1τ2t − e−

1τ1t)

+

(µ−

σ2

2

)[τ2(

1− e−1τ2t)− τ1

(1− e−

1τ1t)]]

=

(µ−

σ2

2

)(τ2 − τ1) (19)

We assume that ∣∣∣∣ limt→∞

[bt,1 + bt,2]− [bt,1 + bt,2]t=tss

∣∣∣∣ < δ (20)

for some sufficiently small δ.

©Doug Service 2016 cbna R/Finance 2016 28

Page 36: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Strategy Analysis: Difference Indicator

Steady State Difference Indicator

Ψt =

(µ−

σ2

2

)(τ2 − τ1) + σ

ˆ t

0

(e−

1τ2

(t−u) − e−1τ1

(t−u))dWu (21)

©Doug Service 2016 cbna R/Finance 2016 29

Page 37: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Strategy Analysis: Steady State

Expected Value and Variance of Ψt

Let Mt represent the Ito integral contained in the definition of Ψt in equation 21.

Mt = σ

ˆ t

0

(e−

1τ2

(t−u) − e−1τ1

(t−u))dWu

=

ˆ t

0Γ(u;t) dWu where Γ(u;t) = σ

(e−

1τ2

(t−u) − e−1τ1

(t−u))

(22)

Since Γ2(u;t) is square integrable, E

[´ t0 Γ2

(u;t) du]<∞, and for all u ≤ t, Γ(u;t) is Ft

adapted, the conditions of Theorem 4.3.1 [Shreve(2004)] are met and Mt is amartingale. This implies that given 0 < s < t

E [Mt|Fs] = Ms (23)

Γ(0;0)=0 and W0 = 0 implies that M0 = 0 which combined with the martingaleproperty expressed in equation 23 implies for all t > 0 E [Mt] = 0.

©Doug Service 2016 cbna R/Finance 2016 30

Page 38: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Expected Value and Variance of Ψt

Theorem 4.3.1 [Shreve(2004)] also implies

E [Ψt] = E[(µ−

σ2

2

)(τ2 − τ1) + σ

ˆ t

0

(e−

1τ2

(t−u) − e−1τ1

(t−u))dWu

]=

(µ−

σ2

2

)(τ2 − τ1) (24)

©Doug Service 2016 cbna R/Finance 2016 31

Page 39: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Strategy Analysis: Steady State

Expected Value and Variance of Ψt

Only the Ito integral contributes to the variance of Ψt

V [ Ψt] = V [Mt]

= E[(Mt − E [Mt])

2] = E[M2t]

= E[ˆ t

0Γ2

(u;t) du]

= E[σ2ˆ t

0

(e−

1τ2

(t−u) − e−1τ1

(t−u))2

du]

= σ2ˆ t

0

(e−

1τ2

(t−u) − e−1τ1

(t−u))2

du

= σ2ˆ t

0

(e−

2τ2

(t−u) − 2e−(

1τ1

+ 1τ2

)(t−u)

+ e−2τ1

(t−u)

)du

= σ2

[ τ22e−

2τ2

(t−u)]t

0−[

21τ1

+ 1τ2

e−(

1τ1

+ 1τ2

)(t−u)

]t0

+[ τ1

2e−

2τ1

(t−u)]t

0

= σ2

(τ22

(1− e−

2τ2t)−

21τ1

+ 1τ2

(1− e−

(1τ1

+ 1τ2

)t)

+τ12

(1− e−

2τ1t))

(25)

©Doug Service 2016 cbna R/Finance 2016 32

Page 40: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Strategy Analysis: Steady State

Variance of Ψt for parameter values σ = 0.1, τ1 = 5 and τ2 = 10

0 20 40 60 80 100

0.00

00.

002

0.00

40.

006

0.00

8

Time

V(ψ

t)

©Doug Service 2016 cbna R/Finance 2016 33

Page 41: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Strategy Analysis: Steady State

When t = 0 in equation 25, the variance of Mt is equal to zero which is expectedsince W0 = 0. Consider the limit of equation 25 as t goes to infinity.

limt→∞

V [Mt]

= limt→∞

[σ2(τ22

(1− e−

2τ2t)−

21τ1

+ 1τ2

(1− e−

(1τ1

+ 1τ2

)t)

+τ12

(1− e−

2τ1t))]

= σ2(τ22−

21τ1

+ 1τ2

+τ12

)

=σ2

2

((τ2 − τ1)2

τ1 + τ2

)(26)

Since 0 < τ1 < τ2 the steady state variance of Ψt is always greater than zero which isexpected as it should only be zero if the two exponentially filtered stochastic processhave the same value of τ . We assume that∣∣∣∣ lim

t→∞V [Mt]− V [Mt]|t=tss

∣∣∣∣ < δ (27)

for some sufficiently small δ.

©Doug Service 2016 cbna R/Finance 2016 34

Page 42: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Strategy Analysis: Steady State

Distribution of Ψt

Since Mt is an Ito integral with respect to Brownian motion with a deterministicintegrand Γ(u;t), by Theorem 4.4.9 [Shreve(2004)] for each t > 0, Mt is normallydistributed with expected value zero and variance

´ t0 Γ2

(u;t) du. Thus, Ψt fromequation 21 is normally distributed with the expected value u and variance s given byequations 24 and 26.

Ψt ∼ N(u, s2)

∼ N((

µ−σ2

2

)(τ2 − τ1) ,

σ2

2

((τ2 − τ1)2

τ1 + τ2

))(28)

Note that for t > tss mean and variance are constant and not dependent on t, but onthe constants µ, σ, τ1, and τ2.

©Doug Service 2016 cbna R/Finance 2016 35

Page 43: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Strategy Analysis: Steady State

V [Ψt] = σ22

((τ2−τ1)2

τ1+τ2

)Plot of V(Ψt) vs τ1 and τ2

05

1015

1520

2530

3540

450.00

0.01

0.02

0.03

0.04

0.05

τ1

τ2

V(ψt)

0.00

0.01

0.02

0.03

0.04

0.05

0.06

©Doug Service 2016 cbna R/Finance 2016 36

Page 44: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Strategy Analysis: Steady State

Density of Ψt

Given that Ψt is normal with mean u and variance s2, Ψt ∼ N (u, s), the cumulativedistribution function (CDF) FΨ and probability density function (PDF) fΨ for Ψt are

FΨ = Φ

(ψ − us

)(29)

fΨ =d FΨ

dψ=

1sφ

(ψ − us

)(30)

where Φ is the standard normal CDF and φ is the standard normal PDF. Substitutionof u and s from equation 28 into equation 30 gives the full density function for Ψt.Once the steady state regime is reached the density function has no dependence ont.

fΨ =1

σ (τ2 − τ1)√

π(τ1+τ2)

exp

−(ψ −

(µ− σ2

2

)(τ2 − τ1)

)2

σ2(τ2−τ1)2

(τ1+τ2)

(31)

©Doug Service 2016 cbna R/Finance 2016 37

Page 45: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Strategy Analysis: Steady State

Expected Value of %tThe position indicator %t from equation 5 is a function of the random variable Ψtwhose distribution we have from equation 28; thus, we can calculate the expectedvalue of the position indicator using Theorem 3.2.2 part (ix) [Ito(1984)].

E [%t] =

ˆ ∞−∞

sgn (ψ) fΨ(ψ) dψ

=

ˆ ∞−∞

sgn (ψ)1sφ

(ψ − us

)dψ

=

ˆ 0

−∞(−1)

1sφ

(ψ − us

)dψ +

ˆ ∞0

(1)1sφ

(ψ − us

)dψ

= lima→∞

(ψ − us

)]a0− lim

b→−∞

(ψ − us

)]0

b

=

[1− Φ

(0− us

)]−[

Φ

(0− us

)− 0]

©Doug Service 2016 cbna R/Finance 2016 38

Page 46: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Strategy Analysis: Steady State

Expected Value of %t Continued

E [%t] = 1− 2Φ

(−us

)

= 1− 2Φ

−(µ− σ2

2

)(τ2 − τ1)

σ22

((τ2−τ1)2

τ1+τ2

)

= 1− 2Φ

[−

2σ2

(µ−

σ2

2

)τ1 + τ2τ2 − τ1

](32)

©Doug Service 2016 cbna R/Finance 2016 39

Page 47: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Strategy Analysis: Steady State

Log Return Expected ValueWe have now assembled the results needed to calculate the Luxor steady stateexpected log return rt as given in definition 16.

E [rt] = E[ˆ t

0%ud (ln Su)

]= E

[ˆ t

0%u

[(µ−

σ2

2

)du + σdWu

]]= E

[(µ−

σ2

2

) ˆ t

0%u du + σ

ˆ t

0%u dWu

]=

(µ−

σ2

2

)E[ˆ t

0%u du

]+ σ E

[ˆ t

0%u dWu

](33)

©Doug Service 2016 cbna R/Finance 2016 40

Page 48: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Strategy Analysis: Log Return

Log ReturnThe position indicator %t by definition is a random sequence of the elements in theset −1,0, 1 which implies

ˆ t

0%2u du ≤ t <∞ (34)

thus %2t is square integrable on [0, t]. In addition, %t is Ft adapted; therefore, the Ito

integral inside the second expected value in equation 33 mets the conditions ofTheorem 4.3.1 [Shreve(2004)] and the integral is a martingale with an initial andexpected value of zero.

Define the function g such that

ξ = g(ρ) =

ˆ t

0ρ du (35)

and define the random variable Ξt.

Ξt = g(%t) =

ˆ t

0%u du (36)

©Doug Service 2016 cbna R/Finance 2016 41

Page 49: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Strategy Analysis: Log Return

Log ReturnSince the last term in equation 33 is zero, the expected value of the log return isgiven by the first term.

E [rt] =

(µ−

σ2

2

)E[ˆ t

0%u du

]=

(µ−

σ2

2

)E [Ξt]

=

(µ−

σ2

2

) ˆ ∞−∞

ξ fΞt (ξ) dξ

Substitute ξ = g(ρ) and fΞt (ξ) dξ = f%t (ρ) dρ

via Theorem 3.2.2 part (ix) in [Ito(1984)]

=

(µ−

σ2

2

) ˆ ∞−∞

g(ρ) f%t (ρ) dρ

=

(µ−

σ2

2

) ˆ ∞−∞

(ˆ t

0ρ du

)f%t (ρ) dρ (37)

(38)

©Doug Service 2016 cbna R/Finance 2016 42

Page 50: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Strategy Analysis: Log Return

Log ReturnChange the order of integration via Fubini’s theorem

=

(µ−

σ2

2

) ˆ t

0

(ˆ ∞−∞

ρ f%t (ρ) dρ)du

=

(µ−

σ2

2

) ˆ t

0E [%u] du (39)

Inserting the expected value of % from equation 32 into equation 39 and solving theintegral gives the expected log return.

E [rt] =

(µ−

σ2

2

) ˆ t

0

[1− 2Φ

(−

2σ2

(µ−

σ2

2

)τ1 + τ2τ2 − τ1

)]du

=

(µ−

σ2

2

)(1− 2Φ

[−

2σ2

(µ−

σ2

2

)τ1 + τ2τ2 − τ1

])t (40)

©Doug Service 2016 cbna R/Finance 2016 43

Page 51: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Strategy Analysis: Log Return

Proposition:Given the assumptions and model in sections 5 and 6, the expected steady state logreturn of the Luxor strategy is greater than or equal to zero.

E [rt] ≥ 0 (41)

Proof:We proceed by determining the sign of each term in equation 40. t and σ2 arepositive by definition, and τ1+τ2

τ2−τ1> 0 since 0 < τ1 < τ2. Let

C = −2σ2

(µ−

σ2

2

)τ1 + τ2τ2 − τ1

(42)

Thus the order relation between µ and σ22 controls the sign of C.

©Doug Service 2016 cbna R/Finance 2016 44

Page 52: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Strategy Analysis: Log Return

Proof (Continued):

Table 1 gives the value of µ relative to σ22 in the left column, the sign of each term

that can take on a negative value in the center columns and the resulting expectedlog return E [rt] in the right hand column.

µ C Φ 1− 2Φ(µ− σ2

2

)E [rt]

> σ22 - < 1

2 + + +

= σ22 0 = 1

2 0 0 0

< σ22 + > 1

2 - - +

Table 1: Expected Log Return Relative to µ and σ

Comparing the far left hand column with the far right hand column in table 1, we seethat for every µ ∈ R, σ ∈ R≥0, and 0 < τ1 < τ2, the expected log return rt is greaterthan or equal to zero.

©Doug Service 2016 cbna R/Finance 2016 45

Page 53: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Strategy Analysis: Log Return

d E[rt]d t =

(µ− σ2

2

)(1− 2Φ

[− 2σ2

(µ− σ2

2

)τ1+τ2τ2−τ1

])σ = 0.1, τ1 = 3, τ2 = 20, t = 1

−0.10 −0.05 0.00 0.05 0.10 0.15

−0.

10−

0.05

0.00

0.05

0.10

0.15

mu

log

retu

rn

σ2

2 buy and holdluxor

©Doug Service 2016 cbna R/Finance 2016 46

Page 54: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Strategy Analysis: Log Return

d E[rt]d t =

(µ− σ2

2

)(1− 2Φ

[− 2σ2

(µ− σ2

2

)τ1+τ2τ2−τ1

])σ = 0.3, τ1 = 3, τ2 = 20, t = 1

−0.10 −0.05 0.00 0.05 0.10 0.15 0.20

−0.

15−

0.10

−0.

050.

000.

050.

100.

15

mu

log

retu

rn

σ2

2buy and holdluxor

©Doug Service 2016 cbna R/Finance 2016 47

Page 55: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Summary

Page 56: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Summary

ResultsGiven the assumptions and model in sections 5 and 6, we

• Derived a closed form solution for the expected log returns of Luxor• Demonstrated Luxor has a non negative expected value• When µ > σ2

2 high volatility causes under performance compared to buy andhold

IssuesIssues we are currently addressing

• Simple SDE model does not capture features of stock prices that may beadvantageous to strategies like Luxor

• More accurate price SDE models• More realistic transaction and slippage models

©Doug Service 2016 cbna R/Finance 2016 48

Page 57: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Bibliography I

Fischer Black and Myron Scholes.The pricing of options and corporate liabilities.Journal of Political Ecomon, 1973.

B. Efron.Bootstrap methods: Another look at the jackknife.The Annals of Statistics, 7(1):1–26, Jan 1979.

Kiyosi Ito.Introduction to Probability Theory.Cambridge University Press, english edition, 1984.Originally published in Japanese 1978.

Urban Jaekle and Emilio Tomasini.Trading Systems - A New Approach to System Development and PortfolioOptimization.HarrimanHouse Ltd, 2009.Robert C. Merton.Theory of rational option pricing.The Bell Journal of Economics and Mangement Science, 4(1):141–183, Spring 1973.

©Doug Service 2016 cbna R/Finance 2016 49

Page 58: Quantitative Analysis of Dual Moving Average …past.rinfinance.com/agenda/2016/talk/DougService.pdf · Quantitative Analysis of Dual Moving Average Indicators in Automated ... trading

Bibliography II

Bernt Oksendal.Stochastic Differential Equations: An Introduction with Applications.Springer-Verlag, 5th edition, 2000.

Brian G. Peterson.Developing and backtesting systematic trading strategies.June 2015.URL https://r-forge.r-project.org/scm/viewvc.php/*checkout*/pkg/quantstrat/

sandbox/backtest_musings/strat_dev_process.pdf?root=blotter.

Steven E. Shreve.Stochastic Calculus for Finance: Continous-Time Models, volume II of SpringerFinance Textbook.Springer, 2004.

Blake LeBaron William Brock, Josef Lakonishokk.Simple technical trading rules and the stochastic properties of stock returns.The Journal of Finance, 47(5):1731–1764, Dec 1992.

©Doug Service 2016 cbna R/Finance 2016 50