===
Optimizing the parameters of a trading strategy via backtesting has i major problem: at that spot are typically non plenty historical trades to accomplish statistical significance. Whatever optimal parameters i flora are probable to endure from information snooping bias, together with at that spot may endure aught optimal virtually them inwards the out-of-sample period. That's why parameter optimization of trading strategies often adds no value. On the other hand, optimizing the parameters of a fourth dimension serial model (such equally a maximum likelihood lucifer to an autoregressive or GARCH model) is to a greater extent than robust, since the input information are prices, non trades, together with nosotros direct maintain plenty of prices. Fortunately, it turns out that at that spot are clever ways to accept wages of the ease of optimizing fourth dimension serial models inwards corporation to optimize parameters of a trading strategy.
One elegant way to optimize a trading strategy is to utilize the methods of stochastic optimal command theory - elegant, that is, if you lot are mathematically sophisticated together with able to analytically solve the Hamilton-Jacobi-Bellman (HJB) equation (see Cartea et al.) Even then, this volition solely piece of job when the underlying fourth dimension serial is a well-known one, such equally the continuous Ornstein-Uhlenbeck (OU) physical care for that underlies all hateful reverting cost series. This OU physical care for is neatly represented past times a stochastic differential equation. Furthermore, the HJB equations tin typically endure solved precisely solely if the objective role is of a unproblematic form, such equally a linear function. If your cost serial happens to endure neatly represented past times an OU process, together with your objective is net maximization which happens to endure a linear role of the cost series, so stochastic optimal command theory volition give you lot the analytically optimal trading strategy: with exact entry together with larn out thresholds given equally functions of the parameters of the OU process. There is no to a greater extent than ask to honor such optimal thresholds past times trial together with mistake during a ho-hum backtest process, a physical care for that invites overfitting to lean publish of trades. As nosotros indicated above, the parameters of the OU physical care for tin endure fitted quite robustly to prices, together with inwards fact at that spot is an analytical maximum likelihood solution to this lucifer given in Leung et. al.
But what if you lot desire something to a greater extent than sophisticated than the OU physical care for to model your cost serial or require a to a greater extent than sophisticated objective function? What if, for example, you lot desire to include a GARCH model to bargain with time-varying volatility together with optimize the Sharpe ratio instead? In many such cases, at that spot is no representation equally a continuous stochastic differential equation, together with hence at that spot is no HJB equation to solve. Fortunately, at that spot is all the same a way to optimize without overfitting.
In many optimization problems, when an analytical optimal solution does non exist, i often turns to simulations. Examples of such methods include imitation annealing together with Markov Chain Monte Carlo (MCMC). Here nosotros shall practice the same: if nosotros couldn't honor an analytical solution to our optimal trading strategy, but could lucifer our underlying cost serial quite good to a measure discrete fourth dimension serial model such equally ARMA, so nosotros tin just imitate many instances of the underlying cost series. We shall backtest our trading strategy on each instance of the imitation cost series, and honor the best trading parameters that most often generate the highest Sharpe ratio. This physical care for is much to a greater extent than robust than applying a backtest to the existent fourth dimension series, because at that spot is solely i existent cost series, but nosotros can
nosotros tin imitate equally many cost serial (all next the same ARMA process) equally nosotros want. That way nosotros tin imitate equally many trades equally nosotros desire together with obtain optimal trading parameters with equally high a precision equally nosotros like. This is almost equally expert equally an analytical solution. (See current nautical chart below that illustrates this physical care for - click to enlarge.)
![]() |
Optimizing a trading strategy using imitation fourth dimension series |
Here is a somewhat picayune illustration of this procedure. We desire to honor an optimal strategy that trades AUDCAD on an hourly basis. First, nosotros lucifer a AR(1)+GARCH(1,1) model to the information using log midprices. The maximum likelihood lucifer is done using a one-year moving window of historical prices, together with the model is refitted every month. We utilization MATLAB's Econometrics Toolbox for this fit. Once the sequence of monthly models are found, nosotros tin utilization them to predict both the log midprice at the goal of the hourly bars, besides equally the expected variance of log returns. So a unproblematic trading strategy tin endure tested: if the expected log provide inwards the adjacent bar is higher than K times the expected volatility (square root of variance) of log returns, purchase AUDCAD together with agree for i bar, together with vice versa for shorts. But what is the optimal K?
Following the physical care for outlined above, each fourth dimension after nosotros fitted a novel AR(1)+GARCH(1, 1) model, nosotros utilization this to simulate the log prices for the adjacent month's worth of hourly bars. In fact, nosotros imitate this 1,000 times, generating 1,000 fourth dimension series, each with the same publish of hourly bars inwards a month. Then nosotros just iterate through all reasonable value of K together with call back which K generates the highest Sharpe ratio for each imitation fourth dimension series. We pick the K that most often results inwards the best Sharpe ratio alongside the 1,000 imitation fourth dimension serial (i.e. nosotros pick the mode of the distribution of optimal K's across the imitation series). This is the sequence of K's (one for each month) that nosotros utilization for our concluding backtest. Below is a sample distribution of optimal K's for a detail month, together with the corresponding distribution of Sharpe ratios:
![]() |
Histogram of optimal K together with corresponding Sharpe ratio for 1,000 imitation cost series |
Interestingly, the way of the optimal K is 0 for whatsoever month. That for sure makes for a unproblematic trading strategy: just purchase whenever the expected log provide is positive, together with vice versa for shorts. The CAGR is virtually 4.5% assuming null transaction costs together with midprice executions. Here is the cumulative returns curve:
![]() |
P.S. nosotros invented this physical care for for our ain utilization a few months ago, borrowing similar ideas from Dr. Ng’s computational question inwards condensed affair physics systems (see Ng et al here or here). But subsequently on, nosotros flora that a similar physical care for has already been described inwards a newspaper past times Carr et al.
===
About the authors: Ernest Chan is the managing fellow member of QTS Capital Management, LLC. Ray Ng is a quantitative strategist at QTS. He received his Ph.D. inwards theoretical condensed affair physics from McMaster University.
===
Upcoming Workshops past times Dr. Ernie Chan
November eighteen together with Dec 2: Cryptocurrency Trading with Python
I volition endure moderating this online workshop for Nick Kirk, a noted cryptocurrency trader together with fund manager, who taught this widely acclaimed course of written report hither together with at CQF inwards London.
February 24 together with March 3: Algorithmic Options Strategies
This online course of written report focuses on backtesting intraday and portfolio option strategies. No pesky options pricing theories volition endure discussed, equally the emphasis is on arbitrage trading.