API Support Forum
OEC API > API Support > Non-regular order of API callbacks on Order being filled
Author Topic: Non-regular order of API callbacks on Order being filled
(3 messages, Page 1 of 1)
Moderators: VPfau
CWeber984
Posts: 226
Joined: Apr 24, 2012


Posted: Apr 24, 2012 @ 07:43 PM             Msg. 1 of 3
Given these three API callbacks:

OnOrderFilled
OnOrderStateChanged
On(Ave)PositionChanged

I have observed non-regular ordering for the following scenario (well-tested):

I buy one stock and sell one stock of same symbol in two orders. There are no open orders remaining.

I understand that On(Ave)PositionChanged would be necessarily async from the other two API callbacks. However, I have also observed that OnOrderFilled and OnOrderStateChanged do not follow a regular ordering amongst themselves on an order being filled. (In my tests, the order is completely filled, not partially.)

Can you inform as to the order of callbacks that I should be able to expect for this simple scenario and give some salient background information as to why? This information will be quite useful, thanks much.


CHW
Edited by CWeber984 on Apr 24, 2012 at 19:46:22
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Apr 25, 2012 @ 09:09 AM             Msg. 2 of 3
OnOrderStateChanged with Completed status should come after OnOrderFilled with the last fill. Please send me order id for investigation, if you noticed a fill after Completed status.

OnAveragePositionChanged can come out of sequence relatively fills that built this position.

Victor Vins
Lead Software Developer
CWeber984
Posts: 226
Joined: Apr 24, 2012


Posted: Apr 26, 2012 @ 12:21 PM             Msg. 3 of 3
Perhaps my initial observations were not correct due to not focusing enough on which orders were being filled and which were changing state. Thank you again.



CHW
Edited by CWeber984 on Apr 27, 2012 at 11:13:23
Edited by CWeber984 on Apr 27, 2012 at 11:13:44