Position management and using WL for real trades
Author: StratCat
Creation Date: 5/23/2010 5:47 PM
profile picture

StratCat

#1
This is an overarching post (because it's my first and I'm feeling lazy) about the reliability of using WL as a live trading platform as well as a couple questions that hopefully someone can address. This post comes from a software architect/developer at Microsoft so please take my comments about bugs/implementation/design/etc... as non-personal and simply one software development expert talking to another.

From what I'm told I'm one of a handful of customers that actually use WL to trade on a live account. I find that hard to believe due to the fact that Fidelity has allocated non-trivial resouces to it. However, the stability and reliability disatisfaction I have running WL to trade on a live account has me leaning the other way.

Bugs
* Recovery from loss of connectivity: WL does not reestablish a connection to Fidelity/Data-Providers if a connection is interrupted. This really is expected and should be trivial to implement. Credentials do not need to be provided again if the contract between WL and the customer is that access to the computer is the customer's responsibility; both physically and remote connections (e.g. RD/TS/Remoting).

* Active connectivity health checks: WL will sometimes stay connected to Fidelity/Data-Provider when the connection is still active but non-responsive. From the behavior it appears as though WL relys on TCP bubbling up reconnect/close events however service software should not rely on only this. Machines bug checking, being turned off (power failure), crash, etc... will often not report connection loss to endpoints. WL should periodically check the connection for validity and recover (close/connect) gracefully if necessary.

* Stock Volume information sometimes not present when streaming from Fidelity: Often I'm seeing stock pricing data streamed and displayed in a strategy window (that is actively trading on a real account) but volume information suddently stops getting displayed. When this happens Enter/Exit Alerts are not placed with Fidelity but do appear in the Strategy window. It appears as though we're in the realm of undefined behavior as soon as this starts to happen. I haven't debugged this any further than validating that the strategy code appears solid. I haven't run NetMon or debugged WL to determine whether the problem is with Fidelity or WL.

* Better documentation (think MSDN style) about objects and methods/functions in the SDK: There does not appear to be documentation for the Position object, for example, that describes the State of a Position object that is partially filled. I found that all the documentation I read does not answer the question about whether a Position object is still Active on a partial (limit) fill, whether resubmitting the limit exit order on a new bar will create a new order (e.g. another 7.95 commission), or whether the original limit order will stay around to fill the remaining shares.

* Position object appears to be set to a non-Active state on partial fills: Actual real-time trading on a real account suggests that the Position object is set to a non-Active state on partial fills. The position with Fidelity will actually be closed and orphaned from the Position object. This needs to be fixed if that is indeed the case.

* Enter/Exit orders do not reliably issue Alerts: Many times during a real account intraday trading session I've seen the Strategy window get updated with Enter/Exit markers but the Alert is never raised (e.g. never staged and never placed - nothing outside of the UX Strategy window denotes anything happened). This happens from the Strategy window as well as running strategies from the Monitor window so it appears as though there's a bug in the WL OM somewhere.

* Enabling auto-place/trading through Strategy and Strategy Monitor Windows conflict: Real intraday trading when all windows are set to auto-trade results in undefined behavior. Orders either don't get alerts or alerts are sent and error out from Fidelity. The fix isn't to synchronize the two 'Windows' but to implement a better auto-trade use-flow for the user. Auto-Trade should be set from one location. If you let the Window (Strategy window, Strategy Monitor, Orders, Alerts, etc...) be the 'view' into trading activity and let the Application (e.g. your main MDI frame) drive Auto-Trade/No-Auto-Trade then you'll eliminate these issues and provide an intuitive user experience.

Well that's pretty much it for now. Since Fidelity does not support other platforms (Meta Trader, Ninja Trader, etc...) or customer's developing custom utilities based on the FIX Protocol this is THE trading platform. Good work devs on the product so far.. I think the biggest area of improvement is in the real trading scenarios instead of back-testing and POC support. The various other platforms also have issues but that's the nature of software developed from independant developer groups; reliability is not always a key goal. WL has the chance to be the most stable trading platform around - which will give Fidelity a new value prop. Currently we're not there yet with WL.

Cheers,
Stratcat
profile picture

Eugene

#2
QUOTE:
Better documentation (think MSDN style) about objects and methods/functions in the SDK: There does not appear to be documentation for the Position object, for example, that describes the State of a Position object that is partially filled.

There's no such property, and for simplification, to quote the Wealth-Lab User Guide > Orders > Portfolio Synch:
QUOTE:
It's not possible for a Strategy to directly access a live Position's true entry price or number of shares.


profile picture

Cone

#3
That's probably a fair assessment for live intraday trading, but not for end-of-trading, so the title of the topic can be misleading for many Fidelity customers.

* Stock Volume information sometimes not present when streaming from Fidelity
This issue is unknown to me, so I encourage you to create a support ticket with the details or call it in to Fidelity support.

* Better documentation
The QuickRef has most of the same elements as msdn docs - Description, Remarks, Examples, Context sensitive help link, etc. It's very easy to use. What more do you really need?

Re: Position object:
There is no such thing as a "partially filled" Position in a strategy. A Position is a Position whether or not it has all the shares that you initially requested. In a streaming chart, when the bar ends, if any part of the order remains open it's canceled and you're left with a single Position whether it's 1 share, 123 shares, or 10,000 shares (User Guide: Orders > Modify, Cancel, Partial Fills). Also, remember that Strategies run in "theoretical mode".

And expanding on Eugene's post:
If in theory the order was filled, it will be filled completely as far as your Strategy is concerned. Only when an exit Alert is processed with the shares be reduced (or increased) to match your account's Position. (User Guide: Orders > Portfolio Synch)


As a blanket statement, the following issues are under investigation.

* Recovery from loss of connectivity
This issue hasn't been mentioned to us in this context, but for sure there's an intermittent problem with Fidelity streaming that disconnects, or perhaps only some charts stop updating, and there's no way to solve it other than restarting. Logging out and back in might be enough. A new Fidelity Streaming provider is under development for the next release, so perhaps this alone could solve the problem.

* Enter/Exit orders do not reliably issue Alerts:
This is an extremely rare event, and frankly, I might have seen it once in 3 years. Nonetheless, any help in identifying the conditions leading to such an event is appreciated.

That said, there's a more prevalent problem with Staging/Placing Alerts that do occur, primarily for exit signals. Duplicating this event too, however, is proving to be a problem for the developers.

* Enabling auto-place/trading through Strategy and Strategy Monitor Windows conflict
There is no conflict with the design, and I honestly don't follow your argument. The design requires a positive user action to enable Staging/Placing orders for every window that is launched. And, when you enable Auto-Trading, the buttons in the Strategy Window/Monitor tools change from Auto-Stage to Auto-Place to indicate that Alerts will be automatically placed instead of simply queued in the Orders tool.
profile picture

StratCat

#4
Thank you very much for your replies. Comments inline >>


* Stock Volume information sometimes not present when streaming from Fidelity
This issue is unknown to me, so I encourage you to create a support ticket with the details or call it in to Fidelity support.
[StratCat] I could provide a repro unfortunately I've been told that Fidelity reps cannot receive email let alone attachments. That's a completely understandable security measure and I applaud Fidelity for taking it. It does provide a problem with transferring a file to repro the bug. I don't want my 'strategy' public so posting to a public forum isn't an option for me. I'll be happy to submit it to the developers as long as it stays confidential; just tell me how you want me to give it to you.

* Better documentation
The QuickRef has most of the same elements as msdn docs - Description, Remarks, Examples, Context sensitive help link, etc. It's very easy to use. What more do you really need?
[StratCat] The QuickRef is nice however it doesn't tell the user all they need to know using the object or method. For example, you addressed it earlier:

Shares Property
double Shares

Returns the number of shares (or contracts) that the Position contains.

Remarks
In portfolio simulation mode, all trades are pre-executed using 1 share per Position, and then position sizing is applied after the fact. So the Shares property will always return 1 while the Strategy is executing.
The Shares property is always available to Performance Visualizers, which execute after the position sizing has been applied.

[ TODO: Add documentation to address partial fills, "See Also..." link can point to how to find out the State of the position (e.g. Error, Pending, Submitted, etc...) or just add the text to the body of the topic, etc... ]

Compare to CreateProcess() in MSDN. You'll see what to watch out for (e.g. when it's advised to supply application name and arguments - and when to combine them into the argument param, you get the exe search rules quoted for you, gives you enough insight into how the command line argument is processed that telling you it cannot be constant makes sense, etc... It's the intrinsic information surrounding the call that gives the MSDN much of its value as a reference. I'd find the QuickRef much more valuable if this were added; cut down on support calls and message board posts too I'd imagine.

Re: Position object:
There is no such thing as a "partially filled" Position in a strategy.
[StratCat] Okay. The Position object either changes to a non-Active state or calls to exit the position are ignored. This is what I'm seeing. This is coming from me seeing the strategy not reissuing an exit order for the unfilled shares. From the documentation I think I recall it mentioning this was By Design. If so then it destroys WL's value as an automated trading platform; e.g. If I cannot programmatically detect and exit the positions. If I read that wrong (I could have) then a Position is in a non-active state or exit calls fail to operate on it. A failed attempt to exit a position also ends with the position not 'exitable' from what I'm seeing; haven't debugged that either to see where the problem is - e.g. call to exit or the object in a non-active state.

* Recovery from loss of connectivity
This issue hasn't been mentioned to us in this context,[...]
[StratCat] Thanks for the info. This means that I need to write an app, assembly, or interop into a dll that monitors the connection state of WL and reconnects when necessary. Sure it's trivial to do but I'm really hoping that I won't have to. Do you guys understand the problem or just the symptoms; it sounds like root cause analysis was never completed from the post. (Not trying to call anyone out - just trying to do my part in helping make the platform stable for automation... and to get an idea whether to expect improvements here before you RTW v.next. <g>). Without understanding the problem you can't know whether any action taken in the future will resolve it.

* Enter/Exit orders do not reliably issue Alerts:
This is an extremely rare event, and frankly, [...]
[StratCat] I worked around the problem. If I get a method for delivering repros to you then I'll try to get you one. What is this more prevalent problem you're seeing with Staging/Placing Alerts from Exit signals? You knew I was going to ask. =0) Is this something I (and other developers) need to work around? Is there a work around? etc...

* Enabling auto-place/trading through Strategy and Strategy Monitor Windows conflict
There is no conflict with the design, and I honestly don't follow your argument. [...]
[StratCat] If I want to trade against my live account I can do so a couple ways. From the Strategy window I can do this by opening one from file, make sure to associate an Account with it (which is out of the way and non-intuitive really), set my scale/data range/Position Size/etc.., click the streaming button, only now is the Auto-Stage option available so I need to go find and click that, open the Orders window, click auto-place, huh.. did I miss anything? I'm not sure so I need to go check... If I want to run the Strategy Monitor then I don't think I can ALSO enable auto-stage/place... whatever it is... from there because now I'm worried that I have two windows issuing Alerts? Let me check the documentation to see if that would happen... it's not in there (that I found). This isn't a rant, I don't want it to come across like that, it's a 'day in the life of' the User. It's the user following the design of the application that could be much less error prone and easier to set up.

One suggestion - <Menu Item> | Auto-Trade... You get a dialog box that sets what you need and populates your live session config data. Now your windows all refer to that. Remove the options from each of the windows. They don't need to be thought of as "Active Windows" that contain context sensitive actions; *especially* when setting an option controls the application and not just the data layout in the window. See the diff?

Thanks,
StratCat
profile picture

Cone

#5
QUOTE:
just tell me how you want me to give it to you.
Attach it to a Support Ticket (upper right menu). But if the problem occurs only with your Strategy, doesn't that sort of point to the source of the problem?

QUOTE:
it doesn't tell the user all they need to know using the object or method
And you think msdn is complete in this regard? Oh man, don't get me going. CreateProcess() might be well-documented, nice pick. But sure, we're constantly revising the documentation, and if there's something that you feel is missing create a Support Ticket, we'll research it, and get it in for the next release.

QUOTE:
This is coming from me seeing the strategy not reissuing an exit order for the unfilled shares.
That will never happen. First, realize that the Strategy runs theoretically and has no idea what's in your account or what has been filled. Please see the Orders chapter in the User Guide. It discusses this at length, with examples. To guarantee not to be left with partial fills, your only recourse is to use Market orders.

QUOTE:
Without understanding the problem
Honestly, I don't think Fidelity understands the problem. They have a difficult time duplicating production connectivity issues behind their firewall, where the connectivity is apparently always good. I'll pass along any info you have for them, though.

QUOTE:
Staging/Placing Alerts from Exit signals?
It's another intermittent problem that some users see frequently, and others don't. It's not fully understood why or how it could happen. However, those who see it say that leaving "residual shares" of the stock you're trading in your account will prevent Auto-Stage/Place failure. This seems to point to Portfolio Synch logic being the problem, and that's one reason I'd like to see it removed.

QUOTE:
I can do this by opening one from file, make sure to associate an Account with it (which is out of the way and non-intuitive really),
If you have only one account, you don't need to do anything other than to make sure that the Default Account preference points to your live account, rather than a Paper Account.

QUOTE:
which is out of the way and non-intuitive really
Agreed, but it's effective and it's only non-intuitive the first time. With unlimited resources and funding, that action could have its own dialog and shortcut.

QUOTE:
did I miss anything?
Sure, that's the process for the first time. Now that you've got everything configured the way you want it, and you've saved it, and, you've saved your Workspace. Here's the process:

1. Open Workspace
(Log in and let streaming charts initialize)
2. Click Auto-Trading in Orders.

You've got to set things up once. And, it's by [good] design we make you enable Auto-Trading for every Wealth-Lab session.

QUOTE:
Let me check the documentation to see if that would happen... it's not in there (that I found).
If by your own action run the same strategy more than once, is there a reason that it should be prevented? There is, though, logic to prevent you from doing something unintentional in your script programming -

User Guide: Orders > Features and Limitations of Automated Trading > Duplicate Order Detection

Only one stop and/or limit order is possible (one of each type) for exit orders on a single position. For example, 2 stop loss orders with different prices for the same position is not valid, and only the stop order closest to the current price will be accepted.
- Incidentally, there appears to be a bug here because the logic always passes the last order through, not the closest in price.

QUOTE:
<Menu Item> | Auto-Trade... Now your windows all refer to that.
What should we do about those customers with 5 accounts, trading different Strategies and settings for each one? (Don't give it too much thought, this design is not going to change now - that's what you get for being late to the design meetings!)
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).