Where should you enter and exit? Practitioners use "enter at two standard deviations, exit at the mean". Under an OU model the question has an exact answer, and the answer is far from two standard deviations.
Centre the spread so that θ=0. Fix levels a<m and a round-trip cost c (in spread units). The cycle strategy (Bertram 2010): when X hits a, buy one unit of the spread; when it then hits m, sell; wait until X returns to a; repeat. With continuous monitoring, each completed trade earns exactly m−a−c. The OU process is positive recurrent, so every trade eventually closes, and by the strong Markov property the cycle lengths T1,T2,… are i.i.d. By the renewal–reward theorem the long-run profit per unit time is
μ(a,m)=E[T]m−a−c,E[T]=Ea[τm]+Em[τa],(13A.26)
where τℓ is the first time the process hits ℓ. A symmetric long–short version that also sells the spread at m and buys it back at a earns 2(m−a−c) per cycle and has the same optimal levels.
where erfcx(u)=eu2erfc(u). For x>ℓ, by the reflection x−θ↦θ−x, replace erfcx(−u) by erfcx(u) and integrate from zℓ to z.
Proof
Take θ=0. Let T(x)=Ex[τℓ] for x<ℓ. The generator of (13A.22) is L=−κx∂x+2σ2∂xx. By Dynkin's formula, T solves
2σ2T′′(x)−κxT′(x)=−1,T(ℓ)=0,
with T growing no faster than polynomially as x→−∞ (the boundary at −∞ is natural). Multiply by the integrating factor σ22e−κx2/σ2: (e−κx2/σ2T′(x))′=−σ22e−κx2/σ2. Integrate from −∞ (where e−κx2/σ2T′(x)→0 under the growth condition):
T′(x)=−σ22eκx2/σ2∫−∞xe−κw2/σ2dw.
Integrate from x to ℓ using T(ℓ)=0; this gives the double integral in (13A.27). Substitute w=σu′/κ: ∫−∞ve−κw2/σ2dw=κσ2πerfc(−u) with u=vκ/σ, and dv=σdu/κ. The constants combine to σ22⋅κσ2⋅2π=κπ, and eu2erfc(−u)=erfcx(−u).∎
The scaled complementary error function erfcx is used because eu2 and erfc separately overflow and underflow for moderate u; scipy.special.erfcx is stable.
Add the two passage times from (13A.27). In u-units, erfcx(−u)+erfcx(u)=eu2[erfc(−u)+erfc(u)]=2eu2. So E[T]=κπ∫zazm2eu2du=κππ[erfi(zm)−erfi(za)].∎
The inner integrals over (−∞,v) and (v,∞) add to a constant, which is why the round trip has a closed form and each leg separately does not.
Proposition 13A.11optimal bands for expected profit per unit time
(a) Any interior maximiser of μ(a,m) in (13A.26) is symmetric about θ: a=θ−d, m=θ+d. (b) With u=dκ/σ and c^=cκ/σ, the optimal u∗ is the unique root in (c^/2,∞) of
(2u−c^)eu2=πerfi(u).(13A.29)
(c) For small c^, u∗≈(3c^/4)1/3: the band width grows like the cube root of the cost. (d) As c→0, the maximal rate tends to σκ/(2π), approached as d→0.
Proof
(a) Take θ=0 and write μ=(m−a−c)/[K(E(m)−E(a))] with E(x)=erfi(xκ/σ) and K=π/κ. The first-order conditions in m and a are E(m)−E(a)=(m−a−c)E′(m) and E(m)−E(a)=(m−a−c)E′(a). Hence E′(m)=E′(a), i.e. eκm2/σ2=eκa2/σ2, so m=±a, and a<m forces a=−m.
(b) With a=−d, m=d and erfi odd, μ∝(2u−c^)/erfi(u) in the scaled variables. Setting the derivative to zero: 2erfi(u)=(2u−c^)π2eu2, which is (13A.29). Let g(u)=(2u−c^)eu2−πerfi(u). Then g(c^/2)=−πerfi(c^/2)<0, g→+∞, and g′(u)=2eu2+2u(2u−c^)eu2−2eu2=2u(2u−c^)eu2>0 for u>c^/2. So the root is unique, and since the profit rate is negative for u<c^/2 and tends to zero as u→∞, it is the maximum.
(c) Expand eu2=1+u2+O(u4) and πerfi(u)=2u+32u3+O(u5). Then (13A.29) becomes 2u+2u3−c^−c^u2=2u+32u3+O(u5), i.e. 34u3≈c^ to leading order.
(d) With c=0, μ=2d/[κ2πerfi(u)]=πκκσerfi(u)u. Since erfi(u)/u=π2∫01eu2s2ds increases in u, μ decreases in d and tends to πσκ⋅2π=2πσκ as u→0.∎
Part (d) is a continuous-time artefact. Without costs the optimal strategy trades infinitely often on infinitely narrow bands and collects a finite profit rate, a manifestation of the local time of the diffusion. Costs and discrete monitoring are what make bands finite. The cube-root law in (c) is the same scaling that appears in optimal portfolio rebalancing with proportional costs.
Worked example
(the spread of 13A.7: κ=7.615, σ=0.1605, stationary s.d. 0.0411; round-trip cost c=0.002, i.e. 20 bp of the long-leg notional for both legs in and out, an illustrative figure for liquid Indian stock futures including slippage):
Band ±d
d in stationary s.d.
Expected cycle (trading days)
Profit rate per year (spread units)
Optimal d∗=0.01739
0.42
71.7
0.1143
±0.25 s.d.
0.25
41.6
0.1116
±0.5 s.d.
0.5
85.9
0.1140
±1 s.d.
1.0
196.7
0.1020
±1.5 s.d.
1.5
381.3
0.0796
±2 s.d.
2.0
778.3
0.0522
Here c^=0.0344 and the cube-root approximation gives d≈0.01719, within 1.2% of the exact root. The zero-cost bound is 0.16057.615/(2π)=0.1250 per year. The common "±2 s.d." rule earns less than half the optimal rate under the model, because the spread reaches two standard deviations rarely (expected cycle more than three years of trading days).
band_backtest in m13a_ou.py runs the strategy on a daily-sampled path (400 simulated years, optimal band, c=0.002). Because the spread jumps past the band between observations, each fill is worse at entry and better at exit than the band level. The mean P&L per trade was 0.0446 against the theoretical 0.0328 and the mean cycle 99.4 days against 71.7, so the realised rate (0.112 per year) was close to the theoretical 0.114. On a much finer grid (50 steps per day) the test file checks that both the cycle length and the P&L per trade match (13A.26)–(13A.28) within 8%. With daily data and a daily shock (0.01) comparable to the optimal band (0.017), the overshoot is a first-order effect on per-trade numbers.
Practitioner notes
The optimal band depends on κ and σ, which are estimated with the errors of 13A.7. A 26% overestimate of κ moves d∗ only through c^∝κ, by about 4% via the cube root. The profit rate is more sensitive: it scales roughly with σκ.
Desks use wider bands than the expected-return optimum for reasons outside the model: robustness to a break in the spread, financing and margin costs proportional to holding time, and the Sharpe ratio (Bertram also derives Sharpe-optimal bands, which are wider).
There is no stop-loss in the cycle strategy. Under a true OU, any stop-loss lowers the expected return. In reality a stop-loss is a test of the model: a spread at five standard deviations is more likely to have broken than to be a bargain. Leung and Li (2015) solve the optimal stopping problem with a stop-loss.
Profit "per unit of spread" is per rupee of the long leg with β rupees short. Margin is posted on both futures legs, so return on capital is lower.