In real-time netting opposing positions are netted immediately and are moved from the Positions tab to the Closed Positions tab. To explain this lets assume that we first make a market order to buy 100.000 EURUSD. This creates a position:
Then we make a market order to sell 100.000 EURUSD. This moves the position from the Positions tab to the Closed Positions tab:
These are the endpoints to GET this information:
- /port/v1/positions: Will return an empty list.
- /port/v1/netpositions: Will return an empty list.
- /port/v1/closedpositions: Will return information about the closed position.
Notice:
- It is not possible to place orders related to an individual position.
- P/L on closed and open margin positions are separated. To accommodate for this, the /port/balances/endpoint return two additional fields UnrealizedMarginOpenProfitLoss and UnrealizedMarginClosedProfitLoss. The UnrealizedProfitLoss field has been retained for backwards compatibility and has the value of the sum of UnrealizedMarginOpenProfitLoss and UnrealizedMarginClosedProfitLoss.
ENS messages
At Saxo Bank real-time netting is implemented as a simulation of what will actually happen in our back-office system over night. In reality the two opposing positions still exist, they are just no longer visible in the UI or available through /port/v1/positions. So in the above situation:
- You will get a BUY 100.000 EURUSD "New Position" event, with the PositionId of the fist position, when the first trade is made.
- You will get a SELL 100.000 EURUSD "New Position" event with the PositionId of the second position, when the second trade is made.
When the positions are netted over night by our back-office system, you will get two "Deleted Position" events.
What to be aware of when switching to real-time netting
- It is no longer possible to relate orders to positions.
- Also, if you place a three-way order (entry+ stop loss/take profit order), once the entry order has been executed and the two related orders become working, these orders will also not be related to the newly created position.
- Opposing positions are netted immediately and removed from the /port/v1/positions and /port/v1/netpositions resources. Instead they are available in the /port/v1/closedpositions resource.
- Netted positions are available as closed positions through the /port/v1/closedpositions resource. However notice that the closedpositions resource does not have the same fields as /port/v1/positions.
- In the example above you will receive two ENS messages, both of them of with PositionEvent: new, so if you are solely relying on ENS to keep track of your "open positions" you will need to apply some logic to "understand" when a PositionEvent: new is closing a position. The ENS messages telling that the positions have been deleted are sent in the end of day processing.
- It is not possible to exercise individual option positions. Instead use the /trade/v1/positions/exercise endpoint to exercise a specified amount out of the total net position amount.