OpenAPI

When an order is fully or partially filled, a new position is created. Netpositions give an overview of exposure and average purchase price across multiple positions. Simply an aggregated/summarized position by instrument on a selected client, account or group of accounts.

The profit/loss, exposure  and currency are determined by the calculation entity requested. All values are available in real-time. Hence, if only ClientKey is specified the calculation currency is the client's base currency. But if a AccountKey is specified, the base currency values will be returned in account currency. When AccountGroupKey is specified, calculations are returned in the client's base currency, but only for the accounts in the given group.

You may start one netposition subscription on the client level, and another on a specific account.

To get all positions under a given Netposition, use the NetPositionId filter on the Positions endpoint.

We highly recommend writing your application to leverage NetPositions rather than relying on updates and repeatedly iterating a list of individual positions.


Getting NetPositions, Positions and Orders

Getting a list of your open orders, positions or NetPositions is simple. Below are some examples of the most common operations.

You must always specify the client/account/account perspective, so either use the /me endpoints for default client level, or specify a ClientKey and optionally an AccountKey or AccountGroupKey. 

Current prices, distance to market and profit/loss calculations are based on the user's market data access agreements. Some exchanges only allow real-time prices streamed to one session. This means that you can loose your price feed rights if logging in from multiple platforms. See Session Capabilities for details.

Example: How to get list of orders, positions or NetPositions on an account or across all accounts

The fastest and simplest way to get a list of orders, positions or NetPositions across all accounts, calculated in client currency, for the logged in user is to use the /me endpoint. It is available on all portfolio services.

Get my positions:

GET https://gateway.saxobank.com/sim/openapi/port/v1/positions?ClientKey={clientkey} 

To get all positions under a given account, with all values calculated in account currency, specify the clientkey and accountkey.

Get all positions on a specific account:

GET https://gateway.saxobank.com/sim/openapi/port/v1/positions?ClientKey={clientkey}&AccountKey={accountKey}

Get all positions on a specific account group:

GET https://gateway.saxobank.com/sim/openapi/port/v1/positions?ClientKey={clientkey}&AccountGroupKey={accountKey}

Example: How to get all positions under a Netposition

To get a list of all positions under a given Netposition, use the NetPositionId filter argument. The calculation currency is determined by the ClientKey, or if AccountKey is specified the account currency.

GET https://gateway.saxobank.com/sim/openapi/port/v1/positions?ClientKey={clientkey}&NetPositionId={netpositionid}

Example: How to get market active orders only

You may want to omit the passive order types that are not market active before a given price threshold or event takes place. such as the family of stop and trailing orders.

Get the current market active orders only:

GET https://gateway.saxobank.com/sim/openapi/port/v1/orders?ClientKey={clientkey}&Status=Working

Example: How to get a list of positions under a underlying client. 

For partners, getting orders, positions or NetPositions for an underlying client, or client account is no different than getting them for your own client. You simply specify the ClientKey and optionally AccountKey for the underlying partner or client.

Get all positions on a underlying client's account:

GET https://gateway.saxobank.com/sim/openapi/port/v1/positions?ClientKey={clientkey of subclient}&AccountKey={accountKey of subclient}

ClosedPositions and the client's position netting mode

For clients, two netting modes are available, End of day and Intraday. The main difference is that with Intraday netting, positions are moved from Positions lists to the ClosedPositions endpoint as they are closed.

With End of day netting, closed positions stay on the Positions lists until end of day. In both cases, final settlement still occurs at end of day. It can be practical to only see active open positions, so this endpoint allows qualified clients to switch the netting mode. See this article for an in-depth explanation.

Example: How to get a list of closed positions for a client on Intraday netting

Get all closed positions on a client's account:

GET https://gateway.saxobank.com/sim/openapi/port/v1/closedpositions?ClientKey={clientkey}&AccountKey={accountkey}

 Netposition Status (Explicit close vs implicit close)

Since Saxo supports explicit netting of positions, one subtle distinction to note is the difference between an explicitly closed position vs. an implicitly closed position. If one specifies a RelatedPositionId when placing an order, the resulting position will be explicitly related to the related position.

  • A Netposition consisting only of closed, explicitly related positions, will have status Closed
  • If one or more positions are PartiallyFilled, then the Status will be PartiallyFilled
  • If the sum of unrelated positions is 0, the Status will be Square
  • In all other instances, the NetPosition will have Status Open