Profile Picture

Orders Not Tracked - TWS

Posted By alpha23 5 Years Ago
Message
Posted Thursday November 01 2012
Below is the TWSLog for and order placed yesterday. I'm using build 44. Why is this order ID not being tracked after initially being tracked?

Thanks, Duane

26:49.7   SNI   47224   49   SubmitOrder   47224: Limit Buy SNI @ 60.4 0/505 - Submitted
26:50.2   SNI   47224   49   OrderStatusSubmitted   Order status updated
30:52.6   SNI   47224   49   ExecDetails   20121031 10:30:53 Bought Size: 100 Price: 60.4
30:52.6   SNI   47224   49   ExecDetails   Partial fill: total 100/505
30:52.6   SNI   47224   49   OrderStatusSubmitted   Order status updated
30:52.8   SNI   47224   49   OrderStatusSubmitted   Order status updated
30:53.3   SNI   47224   49   ExecDetails   20121031 10:30:54 Bought Size: 100 Price: 60.4
30:53.3   SNI   47224   49   ExecDetails   Partial fill: total 200/505
30:53.3   SNI   47224   49   OrderStatusSubmitted   Order status updated
30:53.3   SNI   47224   49   OrderStatusSubmitted   Order status updated
30:53.4   SNI   47224   49   ExecDetails   20121031 10:30:54 Bought Size: 100 Price: 60.4
30:53.4   SNI   47224   49   ExecDetails   ### Execution Ignored - this fill appears to have been reported already
30:53.4   SNI   47224   49   OrderStatusSubmitted   Order status updated
30:53.4   SNI   47224   49   OrderStatusSubmitted   Order status updated
30:54.0   SNI   47224   49   ExecDetails   20121031 10:30:55 Bought Size: 100 Price: 60.4
30:54.0   SNI   47224   49   ExecDetails   Partial fill: total 300/505
30:54.0   SNI   47224   49   OrderStatusSubmitted   Order status updated
30:54.0   SNI   47224   49   OrderStatusSubmitted   Order status updated
31:02.6   SNI   47224   49   ExecDetails   20121031 10:31:03 Bought Size: -160 Price: 60.4
31:02.6   SNI   47224   49   ExecDetails   ### Execution Ignored - Negative Fill
31:02.6   SNI   47224   49   OrderStatusSubmitted   Order status updated
31:02.8   SNI   47224   49   ExecDetails   20121031 10:31:03 Bought Size: 160 Price: 60.4
31:02.8   SNI   47224   49   ExecDetails   Partial fill: total 460/505
31:02.8   SNI   47224   49   ExecDetails   20121031 10:31:03 Bought Size: -240 Price: 60.4
31:02.8   SNI   47224   49   ExecDetails   ### Execution Ignored - Negative Fill
31:02.8   SNI   47224   49   OrderStatusSubmitted   Order status updated
31:02.8   SNI   47224   49   ExecDetails   20121031 10:31:03 Bought Size: 240 Price: 60.4
31:02.9   n/a   47224   n/a   OrderStatusSubmitted   Order ID not currently tracked by TWS plugin.
31:02.9   n/a   47224   n/a   OrderStatusSubmitted   Order ID not currently tracked by TWS plugin.
31:54.8   SNI   47224   n/a   ExecDetails: untracked order   20121031 10:31:56 Bought Size: 105 Price: 60.4
31:54.8   n/a   47224   n/a   OrderStatusFilled   Order ID not currently tracked by TWS plugin.
31:54.9   SNI   47224   n/a   ExecDetails: untracked order   20121031 10:31:56 Bought Size: -202 Price: 60.4
31:54.9   n/a   47224   n/a   OrderStatusFilled   Order ID not currently tracked by TWS plugin.
31:54.9   SNI   47224   n/a   ExecDetails: untracked order   20121031 10:31:56 Bought Size: 202 Price: 60.4
31:54.9   SNI   47224   n/a   ExecDetails: untracked order   20121031 10:31:56 Bought Size: -303 Price: 60.4
31:54.9   n/a   47224   n/a   OrderStatusFilled   Order ID not currently tracked by TWS plugin.
31:54.9   SNI   47224   n/a   ExecDetails: untracked order   20121031 10:31:56 Bought Size: 303 Price: 60.4
31:54.9   n/a   47224   n/a   OrderStatusFilled   Order ID not currently tracked by TWS plugin.
31:55.0   n/a   47224   n/a   OrderStatusFilled   Order ID not currently tracked by TWS plugin.
31:55.1   n/a   47224   n/a   OrderStatusFilled   Order ID not currently tracked by TWS plugin.
04:33.3   SNI   47224   n/a   ExecDetails: untracked order   20121031 10:30:53 Bought Size: 100 Price: 60.4
04:33.3   SNI   47224   n/a   ExecDetails: untracked order   20121031 10:30:54 Bought Size: 100 Price: 60.4
04:33.3   SNI   47224   n/a   ExecDetails: untracked order   20121031 10:30:54 Bought Size: 100 Price: 60.4
04:33.3   SNI   47224   n/a   ExecDetails: untracked order   20121031 10:30:55 Bought Size: 100 Price: 60.4
04:33.3   SNI   47224   n/a   ExecDetails: untracked order   20121031 10:31:03 Bought Size: -202 Price: 60.4
04:33.3   SNI   47224   n/a   ExecDetails: untracked order   20121031 10:31:03 Bought Size: 202 Price: 60.4
04:33.3   SNI   47224   n/a   ExecDetails: untracked order   20121031 10:31:03 Bought Size: -303 Price: 60.4
04:33.3   SNI   47224   n/a   ExecDetails: untracked order   20121031 10:31:03 Bought Size: 303 Price: 60.4
04:33.3   SNI   47224   n/a   ExecDetails: untracked order   20121031 10:31:56 Bought Size: 105 Price: 60.4
Posted Monday November 05 2012
Once an order is filled, the TWS plugin removes it from the list of active orders. If an order isn't in the plugin's list of active orders it will log that the order isn't currently tracked by the plugin.

In this log there are two fill messages with a negative size, which are ignored by the TWS plugin. This is causing the plugin to think the order is closed prematurely, because the corresponding positive fills are treated normally. In the past I have seen negative fills happen when using FA accounts. However, if that were the case, normally I'd expect to see the account number for the fill listed in the ExecDetails messages, which isn't the case in this log. Were you using an FA account?

Thanks,
Daniel
Posted Monday November 05 2012
Daniel,

   Yes, I was using an FA account for the orders above. For FA orders, the order is first purchased in the master account and then transferred to the subaccounts based on the profile. The negative values are the amounts removed from the master account during the transfer to the subaccounts.

Part of the problem appears that the amounts may be misinterpreted by RightEdge versus what is actually happening - tws audit trail reports the same as the RightEdge twslog file - because the negative amounts of 202 and 303 actually are the total amount transferred out of the master to the subaccounts. This occurs, for example, starting at 10 and 11 below. For the order for 505 SNI above the order execution from the tws audit trail proceeded as follows:

1.   Partial fill of 100 (master)
2.   Partial fill of 100 (master)
3.   Partial fill of 100 (master)
4.   Partial fill of 100 (master)
5.   Negative fill of 160 (master)
6.   Fill of 160 (subacct 1)
7.   Negative fill of 240 (master)
8.   Fill of 240 (subacct 2)
9.   Partial fill of 105 (master)
10.   Negative fill stated as 202; however, this is the total amount transferred to subacct 1
11.   Fill stated as 202 for subacct 1 - total amount transferred which includes the amount in #6
12.   Negative fill stated as 303; however, this is the total amount transferred to subacct 2
13.   Fill stated as 303 for subacct 2 - total amount transferred which includes the amount in #8

The above situation is leading to phantom orders that don’t exist which later cause either incorrect order placement or exceptions. How can we fix?

Thanks, Duane
Posted Thursday November 08 2012
We need a way to determine in the TWS Plugin whether a fill is for the master account or for a subaccount, and then we may need to adjust the TWS plugin logic depending on how you are using FA accounts.

The plugin currently uses the AccountNumber property of the execution, which should tell us whether the execution was for the master account or one of the subaccounts. However, the account number should have been included in the log if it was set to anything. Are you using a modified version of the TWS plugin? Do you have the following logic in client_ExecDetails?

if (!string.IsNullOrEmpty(e.Execution.AccountNumber))
{
   logDetails += " Acct: " + e.Execution.AccountNumber;
}

If you set the Account Code for the TWS plugin, it will ignore any executions for other accounts. So if you set it to the account code for the master account, then it should ignore the fills for the subaccounts, and it will also ignore the negative executions. Does this sound like it would work? Of course, for it to work at all the AccountNumber for the Executions needs to be set.

Thanks,
Daniel
Posted Friday November 09 2012
The code above was commented but I will uncomment and test next week. I do have a modified version which can place orders at the FA or the subaccount level depending on custom tag properties during submit. Required settings are stored in the custom string and reloaded from liveopenpositions.

I currently place orders at both the FA and subaccount level because I have a marginable and non-marginable account. For longs, I use the FA account, with an FA profile, which reduces commissions (vs. the required min for each account). For shorts I place at the subaccount level. I could alternatively use two different FA profiles if needed but having the flexibility allows allocations to be dynamically set via code versus set statically via FA profiles.

Thanks, Duane
Posted Monday November 12 2012
Thanks, that explains what's happening.

For each fill for an order you submitted for the master FA account, you will get a fill from TWS for the master account, and then for each subaccount you'll get a negative fill in the master account and a fill in the subaccount. Negative fills (or undoing previous fills) aren't supported, so the negative fill will be ignored. For everything to be add up correctly, the TWS plugin needs to also either ignore the fill for the master account or the fills for the subaccount.

The existing logic is written so that you can specify the master FA account code, and it will ignore all the subaccount fills. Since you want to explicitly trade the subaccounts for some orders, I would recommend coding the plugin to ignore any fills on the master account, since those fills will end up being reported at the subaccount level. Be sure to log what is happening so if we need to investigate something the right information will be available.

Does that sound like a good solution?

Thanks,
Daniel
Posted Wednesday November 14 2012
Does the code (ignoring the fills on the master when the order is placed on the subaccount only) only need to be modified in client_ExecDetails?

Thanks, Duane

Edited: Wednesday November 14 2012 by alpha23
Posted Wednesday November 14 2012
Yes, client_ExecDetails is the only place it registers fills so that's the place you'll need to change. If you use the _settings.AccountCode property in your logic, you may need to make changes elsewhere too, as that property is used in a few other places.

Thanks,
Daniel
Posted Thursday November 15 2012
I modified client_ExecDetails and received an “Overfill 67/1836:” in OrderFilled. The TWS log is below. The original order below was to close the position which it did execute in TWS.

A few questions:

1.   If the execution is ignored in client_ExecDetails, is CustomString and Tag set? I assume no because both were null.
2.   Can the above trade in OrderFilled be completely ignored?
3.   If yes to #1, what is the best way to determine trades to discard. Is searching on Description for “Overfill” sufficient or is there a better way to determine if the trade should be ignored for further processing?
4.   Is there a way to prevent this condition because the position remains in OpenPositions which causes other issues.

Thanks, Duane

31:45.6   LEG   47915   35   SubmitOrder   47915: Market On Close Sell LEG 0/1836 - Submitted
31:45.6   LEG   47719   35   CancelOrder   Cancelling order
31:45.8   LEG   47719   35   IB error/warning   202: Order Canceled - reason:
31:47.8   LEG   47719   35   OrderStatusApiCanceled   Order status updated
01:20.1   LEG   47915   35   ExecDetails   20121115 13:59:31 Sold Size: 400 Price: 26.16
01:20.1   LEG   47915   35   ExecDetails   Partial fill: total 400/1836
01:22.1      LEG   47915   35   OrderStatusPendingSubmit   Order status updated
01:22.1      LEG   47915   35   ExecDetails   20121115 13:59:31 Sold Size: 768 Price: 26.16
01:22.1      LEG   47915   35   ExecDetails   Partial fill: total 1168/1836
01:24.1   LEG   47915   35   OrderStatusPendingSubmit   Order status updated
01:24.1   LEG   47915   35   ExecDetails   20121115 13:59:31 Sold Size: 400 Price: 26.16
01:24.1   LEG   47915   35   ExecDetails   ### Execution Ignored - this fill appears to have been reported already
01:26.2   LEG   47915   35   OrderStatusPendingSubmit   Order status updated
01:26.2   LEG   47915   35   ExecDetails   20121115 13:59:31 Sold Size: 268 Price: 26.16
01:26.2   LEG   47915   35   ExecDetails   Partial fill: total 1436/1836
01:28.2   LEG   47915   35   OrderStatusFilled   Order status updated
01:38.4   LEG   47760   35   CancelOrder   Cancelling order
02:18.9   LEG   47915   35   OrderStatusFilled   Order status updated
02:20.9   LEG   47915   35   OrderStatusFilled   Order status updated
02:22.9   LEG   47915   35   OrderStatusFilled   Order status updated
02:25.0   LEG   47915   35   OrderStatusFilled   Order status updated
03:54.5   LEG   47915   35   OrderStatusFilled   Order status updated
04:02.8   LEG   47915   35   ExecDetails   20121115 13:59:34 Sold Size: -467 Price: 26.16
04:02.8   LEG   47915   35   ExecDetails   ### Execution Ignored - Negative Fill
04:04.8   LEG   47915   35   OrderStatusFilled   Order status updated
04:04.8   LEG   47915   35   ExecDetails   20121115 13:59:34 Sold Size: 467 Price: 26.16
04:04.8   LEG   47915   n/a   ExecDetails: untracked order   20121115 13:59:34 Sold Size: -268 Price: 26.16
04:04.8   LEG   47915   n/a   ExecDetails: untracked order   20121115 13:59:34 Sold Size: 268 Price: 26.16
04:04.8   LEG   47915   n/a   ExecDetails: untracked order   20121115 13:59:34 Sold Size: -701 Price: 26.16
04:04.8   LEG   47915   n/a   ExecDetails: untracked order   20121115 13:59:34 Sold Size: 701 Price: 26.16
04:04.8   LEG   47915   n/a   ExecDetails: untracked order   20121115 13:59:34 Sold Size: -400 Price: 26.16
04:04.8   LEG   47915   n/a   ExecDetails: untracked order   20121115 13:59:34 Sold Size: 400 Price: 26.16


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems