- ago
Hello,

I back-tested Dr. Koch's implementation of Laurens Bensdorp's Automated Stock Trading System 3: Long Mean Reversion Selloff (https://www.wealth-lab.com/Strategy/DesignPublished?strategyID=44).

I use the WealthSignals stock universe (https://www.wealthsignals.com/symbol-list) and I reproduce Dr. Koch's nice-looking equity curve.

Please help me to understand what appears to be significant price improvement (aka negative slippage) I am finding only on the "TakeProfit" limit orders. If this price improvement is removed (ie we assume we get the target prices), the return is cut by more than a factor of two (from 20% ann to 8%), so it is important that I understand how WealthLab computes these execution price estimates.

When I examine the trade history from WealthLab, each limit order lists the target price and the estimated execution price. My trade history runs from 11/1/1999 to 3/24/2023 and contains 7,929 completed trades. If I compute the slippage of each limit order execution price relative to its target price, I receive the following summary result:

7,929 LongLimit executions (trade entry): median slippage -1 BP; ie, exec = tgt, approx.
283 StopLoss executions (trade exit): median slippage 0 BP; ie, exec = tgt, approx.
6,936 TakeProfit executions (trade exit): median slippage: -80 BP; ie, exec 0.8% better than tgt.

The remainder of the exits are "Timeout" for which no target price is reported.

Questions:

1) In general, how does WealthLab estimate an executed price for a limit order?
2) Why am I only seeing negative slippage on the "TakeProfit" limit orders?
3) What type of algorithmic order would I need to specify to a broker so I can achieve this level of negative slippage on these limit orders?

Thanks!
0
851
14 Replies

Reply

Bookmark

Sort
Glitch8
 ( 8.38% )
- ago
#1
A limit order can fill at a higher price if the market gaps up at open above the limit price.
0
- ago
#2
You should see a similar effect with the limit entry: Entry price is lower than the limit order price when the market opens below the limit price.
0
Cone8
 ( 25.05% )
- ago
#3
1) Just like in live trading, limit orders will fill at the limit price or better (which for backtesting occurs only on price gaps).

2) Because negative slippage applies only to Market and Stop orders, just like in live trading. You'll only get negative slippage for backtesting, never positive, which also sometimes occurs in live trading.

3) See #1. You can, however, apply "Limit Order Slippage" as described by the User Guide (so I'm not going to repeat it here). Click on Preferences > Backtest then hit F1 for the help.
0
- ago
#4
Thanks for the responses!

I know that limit orders execute at the target price or better (or not at all!), but, echoing Dr. Koch above, why don't I see similar negative slippage on the entry orders?

As far as I can tell, both entry and take profit orders are using exactly the same OrderType.Limit:

Entry:
CODE:
         Transaction t = PlaceTrade(bars, TransactionType.Buy, OrderType.Limit, limit,             "Long Limit@" + limit.ToString("f2"));


Take Profit:
CODE:
            ClosePosition(p, OrderType.Limit, pt, "Take Profit@" + pt.ToString("f2"));


As far as I can tell, the Long Mean Reversion Selloff algorithm's excellent performance is almost completely due to the negative slippage of the Take Profit limit order. If one has the ability to execute an order and get 0.8% price improvement, does the algorithm that generated the trade even matter at that point? Or does WealthLab internally model the executed price as a function of the target limit price and the daily ohlc prices, and the Long Mean Reversion Selloff algorithm is somehow resonating with this internal model and finding the most advantageous days to place these limit orders?
0
Glitch8
 ( 8.38% )
- ago
#5
>>why don't I see similar negative slippage on the entry orders?<<

I'm seeing it. Here for example,



And to avoid confusion we've been calling this "Positive Slippage", and the normal slippage that goes against you just "Slippage."
0
- ago
#6
Thanks Glitch. Got it - I will call price improvement "Positive Slippage" to avoid confusion.

I see positive slippage on some entry limit executions too, but the median value over thousands of such executions is zero, at least by my calcs. Not so with the take profit limit orders.
0
Glitch8
 ( 8.38% )
- ago
#7
I don't know what you're using to calculate, but in the quick run I did above, 7 of the 9 entries experienced a better fille due to market open "Slippage".
0
- ago
#8
How do I attach a spreadsheet, Glitch?
0
Glitch8
 ( 8.38% )
- ago
#9
Maybe link a Google Drive?
0
- ago
#10
OK Glitch here is the link: https://docs.google.com/spreadsheets/d/1TZrQHPTakulrn6-OEy509uAgfK1uiZTN/edit?usp=sharing&ouid=106679779732070773406&rtpof=true&sd=true

It is an excel spreadsheet; I hope I posted it so you can download!

I reformulated my argument from median slippage to raw dollars, and I think everything is clearer:

On the "Positions" tab in WealthLab, each back-tested trade has a quantity and simulated enter and exit execution prices. Limit orders also have a target price.

So, I can compute the total profit of all the trades using the simulated execution prices, or the target prices.

If I use the simulated execution prices, I get what WealthLab reports: $36M profit.

But if I use target prices, I get a loss of -$160M.

I also computed what would happen for simulated enter and target exit: -$114M

... target enter and simulated exit: -$10M.

So the algorithm is critically dependent on those simulated limit order execution prices.

How exactly does WealthLab produce those simulated limit order execution prices? If anyone wants to try and live-trade this algorithm, they need to know because their success depends more on the execution logic than the algorithm.
0
Cone8
 ( 25.05% )
- ago
#11
Sorry to jump in, but which one of the 8000 trades has a problem? I looked at the first three and all of them indicate a better price than the limit order.

QUOTE:
How exactly does WealthLab produce those simulated limit order execution prices?
Example for long limit entry:
1. Check the opening price - if the Open is below the limit price, the order is filled at the Opening price.
2. Otherwise, the order is filled at the limit price if the Low of the bar equals or exceeds the limit.
3. If you apply Limit Order Slippage in the Backtest Preferences, the Low has to exceed the limit price by the slippage amount. See the User Guide for more details about an exception.

Note that backtests execute at full price precision. When a stock splits prices can have much more precision than just 2 decimals. Using more precision keeps a backtest the same if it executes a limit order at 100.00 or at 33.333333 following a 3:1 split.

That said, when orders are placed with brokers, they often have to conform with the price decimals allowed for the instrument, especially for futures contracts. So, if the order needs to be precise only to 2 decimals (0.01), then a long limit order will be adjusted as required. For example, a long limit order for 23.1264 would be adjusted to 23.12.
0
Glitch8
 ( 8.38% )
- ago
#12
>>How exactly does WealthLab produce those simulated limit order execution prices?<<

Can you isolate a single entry for us that you’d like explained? I already explained how WL arrives at the simulated execution price and I’m having trouble understanding what you perceive as an issue here 🤷🏼‍♂️
1
- ago
#13
The algorithm generates a set of desired trades and target prices.

If you assume you get those target prices, the gain is -$160M.

If you assume you get the simulated prices, the gain is +$36M.

There is a huge difference between losing $160M and making $36M so naturally I want to understand why.

Cone, thanks for explaining how WL produces those limit order prices, particularly the potential fill at the open price. Glitch, if you explained this, I missed it and I am sorry.

I will digest what both of you have said and I will get back to you regarding an isolated entry I'd like explained.
0
- ago
#14
QUOTE:
If you assume you get those target prices, the gain is -$160M.


The profit taking limit price is always calculated to be 4% above the entry price.
If this limit order is filled it should result in a 4% profit of the trade or better.

Of course there is always the possibility that the limit price is never touched. In this case the trade stops after some timeout, and this is a completely different story of course.

0

Reply

Bookmark

Sort