Position id switch because of partially filled order

 

Hi everyone,


I have a quite specific question about the POSITION_IDENTIFIER (PI) of a position in a certain case. But first a bit of information about what I found out so far. When an order opens a new position, the POSITION_TICKET (PT) and the PI are set to the ORDER_TICKET (OT) of this order. When a position is fully closed, the next position that is opened just again gets the PT and PI set to the OT of the order that opens it. In case of a directional change of the position (DEAL_ENTRY_INOUT type of deal), so from buy to sell or the other way around, the PI stays constant and only the PT changes to the OT of the order that caused the directional change. So far, so good.

My question now is, what will happen if an order is set to change the direction but it is not filled entirely but only partially and one of the partial deals that are connected to that order just happens to close the position entirely (instead of doing an INOUT), so that another following partial deal of the same order then opens a new position? Is it the same as stated above, so PI constant and PT = OT of the order? Or will the PI also change to the new OT? If it is case one, then that's all. But if it is case two, then I would also want to know, what will happen to the ORDER_POSITION_ID (OPI) of the order that causes it. Will it stay on the PI of the position that was closed or is it updated to the PI of the newly opened position?


Cheers, tandoori