NetPositionsQuery

class saxo_openapi.endpoints.portfolio.netpositions.NetPositionsQuery(params)

Get netpositions for a client, account group, account or position. Returns a list of net positions fulfilling the criteria specified by the query string parameters. Each net position may include all related sub positions if fieldGroups includes SubPositions.

ENDPOINT = 'openapi/port/v1/netpositions'
EXPECTED_STATUS = 200
METHOD = 'GET'
__init__(params)

Instantiate a NetPositionsQuery request.

Parameters:params (dict (required)) – dict representing the querystring parameters
>>> import saxo_openapi
>>> import saxo_openapi.endpoints.portfolio as pf
>>> import json
>>> client = saxo_openapi.API(access_token=...)
>>> params =
        {
          "ClientKey": "Cf4xZWiYL6W1nMKpygBLLA=="
        }
>>> r = pf.netpositions.NetPositionsQuery(params=params)
>>> client.request(r)
>>> print(json.dumps(r.response, indent=4))

Output:

{
  "__count": 4,
  "Data": [
    {
      "NetPositionBase": {
        "AccountId": "9226397",
        "Amount": 100000,
        "AssetType": "FxSpot",
        "CanBeClosed": true,
        "ClientId": "9226397",
        "IsMarketOpen": true,
        "NumberOfRelatedOrders": 0,
        "PositionsAccount": "9226397",
        "SinglePositionId": "212550210",
        "SinglePositionStatus": "Open",
        "Uic": 23,
        "ValueDate": "2019-03-06T00:00:00.000000Z"
      },
      "NetPositionId": "GBPCAD__FxSpot",
      "NetPositionView": {
        "AverageOpenPrice": 1.75824,
        "CalculationReliability": "Ok",
        "CurrentPrice": 1.75287,
        "CurrentPriceDelayMinutes": 0,
        "CurrentPriceType": "Bid",
        "Exposure": 100000,
        "ExposureCurrency": "GBP",
        "ExposureInBaseCurrency": 116180.5,
        "InstrumentPriceDayPercentChange": -0.19,
        "PositionCount": 1,
        "PositionsNotClosedCount": 1,
        "ProfitLossOnTrade": -537,
        "ProfitLossOnTradeInBaseCurrency": -355.85,
        "Status": "Open",
        "TradeCostsTotal": -17.55,
        "TradeCostsTotalInBaseCurrency": -11.63
      }
    },
    {
      "NetPositionBase": {
        "AccountId": "9226397",
        "Amount": 500000,
        "AssetType": "FxSpot",
        "CanBeClosed": true,
        "ClientId": "9226397",
        "IsMarketOpen": true,
        "NumberOfRelatedOrders": 0,
        "PositionsAccount": "9226397",
        "SinglePositionId": "212550212",
        "SinglePositionStatus": "Open",
        "Uic": 22,
        "ValueDate": "2019-03-06T00:00:00.000000Z"
      },
      "NetPositionId": "GBPAUD__FxSpot",
      "NetPositionView": {
        "AverageOpenPrice": 1.86391,
        "CalculationReliability": "Ok",
        "CurrentPrice": 1.8575,
        "CurrentPriceDelayMinutes": 0,
        "CurrentPriceType": "Bid",
        "Exposure": 500000,
        "ExposureCurrency": "GBP",
        "ExposureInBaseCurrency": 580902.5,
        "InstrumentPriceDayPercentChange": -0.39,
        "PositionCount": 1,
        "PositionsNotClosedCount": 1,
        "ProfitLossOnTrade": -3205,
        "ProfitLossOnTradeInBaseCurrency": -2004.09,
        "Status": "Open",
        "TradeCostsTotal": -93.04,
        "TradeCostsTotalInBaseCurrency": -58.18
      }
    },
    {
      "NetPositionBase": {
        "AccountId": "9226397",
        "Amount": 0,
        "AssetType": "FxSpot",
        "CanBeClosed": false,
        "ClientId": "9226397",
        "IsMarketOpen": true,
        "NumberOfRelatedOrders": 0,
        "PositionsAccount": "9226397",
        "Uic": 21,
        "ValueDate": "2019-03-06T00:00:00.000000Z"
      },
      "NetPositionId": "EURUSD__FxSpot",
      "NetPositionView": {
        "AverageOpenPrice": 0,
        "CalculationReliability": "Ok",
        "CurrentPrice": 1.13377,
        "CurrentPriceDelayMinutes": 0,
        "CurrentPriceType": "Bid",
        "Exposure": 0,
        "ExposureCurrency": "EUR",
        "ExposureInBaseCurrency": 0,
        "InstrumentPriceDayPercentChange": -0.23,
        "PositionCount": 2,
        "PositionsNotClosedCount": 2,
        "ProfitLossOnTrade": 5,
        "ProfitLossOnTradeInBaseCurrency": 4.41,
        "Status": "Open",
        "TradeCostsTotal": -11.38,
        "TradeCostsTotalInBaseCurrency": -10.04
      }
    },
    {
      "NetPositionBase": {
        "AccountId": "9226397",
        "Amount": 10000,
        "AssetType": "FxSpot",
        "CanBeClosed": true,
        "ClientId": "9226397",
        "IsMarketOpen": true,
        "NumberOfRelatedOrders": 0,
        "PositionsAccount": "9226397",
        "SinglePositionId": "212675868",
        "SinglePositionStatus": "Open",
        "Uic": 31,
        "ValueDate": "2019-03-06T00:00:00.000000Z"
      },
      "NetPositionId": "GBPUSD__FxSpot",
      "NetPositionView": {
        "AverageOpenPrice": 1.31849,
        "CalculationReliability": "Ok",
        "CurrentPrice": 1.31718,
        "CurrentPriceDelayMinutes": 0,
        "CurrentPriceType": "Bid",
        "Exposure": 10000,
        "ExposureCurrency": "GBP",
        "ExposureInBaseCurrency": 11618.05,
        "InstrumentPriceDayPercentChange": -0.26,
        "PositionCount": 1,
        "PositionsNotClosedCount": 1,
        "ProfitLossOnTrade": -13.1,
        "ProfitLossOnTradeInBaseCurrency": -11.55,
        "Status": "Open",
        "TradeCostsTotal": -6,
        "TradeCostsTotalInBaseCurrency": -5.29
      }
    }
  ]
}
expected_status
response

response - get the response of the request.

status_code