- ago
I have a live strategy running, which unexpectedly exited an orphan position. I'm curious how this could have happened, because my strategy uses only Market entries/exits (no limit/stop orders), and no other problems had happened leading up to this point. In order for an "exit orphan" command to be triggered, doesn't that mean the backtest had already exited the position, but the live strategy had failed to? If that were the case, wouldn't I see some sort of error message about a failed market sell?

0
887
27 Replies

Reply

Bookmark

Sort
Cone8
 ( 5.68% )
- ago
#1
Everything you said is right. And, the strategy was happy holding the position for more than an hour.

The only thing I can think of is NSF. Open your strategy and check the Strategy Settings. Is "Retain NSF Positions" checked?
1
MIH8
- ago
#2
The most common and systematic reason for WL not being in sync with the broker in this context is the fact that the backtester evaluates purely hypotetic trades.

This means that if a condition is met in the strategy for an exit, but the order is not filled in reality, the trade is terminated for the backtester and no further signals are generated.

Since the backtester does not query the broker's portfolio (the real status), the backtester cannot know this. What is not known cannot be reproduced as a message. Not receiving a message is the smallest problem...

The WL team should realise that trading is not backtesting and that one does not trade with hypothetical states but with the real status. The API interfaces are usually able to retrieve this information.

There is a feature request for which you can vote. I do not want to comment further on the fact that this functionality requires a vote.

This is at least one important piece of the puzzle the WL team is hunting for more than six months i guess. Maybe it helps ...
3
- ago
#3
@Cone: Retain NSF positions is checked. If you suggest disabling this, I will. The backtest only produces an NSF ratio of 0.01 (5 NSF positions over the last 8 months), and unchecking it doesn't seem to have a noticeable impact on the backtest results.
0
Cone8
 ( 5.68% )
- ago
#4
It should be checked, and frankly I thought the S. Monitor always "Retained" anyway (not really sure). I'm just looking for any possible reason that the Strategy at one time thought it had a position, but then decided that it no longer had a position without having signaled to exit it.

Please run that strategy in a Strategy window with the same settings.
1. First, does it enter the position on the same bar (the open of the 17:45 bar)?
2. If it exited the position, when was it?
1
- ago
#5
Things don't seem to match up very well in general, either in terms of entry or exit times, or even the symbols traded:

0
Cone8
 ( 5.68% )
- ago
#6
Actually, the trades line up perfectly with the declared trades for ALEPH. The strategy Positions table shows the timestamp of the bar on which the trade occurred, but the S. Monitor shows the previous bar for the Signal. You can see that the entry at 17:45 occurred after the 17:40 signal bar.

Likewise the backtest sold the ALEPH position on the 20:50 bar - the bar after the exit signal bar at 20:45, but this errored out since the position had already been sold by the orphan exit. That last trade shows that the strategy was actually still processing the exit logic still and something else influenced the orphan logic. We need to study this. (Any ideas @Glitch?)

Aside:
The entry for the penultimate trade, RBN, was the same too, but the exit was different. Differences like that can occur due to the differences in the bar data created by Streaming vs. the history generated by the historical provider. However, there really should be no difference if the streaming provider is giving us all the ticks.

Mike, please send the strategy to me so that we can be sure that there wasn't some sort of a "variable logic" error.
1
MIH8
- ago
#7
QUOTE:

...
Likewise the backtest sold the ALEPH position on the 20:50 bar - the bar after the exit signal bar at 20:45, but this errored out since the position had already been sold by the orphan exit. That last trade shows that the strategy was actually still processing the exit logic still and something else influenced the orphan logic.
...


Good point!

However, this signal was not present on the initial screenshot. I'm not sure, but the signal also looks unusual because it doesn't indicate a price or quantity. But since the exit logic is obviously still active, these values don't make sense, do they? Or is that also a consequential error of the orphan exit?
0
- ago
#8
QUOTE:
Mike, please send the strategy to me so that we can be sure that there wasn't some sort of a "variable logic" error.


@Cone: I did so, let me know if the email didn't find its way to you.
0
Cone8
 ( 5.68% )
- ago
#9
Yes, received it, but couldn't find anything that helps identify what could have made this happen. Really it's the only case of its kind I've ever seen because something happened to "trick" the orphan logic into thinking the strategy didn't have a position, when obviously it did - because later the exit logic triggered the programmed sell.

We have an open bug on this issue, but we're going to need some sort of a breakthrough or new info to solve it.

I noticed an InSample/Out of Sample message in the status bar. Was some WFO process running at the time?
1
- ago
#10
No, I don't believe there was any sort of WFO process running (at least not knowingly/intentionally). The strategy was running on a remote desktop whose sole purpose is to execute the strategy, so I wouldn't expect any sort of accidental interference.

I have another remote desktop, running a modified version of the strategy on a different Coinbase API key, and it also executed a "Selling Orphan Position" for ALEPH-USD at the same timestamp. So whatever the cause is, it looks like it should be reproducible. But I've been running these strategies since the 22nd and have not encountered any more problems since then.
0
Cone8
 ( 5.68% )
- ago
#11
QUOTE:
and it also executed a "Selling Orphan Position" for ALEPH-USD at the same timestamp
You're saying that it occurred simultaneously on a different machine?
0
- ago
#12
That is correct, the timestamp on one machine is "20:20:01" and the timestamp on the other machine is "20:20:02".

Also, I recently had the problem occur again, this time on a 1-minute strategy running on my desktop:

0
Cone8
 ( 5.68% )
- ago
#13
Okay, thanks.
0
- ago
#14
I'm wondering what the reason is



0
Cone8
 ( 5.68% )
- ago
#15
kls - in your case, this is exactly what the orphan logic is for. YOUR live LIMIT order was not filled, but that price was hit, so the strategy was "filled". That's the definition of an orphan position, so it was exited since you selected that trading preference.
0
- ago
#16
How do you know that the price (120.03) was hit? and it was hit why was not filled by IB?
0
Cone8
 ( 5.68% )
- ago
#17
QUOTE:
and it was hit why was not filled by IB?
Okay, this question is not a Wealth-Lab question. You need to know before you trade that LIMIT orders may not be filled even if they hit the LIMIT price. Do you understand that?
0
MIH8
- ago
#18


What a nonsense !!!

If the limit was hit but not filled at the broker the only thing that matters is the status at the broker and not the hypothetical status of the backtesting software. This concerns 100% the WL software, namely the trading module.

Now, if you provide a trading component then feed it with a real broker status it can trade with, or simply let it be what it is, a backtesting software. (where it is really well equipped with a wide range of functions)

Nobody cares about the hypthetic status in a trading session. It is ridiculous to apply orphan logic when the cause is a hypothetical selling of the position.

Do you (WL Team)understand that ?!
0
Cone8
 ( 5.68% )
- ago
#19
MIH,
I don't need your input here.
1
MIH8
- ago
#20
Of course not.

You should not take it personally. There may be good reasons why the software works the way it does. But that doesn't change the fact that this point made has a negative impact on trading with the software. If you (WL team) work on it and develop an appropriate solution in this context, one cannot ask for more.
0
Glitch8
 ( 10.97% )
- ago
#21
It's not as simple as you make it sound. What if the strategy maintains multiple positions? What if you want to keep a "manually entered" position in the account separated from what a Strategy is trading? There are numerous considerations, and this is why there are BENFITS to the way WL8 is doing things.

Of course, we're always open to improve WL8 as evidenced by the tireless work most of the team is doing. It's certainly not perfect. But I think that with every release WL8 gets a little closer to perfection.
2
MIH8
- ago
#22
Without question, the components of the software are continuously improving thanks to all WL team members. Many thanks to each and every one of you!

And I am aware that it is unpleasant to get criticism when 99% works properly.

But the functions in the trading component have to work robustly within the limits of what is controllable and you should definitely accept that as an argument. Working with a hypothetical portfolio status while trading is pretty far from perfect.

When the backtesting scope is left, real money is at stake and a single mistake can easily cost hundreds of dollars. I'm sure you care about your clients' money.

Now, I didn't say it was easy, but I am saying that any effort to improve the software in a trading context is necessary because every user of the software ultimately wants to trade and make money.

0
Glitch8
 ( 10.97% )
- ago
#23
Do we already have a Feature Request for this, I’m not atk right now but can check later. I could envision a new mode where the real time strategy trades on the current (single) broker position and not hypothetical.
0
MIH8
- ago
#24
I guess this one could cover it https://www.wealth-lab.com/Discussion/Access-Accounts-data-from-broker-programmatically-7914 , already mentioned in #2.

I am also aware that this may well lead to redundancy and unwanted complexity in the overall design. Regardless of many advantages in the existing software design, the trading component should focus on robustness and reliability imho.

Thanks for the talk.

0
- ago
#25
Regarding the orphan exit behavior I'm seeing, are there any steps I can take that might help as a workaround or way to sidestep this issue? For example:
* If the problem is perhaps connected to one of the indicators I'm using, I can experiment with different indicators
* If using MathIndOpInd in my Transaction Weight block is atypical, I can try something else
* I assume that disabling the Orphan Exit preference is riskier than leaving it enabled, but perhaps not?
* Could I perhaps see better results with Polling or a different Data Scale?
* Should I try "Basis Price: Market Open Next Bar"?

Or, if we want to attack this from a different angle, these are some guesses as to why the backtest and live strategy might be diverging:
* When saving my strategy and backtesting, I often set "Max Entry Signals" to 1. But it's very easy to forget to redo this inside the live strategy settings when dragging it to the Strategy Monitor. I'm not sure what consequence this inconsistency could potentially have (maybe none)
* I use all four of the "Max Open..." fields in the Position Sizing section, though I notice the tooltip specifies that these are "Used for backtest only". Couldn't this introduce a desync between backtest and live trading? Though this seems unlikely in my case, since I'm trying to enforce only 1 long position open at any given time, and I've never seen anything besides this.
* Glitch and I had previously discussed some oddities related to 0-volume bars when streaming, though this was more relevant in an older version of the Binance extension. But perhaps a similar issue could be at cause here? It would make sense, because that was something that caused different behavior between streaming during live trading, as compared to backtesting behavior
0
Cone8
 ( 5.68% )
- ago
#26
None of the above.

Since now that you're not using Limit orders, you can just turn off Orphan Exit altogether. It's troubling why it occurred - and we should get to the bottom of it - but Market systems don't require the orphan exits because you can be nearly 100% sure that a market order will fill completely.
1
- ago
#27
Perfect, thank you!
0

Reply

Bookmark

Sort