Optimization of Trading Strategies in Continuous Intraday ... · 1 arbitraging against earlier bids...

38
Optimization of Trading Strategies in Continuous Intraday Markets Anthony Papavasiliou, Gilles Bertrand Center for Operations Research and Econometrics Universit´ e catholique de Louvain January 31, 2019

Transcript of Optimization of Trading Strategies in Continuous Intraday ... · 1 arbitraging against earlier bids...

Page 1: Optimization of Trading Strategies in Continuous Intraday ... · 1 arbitraging against earlier bids with less interesting prices (rolling intrinsic, risk-free) 2 waiting for more

Optimization of Trading Strategiesin Continuous Intraday Markets

Anthony Papavasiliou, Gilles Bertrand

Center for Operations Research and EconometricsUniversite catholique de Louvain

January 31, 2019

Page 2: Optimization of Trading Strategies in Continuous Intraday ... · 1 arbitraging against earlier bids with less interesting prices (rolling intrinsic, risk-free) 2 waiting for more

Outline

1 Introduction

2 Rolling Intrinsic and Perfect Foresight

3 MDP Formulation of Continuous Intraday TradingMDPs and Policy FunctionsIllustration of Threshold Policies: Purely Financial Problem

4 Threshold Policy

5 Case Study: German Intraday Market

1

Page 3: Optimization of Trading Strategies in Continuous Intraday ... · 1 arbitraging against earlier bids with less interesting prices (rolling intrinsic, risk-free) 2 waiting for more

Outline

1 Introduction

2 Rolling Intrinsic and Perfect Foresight

3 MDP Formulation of Continuous Intraday TradingMDPs and Policy FunctionsIllustration of Threshold Policies: Purely Financial Problem

4 Threshold Policy

5 Case Study: German Intraday Market

2

Page 4: Optimization of Trading Strategies in Continuous Intraday ... · 1 arbitraging against earlier bids with less interesting prices (rolling intrinsic, risk-free) 2 waiting for more

Motivation

2012 2013 2014 2015 2016 2017

Year

0

1

2

3

4

5

6

7

8N

um

be

r o

f tr

ad

es o

n t

he

Be

lgia

n c

on

tin

uo

us in

tra

da

y m

ark

et

104

3

Page 5: Optimization of Trading Strategies in Continuous Intraday ... · 1 arbitraging against earlier bids with less interesting prices (rolling intrinsic, risk-free) 2 waiting for more

Description of the Continuous Intraday Market

Figure: Short-term German electricity market

4

Page 6: Optimization of Trading Strategies in Continuous Intraday ... · 1 arbitraging against earlier bids with less interesting prices (rolling intrinsic, risk-free) 2 waiting for more

Format of Intraday Bids

Hour Quarter Type Price (e/MWh) Quantity (MW)

Bid 1 1 h s 28 10

Bid 2 1 h b 25 5

Bid 3 1 q1 b 30 8

Bid 4 1 q2 b 25 2.5

Bid 5 1 q3 s 27 0.3

Bid 6 2 h b 29 0.8

Bid 7 14 q4 s 32 3

Bids arrive continuously in the intraday platform

Bids are reserved on first-come-first-serve basis

5

Page 7: Optimization of Trading Strategies in Continuous Intraday ... · 1 arbitraging against earlier bids with less interesting prices (rolling intrinsic, risk-free) 2 waiting for more

Literature Review

Intraday price models

[Kiesel 2015]: Econometric study of the parameters influencing theprice evolution

[Kiesel 2017]: modelling of order arrivals using Hawkes process

Trading by assuming a price model

[Aid 2015]: solving the trading problem of a thermal generator usingstochastic differential equations, assuming some model for the priceevolution

[Braun 2016]: solving the problem of optimizing pumped storagetrading if we have access to a price curve for the coming hours

Trading without assuming a price model

[Skajaa 2015]: heuristic method for covering the position of a windfarm based on imbalance price forecast

6

Page 8: Optimization of Trading Strategies in Continuous Intraday ... · 1 arbitraging against earlier bids with less interesting prices (rolling intrinsic, risk-free) 2 waiting for more

Our Goal

We are interested in a model-free approach that can handle

continuous arrival of orders

multi-stage uncertainty

management of flexible (e.g. pumped hydro, storage) assets

7

Page 9: Optimization of Trading Strategies in Continuous Intraday ... · 1 arbitraging against earlier bids with less interesting prices (rolling intrinsic, risk-free) 2 waiting for more

Outline

1 Introduction

2 Rolling Intrinsic and Perfect Foresight

3 MDP Formulation of Continuous Intraday TradingMDPs and Policy FunctionsIllustration of Threshold Policies: Purely Financial Problem

4 Threshold Policy

5 Case Study: German Intraday Market

8

Page 10: Optimization of Trading Strategies in Continuous Intraday ... · 1 arbitraging against earlier bids with less interesting prices (rolling intrinsic, risk-free) 2 waiting for more

Rolling Intrinsic

We consider the rolling intrinsic policy as a benchmark [Lohndorf,Wozabal, 2015]

Applied for intraday trading with pumped hydro

Receding horizon approach

Myopic: accept any feasible trade that gives an instantaneous profit

9

Page 11: Optimization of Trading Strategies in Continuous Intraday ... · 1 arbitraging against earlier bids with less interesting prices (rolling intrinsic, risk-free) 2 waiting for more

Rolling Intrinsic Model

Accept any feasible trade that gives a positive profit

(Pt) : maxqs/bi,t ,vt,d

∑d∈D

∑i∈Id

(Pbi · qbi ,t − Ps

i · qsi ,t)

qs/bi ,t ≤ Q

s/bi ,t ∀i ∈ Id , d ∈ D

vt,d = vt−1,d

+∑

b∈D|b≤d

∑i∈Ib

(qsi ,t − qbi ,t

)∀d ∈ D

vt,d ≤ V ∀d ∈ D

vt,d ≥ 0 ∀d ∈ D

qs/bi ,t ≥ 0 ∀i ∈ Id , d ∈ D

10

Page 12: Optimization of Trading Strategies in Continuous Intraday ... · 1 arbitraging against earlier bids with less interesting prices (rolling intrinsic, risk-free) 2 waiting for more

Perfect Foresight

Use perfect foresight model in order to:

obtain upper bounds for any trading policy

gain insights from the KKT conditions in order to design our policy

11

Page 13: Optimization of Trading Strategies in Continuous Intraday ... · 1 arbitraging against earlier bids with less interesting prices (rolling intrinsic, risk-free) 2 waiting for more

Perfect Foresight Model

The variables are not indexed by t anymore because perfect foresightsetting is equivalent to having access to all bids at once

max∑d∈D

∑i∈Id

(Pbi · qbi − Ps

i · qsi)

qs/bi ≤ Q

s/bi ∀i ∈ Id , d ∈ D (µs

i,d)

vd = vd−1 +∑i∈Id

(qsi,d − qbi,d

)∀d ∈ D (λd)

vd ≤ V ∀d ∈ D (γd)

vd ≥ 0 ∀d ∈ D (βd)

qs/bi,d ≥ 0 ∀i ∈ I , d ∈ D (νsi,d)

12

Page 14: Optimization of Trading Strategies in Continuous Intraday ... · 1 arbitraging against earlier bids with less interesting prices (rolling intrinsic, risk-free) 2 waiting for more

KKT Analysis of Perfect Foresight Policy

If λd < Pbi , we have qbi = Qb

i

If λd > Pbi , we have qbi = 0

If λd < Psi , we have qsi = 0

If λd > Psi , we have qsi = Qs

i

Interpretation of λd : threshold above which we sell and below which webuy

This suggests that a threshold policy could be a reasonable tradingstrategy

13

Page 15: Optimization of Trading Strategies in Continuous Intraday ... · 1 arbitraging against earlier bids with less interesting prices (rolling intrinsic, risk-free) 2 waiting for more

Outline

1 Introduction

2 Rolling Intrinsic and Perfect Foresight

3 MDP Formulation of Continuous Intraday TradingMDPs and Policy FunctionsIllustration of Threshold Policies: Purely Financial Problem

4 Threshold Policy

5 Case Study: German Intraday Market

14

Page 16: Optimization of Trading Strategies in Continuous Intraday ... · 1 arbitraging against earlier bids with less interesting prices (rolling intrinsic, risk-free) 2 waiting for more

Definition of a Markov Decision Process

Markov decision process

A Markov decision process is a tuple (S,A,P,R), where

S is a set of states

A is a set of actions

Pas,s′ = P[St+1 = s ′|St = s,At = a] is the probability to arrive in state

s ′ if we follow action a in state s

R is a reward function, R(s, a) = E[Rt+1|St = s,At = a]

15

Page 17: Optimization of Trading Strategies in Continuous Intraday ... · 1 arbitraging against earlier bids with less interesting prices (rolling intrinsic, risk-free) 2 waiting for more

Definition of a Markov Decision Process

Objective function

We optimize over a set of policies for the sum of reward if we follow apolicy

maxπ∈Π

T∑t=1

E [Rt(St ,Aπ(St))]

16

Page 18: Optimization of Trading Strategies in Continuous Intraday ... · 1 arbitraging against earlier bids with less interesting prices (rolling intrinsic, risk-free) 2 waiting for more

Policy Function Approximation

Policy function approximation (PFA)

The idea in PFA is to approximate directly the policy

π(a|s; θ) = P[At = a|St = s; θ]

17

Page 19: Optimization of Trading Strategies in Continuous Intraday ... · 1 arbitraging against earlier bids with less interesting prices (rolling intrinsic, risk-free) 2 waiting for more

Illustration of Threshold Policies: Purely Financial Problem

We have to decide whether to accept a bid at the intraday price pID

We know the intraday price pID, but the real-time price pRT isuncertain

18

Page 20: Optimization of Trading Strategies in Continuous Intraday ... · 1 arbitraging against earlier bids with less interesting prices (rolling intrinsic, risk-free) 2 waiting for more

MDP Formulation of Purely Financial Problem

Purely financial problem as an MDP

S = {pID}, the intraday price

A = {a}, a binary variable whose value is equal to 1 if we accept thebid, or 0 if we reject it

R(s, a) = E[pID − pRT|pID] · a

Policy function approximation for the purely financial problem

We use a stochastic threshold policy with parameters θ = (µ, σ)

π(pID, 0; θ) = 1− Fθ(pID)

π(pID, 1; θ) = Fθ(pID)

19

Page 21: Optimization of Trading Strategies in Continuous Intraday ... · 1 arbitraging against earlier bids with less interesting prices (rolling intrinsic, risk-free) 2 waiting for more

Graphical Illustration of a Stochastic Threshold

20

Page 22: Optimization of Trading Strategies in Continuous Intraday ... · 1 arbitraging against earlier bids with less interesting prices (rolling intrinsic, risk-free) 2 waiting for more

Payoff for Bivariate Normal Distribution

Payoff as a function of θ = (µ, 0+):

J(µ) = E[pID − pRT|pID ≥ µ

]· (1− FpID(µ))

20 22 24 26 28 30

Mu [Eur/MWh]

0

0.2

0.4

0.6

0.8

1

1.2

1.4E

xpecte

d p

rofit [E

ur/

MW

h]

rho=-0.99

rho=-0.5

rho=0

rho=0.5

rho=0.99

Assuming that (pID, pRT) are bivariate normal, J(µ) can be computedanalytically and is a non-concave function of µ

21

Page 23: Optimization of Trading Strategies in Continuous Intraday ... · 1 arbitraging against earlier bids with less interesting prices (rolling intrinsic, risk-free) 2 waiting for more

Outline

1 Introduction

2 Rolling Intrinsic and Perfect Foresight

3 MDP Formulation of Continuous Intraday TradingMDPs and Policy FunctionsIllustration of Threshold Policies: Purely Financial Problem

4 Threshold Policy

5 Case Study: German Intraday Market

22

Page 24: Optimization of Trading Strategies in Continuous Intraday ... · 1 arbitraging against earlier bids with less interesting prices (rolling intrinsic, risk-free) 2 waiting for more

Graphical Representation of Threshold Policy for PumpedHydro Problem

23

Page 25: Optimization of Trading Strategies in Continuous Intraday ... · 1 arbitraging against earlier bids with less interesting prices (rolling intrinsic, risk-free) 2 waiting for more

Graphical Representation of Threshold Policy

We use a threshold policy, which is a distribution over actions:

The bell curve indicates the probability density function of the sellthreshold

The two purple segments and the red segment of the bell curveindicate the probability of each of the three actions:

Sell 0 MWhSell 10 MWhSell 20 MWh

The green decreasing function corresponds to the buy bids that areavailable in the order book for a given trading hour

We are interested in finding an optimal threshold

24

Page 26: Optimization of Trading Strategies in Continuous Intraday ... · 1 arbitraging against earlier bids with less interesting prices (rolling intrinsic, risk-free) 2 waiting for more

REINFORCE Algorithm

Algorithm

REINFORCE algorithm for finite horizon:

Initialize θ0

for each episode {s1, a1, r2, · · · , sT−1, aT−1, rT} ∼ πθfor t = 1 : T − 1 do

θk+1 = θk + α∇θlog(π(st , at ; θ))gtend for

end for

Remark

gt is the profit from t to the end T of the episode

∇θlog

These gradients can be expressed in closed form

25

Page 27: Optimization of Trading Strategies in Continuous Intraday ... · 1 arbitraging against earlier bids with less interesting prices (rolling intrinsic, risk-free) 2 waiting for more

Generalization of the Threshold Policy

Let f : Rn → R be a differentiable function s.t. θ = f (α). We cancompute the derivative with respect to α by using the chain rule:

∂π(s; θ)

∂α=∂π(s; θ)

∂θ

∂θ

∂α

=∂π(s; θ)

∂θ

∂f

α

This allows us to influence the threshold by observing relevant factors

26

Page 28: Optimization of Trading Strategies in Continuous Intraday ... · 1 arbitraging against earlier bids with less interesting prices (rolling intrinsic, risk-free) 2 waiting for more

Expected Behaviour of a Threshold Policy

1 Ensure that the stored volume respects reservoir limits

2 Adapt with respect to the intraday auction price

3 Adapt with respect to the delivery time

4 Adapt with respect to the evolution of intraday prices

5 Adapt with respect to the remaining time

27

Page 29: Optimization of Trading Strategies in Continuous Intraday ... · 1 arbitraging against earlier bids with less interesting prices (rolling intrinsic, risk-free) 2 waiting for more

Outline

1 Introduction

2 Rolling Intrinsic and Perfect Foresight

3 MDP Formulation of Continuous Intraday TradingMDPs and Policy FunctionsIllustration of Threshold Policies: Purely Financial Problem

4 Threshold Policy

5 Case Study: German Intraday Market

28

Page 30: Optimization of Trading Strategies in Continuous Intraday ... · 1 arbitraging against earlier bids with less interesting prices (rolling intrinsic, risk-free) 2 waiting for more

Case Study

Data source: 2 years of data of the German CIM, procured fromEPEX

Training data: 200 days of 2015

Testing data: 165 last days of 2015

29

Page 31: Optimization of Trading Strategies in Continuous Intraday ... · 1 arbitraging against earlier bids with less interesting prices (rolling intrinsic, risk-free) 2 waiting for more

Training the Policy Function

This graph shows the evolution of the profit with respect to the iteration.An iteration corresponds to 5 repetitions of our 200 days of learning.

0 500 1000 1500

Iteration

3500

4000

4500

5000

5500

6000

6500

7000

Obta

ined p

rofit [E

uro

/day]

30

Page 32: Optimization of Trading Strategies in Continuous Intraday ... · 1 arbitraging against earlier bids with less interesting prices (rolling intrinsic, risk-free) 2 waiting for more

Competing Policies

We have compared the results of four different methods:

Rolling intrinsic 4pm: rolling intrinsic method launched at 4pm

Rolling intrinsic 11pm: rolling intrinsic method launched at 11pm

Threshold: our proposed threshold policy

Perfect foresight

31

Page 33: Optimization of Trading Strategies in Continuous Intraday ... · 1 arbitraging against earlier bids with less interesting prices (rolling intrinsic, risk-free) 2 waiting for more

Comparison of Policies

MethodProfit

mean [e/day]Profit standard

deviation [e/day]

Rolling intrinsic 4pm 4042 1968

Rolling intrinsic 11pm 4871 2034

Threshold 5076 2484

Perfect foresight 10321 4416

In the next slides, we will compare the two best performing policies:

rolling intrinsic starting at 11pm

threshold policy

32

Page 34: Optimization of Trading Strategies in Continuous Intraday ... · 1 arbitraging against earlier bids with less interesting prices (rolling intrinsic, risk-free) 2 waiting for more

Distribution of Profits

One occurrence corresponds to one day of trading

The profit is accumulated gradually and is not coming from one spike

-6000 -4000 -2000 0 2000 4000 6000

thres -

rol [Eur/day]

0

10

20

30

40

Nu

mb

er

of

occu

ren

ce

s

33

Page 35: Optimization of Trading Strategies in Continuous Intraday ... · 1 arbitraging against earlier bids with less interesting prices (rolling intrinsic, risk-free) 2 waiting for more

Significance of Profit Difference

We conduct a p-value test with the two following hypotheses

Null hypothesis: E[Πthres] = E[Πrol]

Alternative hypothesis: E[Πthres] > E[Πrol]

We find that the probability of obtaining the observed profit differenceswith E[Πthres] = E[Πrol] is equal to 0.7%

34

Page 36: Optimization of Trading Strategies in Continuous Intraday ... · 1 arbitraging against earlier bids with less interesting prices (rolling intrinsic, risk-free) 2 waiting for more

Different Attitude towards Risk

There is a trade-off between

1 arbitraging against earlier bids with less interesting prices (rollingintrinsic, risk-free)

2 waiting for more interesting prices later in the day (threshold policy,more risky)

35

Page 37: Optimization of Trading Strategies in Continuous Intraday ... · 1 arbitraging against earlier bids with less interesting prices (rolling intrinsic, risk-free) 2 waiting for more

Conclusions and Perspectives

Observations

The profit of rolling intrinsic varies significantly with the time thattrading commencesOur method outperforms rolling intrinsic with statistical significance

Future research

We are trading at hourly frequency, we would like to solve the problemat higher trading frequencyStep size analysisAccelerated learning through parallel computing

36

Page 38: Optimization of Trading Strategies in Continuous Intraday ... · 1 arbitraging against earlier bids with less interesting prices (rolling intrinsic, risk-free) 2 waiting for more

Thank you

Contact:

Anthony Papavasiliou, [email protected]://perso.uclouvain.be/anthony.papavasiliou/

Gilles Bertrand, [email protected]://sites.google.com/site/gillesbertrandresearch/home

37