{'fraction_non_alphanumeric': 0.05563642591086184, 'fraction_numerical': 0.019416020893094146, 'mean_word_length': 3.9507206443408225, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 25, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 29, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Detecting data-driven robust statistical arbitrage strategies with deep neural networks

We present an approach, based on deep neural networks, that allows identifying robust statistical arbitrage strategies in financial markets. Robust statistical arbitrage strategies refer to self-financing trading strategies that enable profitable trading under model ambiguity. The presented novel methodology does not suffer from the curse of dimensionality nor does it depend on the identification of cointegrated pairs of assets and is therefore applicable even on high-dimensional financial markets or in markets where classical pairs trading approaches fail. Moreover, we provide a method to build an ambiguity set of admissible probability measures that can be derived from observed market data. Thus, the approach can be considered as being model-free and entirely data-driven. We showcase the applicability of our method by providing empirical investigations with highly profitable trading performances even in 50 dimensions, during financial crises, and when the cointegration relationship between asset pairs stops to persist.


Introduction
In this paper we present an empirically tractable method using neural networks that allows identifying robust statistical arbitrage strategies in financial markets.
The term statistical arbitrage is commonly used in finance to describe trading strategies which are profitable on average, but, in contrast to pure arbitrage strategies (see e.g., [15,17,45] for their detection), not necessarily in every market scenario that is deemed to be possible. This generalized notion therefore forms the foundation for a systematic approach enabling to trade profitably even in markets in which it is difficult or impossible to detect pure arbitrage strategies.
A popular class of trading strategies that are often referred to as statistical arbitrage strategies are pairs trading strategies, which all rely on the fundamental idea that, given two financial assets are strongly related, e.g., through a cointegration property (compare e.g. [13]) or through a low level of the variance of the spread between the two assets (compare e.g. [30]), then deviations of the spread are assumed to last only for a short period of time and, thus, eventually the spread of the asset pair will return to its long-term equilibrium. This mean-reversion property is exploited by trading in the opposite direction of the deviation after the deviation has exceeded a certain threshold and by clearing the position when the spread has reached again a level close to its long-term equilibrium, see also [5,22,27,30,40,41,49,55].
The apparent drawback of applying pairs trading strategies is the strong dependence on the underlying mean-reversion property of the spread process. Indeed, if the mean-reversion relation breaks down and thus the spread does not converge to its equilibrium, then the pairs trading approach will in general not be profitable. Moreover, in an empirical study, [21] provide evidence that the profitability of pairs trading strategies has declined over the recent years, mainly as it has become increasingly difficult to identify profitable asset pairs.
In contrast, our contribution builds on another class of statistical arbitrage strategies that do not rely on a mean-reversion property. We will show that these strategies are profitable even in periods where the pairs trading approach fails. Our approach relies on the idea of Bondarenko ([10]), who introduced and characterized statistical arbitrage strategies as self-financing strategies which are profitable on average given any terminal value of the underlying securities at a fixed maturity t n > 0, Date i.e., if Φ(S) denotes the profit of a trading strategy investing in underlying securities S = (S) t≤tn , then statistical arbitrage strategies fulfil E P [Φ(S) | S tn ] ≥ 0 as well as P E P [Φ(S) | S tn ] > 0 > 0. Based on this idea, [38] generalized the notion of statistical arbitrage from [10] by introducing Garbitrage defined through zero-cost payoffs Y (which are not necessarily the payoffs of self-financing trading strategies) fulfilling (1.1) E P [Y | G] ≥ 0 and P E P [Y | G] > 0 > 0 for G being a σ-algebra G ⊆ σ(S), which allows, in particular, to take into account more flexible choices of trading strategies, possibly adjusted to available information.
Building on the definition of G-arbitrage, the results from [10, Proposition 1], [38,Proposition 6], and [50,Theorem 3.3] characterize the existence of G-arbitrage strategies by relating the absence of self-financing strategies fulfilling (1.1) to the existence of G-measurable Radon-Nikodym densities, a result which can be considered as an extension of the fundamental theorem of asset-pricing (compare [2,11,19,34,53] for several versions of the fundamental theorem of asset-pricing in different underlying settings) which connects the absence of arbitrage with the existence of pricing measures. The authors from [50] further propose and validate empirically an embedding-methodology to exploit statistical arbitrage on financial markets. All these mentioned contributions assume that the underlying securities behave according to a previously fixed underlying probability measure P. To account for ambiguity with respect to the choice of an underlying probability measure [44] recently introduced the notion of P-robust G-arbitrage referring to self-financing trading strategies that allow for G-arbitrage independent which measure P from the considered ambiguity set of measures P is the "correct" underlying probability measure, as the strategy is required to be profitable for all measures from the ambiguity set. Hence, this notion allows, in particular, to take into account probability measures that would incur losses for conventional pairs trading strategies, and thus to determine trading strategies that are profitable even in scenarios where pairs trading fails.
To compute P-robust statistical arbitrage strategies, i.e., P-robust G-arbitrage strategies for the choice G = σ(S tn ), where S tn denotes the terminal values of the underlying securities, a methodology in [44] is provided that relies on a linear programming approach. This routine therefore suffers from the curse of dimensionality and cannot be applied in high-dimensional settings. To overcome this limitation, we establish a numerical method involving deep neural networks to determine Probust statistical arbitrage strategies. To this end, we introduce a functional which penalizes selffinancing trading strategies that are not statistical arbitrage strategies for each of the considered measures from the ambiguity set P. We show as a main result in Theorem 2.14 that minimizing this functional among trading strategies that can be represented as the outputs of deep neural networks is, for a sufficiently large penalization parameter, equivalent to the determination of Probust statistical arbitrage strategies. In particular, through the representation of trading strategies by neural networks, our approach does not suffer from the curse of dimensionality, in contrast to approaches relying on linear programming, and is hence tractable even when the trading strategy depends on a large amount of underlying assets. We provide empirical evidence in Section 4.4 of the applicability of our approach in a high-dimensional setting, where we consider strategies investing in 50 underlying assets from the S&P 500 universe.
As a choice of the ambiguity set P, we propose a purely data-driven approach as follows. First, relying on a historical time-series of stock returns, a probability measure is constructed that considers each sequence of observed historical returns as equally likely to occur again in the future. Second, since this measure allows no deviation of future returns from historical returns, we consider a ball around this measure (where the ball is taken with respect to the Wasserstein-distance). Finally, we provide a methodology to explicitly generate measures from this ball.
In contrast to the determination of statistical arbitrage strategies with respect to a fixed underlying probability measure, taking into account the ambiguity set allows, particularly, that the future developments of the underlying process differ to a certain degree (this degree can be specified by the applicant and is expressed in terms of the Wasserstein-distance) from the historical evolution. Indeed, by using this data-driven ambiguity set of measures P we provide empirical evidence for the profitability of our approach in overall bad market scenarios (Section 4.3), in high-dimensional financial markets (Section 4.4), and in scenarios where classical pairs trading approaches fail (Section 4.5).
The remainder of this paper is as follows. In Section 2 we introduce the underlying setting and present our main theoretical results. Section 3 presents an approach to first derive an ambiguity set of measures P from financial data and then use a numerical method to compute P-robust statistical arbitrage strategies when considering the data-implied set P as the ambiguity set of physical measures. In Section 4 we then provide empirical evidence for the applicability of our approach by studying several relevant examples involving real-world data. Section 5 concludes and provides an outlook to future research. The proofs of all mathematical statements are provided in Section 6.

Setting and main results
We consider a financial market on which we examine the evolution of d ∈ N underlying securities at n ∈ N future times t 1 < · · · < t n . The future values of all securities are assumed to be bounded from below and from above by some (possibly very large) constants 1 . More precisely, for each j ∈ {1, . . . , d} there exist security-specific bounds K j , K j ∈ R satisfying K j < K j . We then define which refers to the bounds for the evolution of the underlying assets until time t i . Then, we model the evolution of the values of the underlying securities until time t n through the canonical process on Ω := Ω n and we denote this process by S := (S j t i ) j=1,...,d i=1,...,n , which is for i = 1, . . . , n; j = 1, . . . , d defined by Moreover, we introduce for the values of the d securities at each time t i the notation S t i := (S j t i ) j=1,...,d and denote for ( the observed, and therefore deterministic, spot prices at initial time t 0 . Then we define the gross profit of a self-financing trading strategy ∆ : Additionally, we assume that trading in a self-financing strategy ∆ induces transaction costs. If a trader adjusts at time t i his trading position ∆ j i−1 and changes it to a new position ∆ j i , then this adjustment causes transactions costs c j i ∆ j i (S t 1 , . . . , S t i ) − ∆ j i−1 (S t 1 , . . . , S t i−1 ) for some measurable non-negative function c j i : R → R + . Thus, given some trading strategy ∆, the overall transaction costs until time t n are measured by with the convention ∆ j −1 ≡ ∆ j n ≡ 0 for all j = 1, . . . , d. Therefore, the net overall profit of a self-financing trading strategy ∆ is given by  Figure 3 where we illustrate that if the width of the interval [K j , K j ], j ∈ {1, . . . , d}, spanned by the bounds K j , K j of the securities, exceeds a certain threshold, then the performance of our approach does not further improve. Thus, assuming a setting considering large bounds for the underlying securities turns out to be no restriction in practice when applying our approach.
2.1. P-robust G-arbitrage strategies. The notion of (statistical) arbitrage depends crucially on the choice of an underlying probability measure. To take into account uncertainty with respect to the choice of the correct underlying model -and the associated probability measure -we consider a set P ⊆ M 1 (Ω), where M 1 (Ω) denotes the set of Borel probability measures on Ω. The set P can thus be considered as an ambiguity set of admissible physical probability measures. Our approach relies on the notion of P-robust G-arbitrage, which is borrowed from [44] and adjusted to the present multi-asset setting with transaction costs. Definition 2.3 (P-robust G-arbitrage). Let P ⊆ M 1 (Ω), and let G ⊆ σ(S) be a sigma-algebra on Ω. Then, a self-financing strategy ∆ is called a P-robust G-arbitrage strategy if the following conditions are fulfilled.
The constant B, which restricts the amount an investor is able to invest, possesses therefore a natural interpretation as a given budget constraint. Moreover, we obtain from the following lemma that H B,L is compact. Given some measurable function Φ : Ω → R and some σ-algebra G ⊆ σ(S), we are interested in solving the following conditional super-replication problem Solutions of Γ B,L are interesting for two reasons. For a financial derivative with payoff function Φ, the value Γ B,L (Φ, G) describes the upper bound of prices for Φ which do not allow for P-robust G-arbitrage, given the market admits no P-robust G-arbitrage opportunities, see also the discussion in [44,Section 4.2]. On the other hand, if the market admits P-robust G-arbitrage, the definition of Γ B,L allows to determine P-robust G-arbitrage strategies. Indeed, when considering Φ ≡ 0, then Γ B,L (0, G) < 0 leads, according to Definition 2.3, directly to a P-robust G-arbitrage strategy, since Γ B,L (0, G) < 0 implies the existence of some strategy with negative price which has, conditional on G, a non-negative payoff.

2.
2. An approximation of Γ B,L via penalization. In the following we establish a numerical method to compute Γ B,L as well as associated P-robust G-arbitrage strategies relying on a penalization approach, similar to the approaches pursued in [8,16,18,24,25,26,36] . To facilitate a numerical implementation, we impose the standing assumption that P contains a finite amount of measures.
Assumption 2.5. The set P ⊂ M 1 (Ω) contains a finite amount of measures.
2 Let a, b ∈ N. Then, we say a function f : with · a denoting the Euclidean norm on R a . Note that for any X ⊆ R a and f : X → R b we denote by f ∞,X,b := sup x∈X f (x) b the supremum-norm restricted to the set X. Moreover, to simplify notations, we write Let M > 0, let Φ : Ω → R be some Borel measurable function, and let G ⊆ σ(S) be some σ-algebra on Ω, then to approximate Γ B,L numerically, we introduce for each k ∈ N the following functional where β : R → R + is some penalization function which penalizes trading strategies h c,∆ ∈ H B,L for which the conditional super-replication constraint s. for all P ∈ P is violated. To ensure that β penalizes as intended, we impose additionally the following assumption on the geometry of β.
A natural choice for the function β is therefore given by β(x) := λ · max{0, x} p for some λ > 0, p > 0. As we will show below, the compactness of H B,L , stated in Lemma 2.4, induces the existence of some strategy attaining the value of Γ B,L,k .
Lemma 2.7. Let Assumptions 2.1, 2.5, 2.6 hold true. Let B > 0, let L > 0, and let Φ : Ω → R be Borel measurable with Φ ∞,Ω ≤ B. Then for every σ-algebra G ⊆ σ(S) on Ω and for all k ∈ N the infimum of Γ B,L,k is attained, i.e., there exists h c * ,∆ * ∈ H B,L such that By employing Lemma 2.4 and Lemma 2.7, we can derive the following result which shows that Γ B,L can indeed be approximated arbitrarily well by Γ B,L,k by choosing k sufficiently large.

2.
3. An approximation of Γ B,L through neural networks. Next, we show how the functional Γ B,L,k can be approximated with trading strategies whose positions are represented by an appropriate class of neural networks. To this end, we present a problem-tailored class of fully-connected feed-forward neural networks which we will use to approximate the class of bounded and Lipschitz-continuous trading strategies H B,L .
More specifically, for any m ∈ N we consider fully-connected neural networks which have input dimension m ∈ N, output dimension d, and number of layers l + 1 ∈ N defined as functions of the form where (A i ) i=0,...,l are affine functions of the form where for i = 1, . . . , l we have ϕ i (x 1 , . . . , x h i ) = (ϕ(x 1 ), . . . , ϕ(x h i )) with ϕ : R → R being a nonconstant function which is referred to as activation function. The vector h = (h 1 , . . . , h l ) ∈ N l contains the number of neurons of the hidden layers. We call h also the hidden dimension of the neural network. Assumption 2.10. We assume that the activation function ϕ : R → R is either one time continuously differentiable and not polynomial, or that ϕ is the ReLU.
For a fixed activation function, we consider the set of all neural networks with input dimension m ∈ N, l ∈ N hidden layers, hidden dimension h ∈ N , and output dimension d ∈ N and we call this set N l,h m,d . Next, we introduce an additional degree of freedom by considering all neural networks where the hidden dimension is arbitrary and the number of hidden layers is not specified, i.e., We further restrict to those neural networks with outputs that are componentwise bounded by a constant B > 0 and L-Lipschitz, when restricted to Ω i , i ∈ N.
where π j : R d → R denotes the canonical projection onto the j-th component, i.e., we have for every x ∈ R m . One reason for the importance and popularity of deep neural networks is their universal approximation property (compare e.g., for the classical result [37, Theorem 2], [39, Theorem 3.2] for arbitrary input and output dimensions, and [23, Theorem 1] for neural networks which are Lipschitz continuous with respect to some pre-specified constant). We establish the following form of a universal approximation theorem tailored to our setting which is useful to approximate trading positions from H B,L .
Lemma 2.11. Let Assumption 2.10 hold true. Then, for all i = 1, . . . , n, for all L > 0 and for all with respect to the uniform topology on Ω i .
We remark that the requirement on the activation function formulated in Lemma 2.11 is in particular fulfilled by those activation functions mentioned in Remark 2.9. The reduction of H B,L to those strategies that can be represented by neural networks leads to the set The associated functional is then defined accordingly by which relies on the same penalization as Γ B,L,k expressed through the function β. The following result employing Lemma 2.11 establishes that Γ B,L,k can indeed be approximated arbitrarily well by appropriate neural networks. Then for every σ-algebra G ⊆ σ(S) on Ω and for all k ∈ N we have

2.4.
Computation of P-robust statistical arbitrage strategies with neural networks. We now focus on the computation of P-robust statistical arbitrage strategies. These are P-robust Garbitrage strategies with the specific choice G := σ(S tn ). These strategies have a particular importance as they can be interpreted as profitable trading strategies on average given any terminal value, compare also [10], [38], [44], and [50]. As σ(S tn ) contains an infinite number of sets, it is a priori unclear how to compute numerically a conditional expectation with respect to σ(S tn ). However, recall that conditional expectations with respect to any σ-algebra F generated by a finite partition can be computed efficiently. 3 Thus, with Pseudo-Algorithm 1 we establish a routine enabling the generation of random sets from the σ-algebra σ(S tn ). To this end, we consider for every i ∈ N the finite partition Input : The bounds K j < K j , j = 1, . . . , d of possible stock prices; Generate a random set We obtain, by construction, that for each i ∈ N the set E i contains (at most) 2 i sets and fulfils For any realization of the Pseudo-Algorithm 1, we set One possible choice of distribution according to which the random sets ) are generated is the following: For each i ∈ N and for all j = 1, . . . , d, let The following proposition then shows that for P U -almost all realizations of Pseudo-Algorithm 1, conditional expectations with respect to the sigma-algebra σ(S tn ) can be approximated arbitrarily well by conditional expectations with respect to F i , defined in (2.8), for large enough i ∈ N 0 . Since each F i is generated by a finite partition, this allows to compute the corresponding conditional expectation efficiently.
where the convergence holds both P-almost surely and in L 1 (P).
We build on Proposition 2.8, Proposition 2.12, and Proposition 2.13 to establish the following main theorem.
Theorem 2.14. Let Assumptions 2.1, 2.5, 2.6, 2.10 hold true. Further, assume that β is convex. Then for all B > 0, for all L > 0, and for all Φ : Ω → R Borel measurable with Φ ∞,Ω ≤ B, the following equality holds P U -almost surely: In particular, in view of Equation (2.10) we have for large enough k and i that is an optimization problem involving neural networks which can be solved efficiently. We will apply this approximation on real-world data in the next section.

Remark 2.15.
(i) Proposition 2.13 and Theorem 2.14 rely on the construction from Pseudo-Algorithm 1 that allows to generate random partitions (E i ) i∈N . Note that while (2.6) and (2.9) are numerically tractable, the creation of sets involving complements as in (2.7) suffers from the curse of dimensionality and is therefore not tractable in higher dimensions. For this reason, we call this methodology a pseudo-algorithm and provide with Algorithm 3 a numerical feasible methodology to generate indicator functions of sets of the corresponding partition (E i ) i∈N avoiding the explicit creation of complements. As it turns out in Algorithm 4, considering indicator functions instead of computing explicit sets is sufficient to compute expressions of the form Hence, we consider Pseudo-Algorithm 1 as a theoretical routine, while Algorithm 3 and Algorithm 4 can be used in practice to compute P-robust statistical arbitrage strategies.
(ii) Proposition 2.13 and Theorem 2.14 remain still valid if we replace (E i ) i∈N by any family for each i ∈ N and σ (S tn ) = σ ∪ i∈N E i . This is satisfied, e.g., by the (deterministic) dyadic For our numerical experiments we decided however to use the partition (E i ) i∈N from Pseudo-Algorithm 1, mainly because Algorithm 3 admits a computationally efficient algorithm to construct indicators of sets in E i .
, then a similar procedure as in Proposition 2.13 and Theorem 2.14, where the case G = σ(S tn ) is considered, can be obtained, by generating for each i ∈ N a finite partition However, note that for G = σ (S tn ) it is not guaranteed that one can efficiently generate elements A i 1 , . . . , A i B ⊆ (A i ) i∈N as in (2.6) of Pseudo-Algorithm 1. However, if it is possible to do so, one can apply the same Algorithm 3 to efficiently compute indicators of the partition obtained via (2.7).

Determination of the ambiguity set and the numerical algorithm
We next use the approximation Γ B,L (Φ, σ(S tn )) ≈ Γ N N B,L,k (Φ, F i ), for large k, i ∈ N justified by Theorem 2.14 and introduce an approach enabling to detect P-robust statistical arbitrage strategies on financial markets. First, in Section 3.1, we propose an approach to determine an entirely datadriven ambiguity set P, then, in Section 3.2, we provide a neural network-based numerical algorithm.
3.1. Determination of an ambiguity set of physical measures. We assume that we are able to observe a time series . . , N consisting of N ∈ N observed past prices of each of the underlying d securities on which we rely our trading strategy on. The past observation dates are denoted by s 1 , . . . , s N with s N ≤ t 0 , compare also Figure 1.
Past observation dates Future trading dates Based on the time series Y , our aim is to construct an entirely data-driven ambiguity set P such that we are able to detect P-robust statistical arbitrage strategies which turn out to be profitable. Recall that we aim to determine a trading strategy which trades at future dates (t i ) i=0,...,n−1 . Assume for sake of simplicity that and that N > n. Further, assume that at time t 0 we observe the spot values This allows us to determine the empirical measure P ∈ M 1 (R nd ), relying on the observations from Y and on the current spot values S t 0 , through where δ x denotes the Dirac measure with unit mass at x ∈ R nd , and where the multiplication with S t 0 as well as division with respect to Y s i is meant component-wise. This means, according to (3.1), the measure P assigns equal probability to all N − n scaled paths of length n that were observed at times (s ) =1,...,N −n to occur in the future, compare also the left and middle panel of Figure 2. Note that the construction in (3.1) ensures particularly that the future paths evolve according to observed paths while the scaling ensures that the spot value of all considered future paths coincides with S t 0 . Left: An exemplary observed path (Y s i ) i=1,...,7 is displayed. Centre: In the case n = 2 the future paths with positive probability under P are shown. To each of the paths equal probability is assigned. Right: A possible realization of P τ is depicted, the paths from P are deviated according to a normally distributed realization of τ .
The empirical measure P relies entirely on past data and on the spot value S t 0 , whereas for the future development of the securities we want to take into account uncertainty with respect to the choice of the underlying probability measure, but still consider only such measures which are in a certain sense close to the observed data. To measure the distance between two probability measures P, Q ∈ M 1 (R nd ), we therefore introduce the 1-Wasserstein-distance 5 which is defined as with Π(P, Q) ⊂ M 1 R nd × R nd denoting the set of all joint distributions of P and Q, compare e.g. [3,52,56] for more details on the Wasserstein distance and the related topic of optimal transport. Let ε > 0, then we consider some ambiguity set P ⊂ M 1 (R nd ) such that the therein contained measures lie within the Wasserstein ball around P with radius ε > 0, i.e., P ⊂ B ε ( P) := P ∈ M 1 (R nd ) W( P, P) < ε .
In that way each P ∈ P can be considered to be close to the empirical measure P. Next, we introduce for some τ = (τ 1 , . . . , τ N −n ) ∈ R nd(N −n) the perturbed measure compare also the right panel of Figure 2. The following lemma asserts that choosing τ appropriately ensures that the measure P τ is indeed contained in B ε ( P).
Moreover, let P be defined by (3.1), and P τ by (3.2). Then we have that P τ ∈ B ε ( P).
Then, based on Lemma 3.1, we are able to determine a set P ⊂ B ε ( P) which contains a finite number of N measures ∈ N. We summarize this procedure in Algorithm 2.
n the following way. Consider for j = 1, . . . , d Based on the above bounds (S j ) j=1,...,d and (S j ) j=1,...,d , we define, for some δ > 0, the underlying space by setting Then, we see that P ∈ M 1 (Ω) and for each 0 < ε ≤ δ and τ ∈ R nd(N −n) satisfying (3.3) we have P τ ∈ M 1 (Ω). 5 Alternatively, one could have used, e.g., the Kullback-Leibler divergence ( [42]) to measure the distance between two measures. However, the Kullback-Leibler divergence requires absolute continuity of the considered measures, which means in our case that considered measures would have been restricted to the support determined by the observed prices (Ys i ) i∈N . The 1-Wasserstein distance does not suffer from this restriction.
Algorithm 2: Generation of a set P ⊂ B ε ( P).
Input : Time series Y ∈ (0, ∞) dN ; Spot prices S t 0 ∈ (0, ∞) d ; Radius of the Wasserstein ball ε > 0; Amount of measures N measures ∈ N to generate; Variance of the random perturbations σ 2 > 0; Output: Set P ⊂ B ε ( P) of probability measures; for m = 1, . . . , N measures do  Generate end for i = 1, . . . , B do Set the i-th element of s to 1 if S tn ∈ A i and 0 otherwise; end Treat s as a binary number and convert it into a decimal number s : Set the ( s + 1)-th entry of v to 1; Then, by construction, the indicator vector (1l {St n ∈F b } ) b=1,...,2 B coincides with v.
Based on this methodology, we propose a method specified in Algorithm 3 that allows to compute efficiently indicator functions of the form 1l {St n ∈E} for E ∈ E i , i ∈ N. Note that this method provides an extremely efficient method that reduces the exponential complexity of the brute force approach to indicator computation to a linear time complexity. Moreover, according to the considerations from Section 3.1, we propose the following Algorithm 4 to detect P-robust statistical arbitrage strategies, where P is an ambiguity set defined as in (3.6); see also Algorithm 2.

Real-world examples
In this section we show that the presented approach can be applied successfully to real-world-data. In particular, the experiments provide empirical evidence for the applicability of the determined set of physical measures in Section 3.1 even in a multi-asset environment. Moreover, we highlight the extraordinary performance of our robust trading approach in crisis-periods. 6 Note that we define 0 0 := 0 to avoid numerical instabilities when minimizing the expression in (3.7).
4.1. Implementation. To apply Algorithm 4, we use the framework provided by PyTorch ( [47]) and train neural networks with a Batch-normalization layer for the input and 3 fully-connected layers with 32d neurons in the first layer, 64d neurons in the second layer, and 128d neurons in the third layer, where d is the number of considered assets (the coefficient d varies across the provided examples). We consider n = 9 future times t 1 , . . . , t 9 and hence the network architecture consists of n − 1 independent fully-connected subnetworks ∆ 1 i , . . . , ∆ d i ∈ N id,B,L for i = 1, . . . , n − 1, whereas ∆ 1 0 , . . . , ∆ d 0 are constants which are trained, too. Each neural network ∆ 1 i , . . . , ∆ d i , i = 1, . . . , n − 1 takes the past realizations of the d assets of the i trading days after t 0 as inputs and outputs the trading positions of all assets at day t i . The activation functions of all hidden layers are ReLU functions. To only consider neural networks from the set N m,B,L for m ∈ N and, in particular, to bound the output of the neural network by the constant B := 10, we use in the notation of (2.2) for ϕ l a tanh-activation function (which is bounded by the absolute value 1) and matrices A i with biases b i which are randomly initialized for i = 1, . . . , l − 1 (using standard initialization in PyTorch), whereas A l := diag(B, . . . , B) and b l := 0 . A predetermined Lipschitz constant L > 0 could be enforced through per-layer Batch-normalization ( [33]), weight restrictions ( [4]), or through regularization ( [48]), however we decided to not use any of these methods specifically for this purpose and to allow, a priori, L to be arbitrarily large. However, note that a posteriori L < ∞, since the parameters of the neural networks in practice remain bounded (see e.g., [7, Fig. 4 where we set δ := ε = d. Further, we adopt a learning rate of 1e −3 for low dimensional cases (1 or 2 assets) and a learning rate of 1e −4 for high dimensional cases (10 assets and more), as empirical tests have shown that choosing different learning rates for low and high dimensional cases, respectively, significantly improves the training speed. In the sequel (Table 1, 2, 3, 4, 5, 6, 7), we report the numerical results by taking the average of 50 independent experiments to balance off the effect of random weight initialization. In each of these 50 experiments we partition the testing period into consecutive sub-periods of length n to which we apply our trained strategy. For the reader's convenience the applied Python-codes are provided and can be found under https://github.com/YINDAIYING/Deep-Robust-Statistical-Arbitrage. Remark 4.1. As neural networks turn out to be extremely sensitive with respect to the scale of the input (compare e.g. [6,54]), we decided in the implementation to normalize the inputs by scaling the stock prices of each asset separately such that the spot values of each asset equals to 100, i.e. S t 0 = (100, ..., 100) ∈ R d and therefore to consider a Wasserstein-ball around P that takes these normalized spot values into account.

4.2.
Comparison with the linear programming approach from [44]. In this example, we compare our approach, relying on Algorithm 4, with the linear programming (LP) approach proposed in [44,Section 5.2]. Note that the LP-approach in [44] is computationally tractable only in an one-dimensional setting. To this end, we borrow the setting from [44, Section 5.2] and also consider the price evolution of the EUROSTOXX 50 in a training period from January 1995 until August 2013, and in a testing period ranging from September 2013 until July 2018, while assuming that t 1 − t 0 = 11, t 2 − t 1 = 10, i.e., we face a trading period of approximately one month with one intermediate trade. We train strategies according to Algorithm 4 while using different bounds K 1 and K 1 and then test the performance of the trained strategies for various values of K 1 and K 1 . The performance measure is defined by the Sharpe ratio of the strategies applied to the testing period in dependence of K 1 − K 1 , averaged over all 50 independent experiments. In Figure 3 Sharpe ratio of the calculated strategy is plotted against the difference between the upper bound K 1 and the lower bound K 1 centered at the price of 100. One can observe that the Sharpe ratio of the proposed approach is slightly higher than the Sharpe ratio of the LP-approach from [44] once the bounds width exceeds a certain value (around 30 in this example), reaches its highest value when the width equals a value of about 90, and declines slightly when increasing the width of the bounds further. As the best trading performance, i.e., the highest Sharpe ratio, can be observed when the asset values are assumed to be restricted by relatively small bounds, this provides strong evidence that the underlying setting, which assumes (large) bounds for stock prices, imposes no constraint for the detection of optimal trading strategies.

Sharpe Ratio
Proposed Approach Linear Programming Figure 3. We compare the Sharpe ratio of a trading strategy that was trained in line with Algorithm 4 with the Sharpe ratio of a strategy that was trained according to an LP-approach described in [44,Section 5.2]. We depict the Sharpe ratio in dependence of the width of the bounds K 1 − K 1 . The underlying security is the EUROSTOXX 50, while the testing period ranges from September 2013 until July 2018.
The bounds mentioned in Remark 3.2 compute in this example as S 1 − ε = 71.65 and as S 1 + ε = 123.86, respectively, i.e., we have (S 1 + ε) − (S 1 − ε) = 52.21, where we set ε = d = 1. Figure 3 supports that the choice of these bounds is reasonable, since increasing the interval width further does not significantly improve the performance of our trading approach. Note that Figure 3 also illustrates that both LP-approach and the neural network approach from Algorithm 4 perform remarkably well in the considered setting, while the neural network approach even marginally outperforms the LP-approach from [44] which we here used as benchmark to compare. The drawback of the LP-approach however is that it is no more applicable in higher dimensions. We provide with the examples from Section 4.4 empirical evidence that our approach (Algorithm 4) can still be applied successfully in higher dimensions in contrast to the LP-approach.

4.3.
Outperformance of the market. We consider d = 2 underlying securities. These are the American stock market index S&P 500 and the European market index EUROSTOXX 50, respectively. To estimate the ambiguity set P according to the methodology proposed in Section 3.1 we consider historic daily data of both underlying indices from 1986/12/31 to 2006/12/01. This results in N = 5000 observation dates. We set the number of future trading days to n = 9 and consider daily trading. We train a trading strategy according to Algorithm 4 and test it on the period from 2006/12/04 to 2013/01/25, in which the considered indices perform remarkably bad 9 , compare Figure 4 which depicts both the evolution in the train period and the test period. The results in Table 1 showcase that our trained strategy clearly outperforms the market and therefore provide empirical evidence that the robust strategies determined by our approach are able to cut losses even in extremely difficult market scenarios.  Figure 4. The results are shown in dependence of zero (0), proportional (Prop.), and per share transaction costs (P.S.), respectively. Further, we compare the results with a buy-and-hold strategy (B&H) with ∆ k i = 10 for all i = 0, . . . , 9 and all k = 1, 2.

4.4.
Trading in a large number of stocks. In this example we consider d = 10, 20, 30, 40, and 50 securities, respectively, which correspond to some of the largest constituents of the S&P 500 10 . The training period ranges from 2000/01/03 to 2015/11/25 and the testing period from 2015/11/26 to 2020/09/02, compare Figure 5, where we illustrate d = 10 securities. In Table 2, Table 3, Table 4, Table 5, and Table 6, we depict the results of the trained strategy evaluated on the testing period.
In particular, our results show that the approach can indeed be applied to high-dimensional data in contrast to conventional approaches such as linear programming. Moreover, our approach clearly beats the market in all considered cases.    Table 2. We consider d = 10 securities. The table shows Table 3. We consider d = 20 securities. The Table provides Table 4. We consider d = 30 securities. The Table provides Table 5. We consider d = 40 securities. The Table provides Table 6. We consider d = 50 securities. The Table provides  mutual dependence. More specifically, we study the stocks of ExxonMobil (Ticker symbol: XOM) and of BP p.l.c (Ticker symbol: BP). The training period ranges from 1987/10/22 to 2005/08/24 and indeed, an augmented Dickey-Fuller test (compare e.g. [29]) indicates with a p-value of 0.0129 that the spread 1.15·XOM-BP is stationary and thus XOM and BP are indeed cointegrated. However, as depicted in Figure 6, in the testing period that ranges from 2005/08/25 to 2013/08/06, the cointegration relationship breaks down, i.e., the spread diverges, and thus conventional pairs trading approaches fail. However, as the results in Table 7 indicate, a trading strategy that was trained according to Algorithm 4 performs even in this environment remarkably well. This provides further evidence for the robustness of our presented approach.   where we test trading in d = 2 securities in a testing period in which the spread, that was tested to be cointegrated in the training period, diverges. The profits in bold are depicted in dependence of zero (0), proportional (Prop.), and per share transaction costs (P.S.), respectively, and are compared with the outcomes of a buy-and-hold strategy (B&H) with ∆ k i = 10 for all i = 0, . . . , 9 and all k = 1, 2.

Conclusion and Future Research
In this paper we have presented a deep-learning based approach to the computation of profitable trading strategies. In the main result in Theorem 2.14 we prove, in particular, the convergence of a penalized functional involving strategies that can be represented by neural networks towards the minimal conditional super-replication price of profitable trading strategies. This allows theoretically to determine profitable trading strategies by optimizing neural networks. To ensure also the practical applicability of our approach, we have introduced an algorithm in Section 3 for the determination of a data-driven ambiguity set P of underlying probability measures as well as an algorithm for the computation of P-robust statistical arbitrage strategies. In Section 4 we then have shown in several empirical examples that our approach indeed leads to profitable trading outcomes, even in scenarios where it is naturally difficult for trading strategies to perform well.
Analogue to the setting from [44], the presented approach can be extended in a natural way by trading in liquid options and by considering more general σ-algebras G, leading to the notion of P-robust G-arbitrage strategies instead of P-robust statistical arbitrage strategies. In this case, the σ-algebra G may require a different approximation as the case G = σ(S tn ), which was considered in Proposition 2.13. Moreover, the determination of the ambiguity set P in Section 3.1, even though entirely data-driven and straightforward, could also be replaced by approaches that include, for example, a more subtle weighting of past returns or even by a Bayesian approach in which one updates sequentially an assumed prior distribution contingent on observed returns. Eventually we remark that all of our results, and in particular Theorem 2.14, not only enable the approximation of P-robust G-arbitrage strategies, but also allow to detect strategies that conditionally super-replicate some payoff Φ and thus allow to involve mispriced derivatives (with payoff Φ) into trading. We leave these extensions and its effects on the outcomes of the resultant trading strategies for future research.

Proofs
In this section we provide the proofs from the mathematical statements in Section 2 and Section 3. Proof of Lemma 2.7. Let G ⊆ σ(S) be some σ-algebra. We define the map The map F is continuous with respect to the uniform topology induced by · ∞,Ω due to the where the last equality is a consequence of the continuity of F .
Proof of Proposition 2.8. Let G ⊆ σ(S) be some σ-algebra. First, we note that the condition Φ ∞,Ω ≤ B ensures the existence of some strategy h c,∆ ∈ H B,L such that s. for all P ∈ P.
Thus, due to Assumption 2.6, we have for all k ∈ N s. for all P ∈ P = Γ B,L (Φ, G).
By the assumption that β ≥ 0 and by the above inequality we obtain for each k ∈ N This means in particular that Γ B,L,∞ (Φ, G) := lim k→∞ Γ B,L,k (Φ, G) exists and Moreover, by Lemma 2.7, for each k ∈ N there exists h c (k) ,∆ (k) ∈ H B,L which minimizes Γ B,L,k (Φ, G), i.e., we have that According to Lemma 2.4, H B,L is compact, thus there exists a uniformly convergent subsequence (h c (k l ) ,∆ (k l ) ) l∈N with limit h c,∆ ∈ H B,L . Hence, by (6.2) we have Since β is continuous and nonnegative the dominated convergence theorem and the boundedness of the expression in (6.3) imply that By the validity of (6.5), we see that Further, since β ≥ 0, we have with (6.2) that for all l ≥ 1 We consider in (6.7) the limit l → ∞ and obtain with (6.4) that Thus, combining (6.1), (6.8), and (6.6) yields the following inequalities which implies that Γ B,L (Φ, G) = Γ B,L,∞ (Φ, G).
Proof of Lemma 2.11. Let B > 0, L > 0, 0 < ε < B, i ∈ {1, . . . , n}, and let f : Ω i → R d be some function such that f j := π j • f is L-Lipschitz with f j Ω i ,∞,1 ≤ B for all j = 1, . . . , d. We define for all j = 1, . . . , n the truncated function f j : Ω i → R by which is L-Lipschitz, since for all x, y ∈ Ω i we have by construction Then, according to a version of the universal approximation theorem for Lipschitz functions in the form of [23, Theorem 1], there exists for all j = 1, . . . , d some neural network g j : R id → R, g j ∈ N id,1 , which is L-Lipschitz continuous, and which fulfils Thus, by (6.9), and since by construction we have for all j = 1, . . . , d that Moreover, we observe for all j = 1, . . . , d that Then by defining g := (g 1 , . . . , g d ) we obtain Finally, note that g ∈ N i,B,L , as the set N i,B,L also contains neural networks which are not fully connected, which can be seen by setting the weights of connections from a neural network in N i,B,L , which do not appear in partially connected networks, to be 0.
Proof of Proposition 2.12. Let G ⊆ σ(S) be some σ-algebra, and let k ∈ N. First note that as Hence it remains to prove that Γ N N B,L,k (Φ) ≤ Γ B,L,k (Φ). To that end, according to Lemma 2.7 there exists some h c,∆ ∈ H B,L such that This implies particularly for all i = 1, . . . , n, j = 1, . . . , d that ∆ j i (m) → ∆ j i uniformly on Ω i for m → ∞. By the dominated convergence theorem, with the continuity of β and the continuity of the transaction costs c j i for all i = 1, . . . , n, j = 1, . . . , d we have that Thus, as h c,∆ (m) ∈ H N N B,L for all m ∈ N, we obtain Proof of Proposition 2.13. We first show that the following equality holds P U -almost surely: 11 11 More precisely, we show that the following holds for P U -almost all realizations of (Ei) i∈N following (2.7) and (2.9).
Hence, it follows by (6.11) that ∞ i=1 F i ⊆ σ(S tn ), and in particular This proves one inclusion of (6.10). Next, for the other inclusion, pick for j = 1, . . . , d some arbitrary numbers a j ∈ [K j , K j ). Then we aim to show that P U -almost surely (6.12) (a 1 , K 1 ] × · · · × (a d , j for j = 1, ..., d, i ∈ N be the random variables which are P U -distributed, i.e, where a It follows now from a (i) j ∼ U [K j , K j ] under P U that the following equality holds for all i ≥ i 0 P U a j < a (i) for each j = 1, . . . , d. Thus, by using the independence of (a (i) j ) j=1,...,d , we have for all i ≥ i 0 This implies that ∞ i=1 P U (E i ) = ∞. By the Borel-Cantelli lemma and by the fact that the events {E i , i ∈ N} are independent, we have P U lim sup i→∞ E i = 1. Thus, P U -almost surely we have (6.13) a j < a (i) j < a j + i − 1 d for all j = 1, . . . , d for infinitely many i ∈ N. Therefore, P U -a.s., there exists a subsequence a (i k ) j j=1,...,d k∈N which fulfils (6.13) for every k ∈ N. Hence, P U -a.s., according to the Bolzano-Weierstrass theorem, there exists a subsequence which converges, and due to (6.13) we have a (i k ) j ↓ a j for k → ∞ for all j = 1, . . . , d. We hence get (a 1 , K 1 ] × · · · × (a d , Next, note that B([K 1 , K 1 ] × · · · × [K d , K d ]) is generated by (a 1 , K 1 ] × · · · × (a d , K d ] K i ≤ a i < K i , i = 1, . . . , d .
Proof of Theorem 2.14. Let B > 0, L > 0. Moreover, let σ(S tn ) = σ ( ∞ i=1 F i ), which holds true P U -a.s. according to Proposition 2.13. By Lemma 2.7, for all k ∈ N and all i ∈ N there exists some strategy h c (i) ,∆ (i) ∈ H B,L such that According to Lemma 2.4, H B,L is compact, thus there exists a subsequence of (h c (i) ,∆ (i) ) i∈N (labelled identically) such that (h c (i) ,∆ (i) ) i∈N converges uniformly for i → ∞ against some h c,∆ ∈ H B,L . Then, it follows with the dominated convergence theorem, the continuity of the transaction costs, the continuity of β, and with Proposition 2.13 that Γ B,L,k (Φ, σ(S tn )) ≤ c + k By the tower property of the conditional expectation and by Jensen's inequality, as β is convex, it holds for every j ≥ i, by using F i ⊆ F j , that δ (x ,x +τ ) ∈ Π( P, P τ ) ⊂ M 1 (R nd × R nd ).
Then it holds by construction that This shows P τ ∈ B ε ( P).