CreateExposureSubscription

class saxo_openapi.endpoints.portfolio.exposure.CreateExposureSubscription(data)

Sets up a subscription and returns an initial snapshot of list of instrument exposure specified by the parameters in the request.

ENDPOINT = 'openapi/port/v1/exposure/instruments/subscriptions'
EXPECTED_STATUS = 201
METHOD = 'POST'
__init__(data)

Instantiate a CreateExposureSubscription request.

Parameters:data (dict (required)) – dict representing the body with request parameters
>>> import saxo_openapi
>>> import saxo_openapi.endpoints.portfolio as pf
>>> import json
>>> client = saxo_openapi.API(access_token=...)
>>> data =
        {
          "Arguments": {
            "ClientKey": "Cf4xZWiYL6W1nMKpygBLLA=="
          },
          "ContextId": "explorer_1552035128308",
          "ReferenceId": "Z_807"
        }
>>> r = pf.exposure.CreateExposureSubscription(data=data)
>>> client.request(r)
>>> print(json.dumps(r.response, indent=2))

Output:

{
  "ContextId": "explorer_1552035128308",
  "Format": "application/json",
  "InactivityTimeout": 30,
  "ReferenceId": "Z_807",
  "RefreshRate": 1000,
  "Snapshot": {
    "Data": [
      {
        "Amount": 60000,
        "AssetType": "FxSpot",
        "AverageOpenPrice": 1.13071,
        "CalculationReliability": "Ok",
        "CanBeClosed": true,
        "DisplayAndFormat": {
          "Currency": "USD",
          "Decimals": 4,
          "Description": "Euro/US Dollar",
          "Format": "AllowDecimalPips",
          "Symbol": "EURUSD"
        },
        "InstrumentPriceDayPercentChange": 0.44,
        "NetPositionId": "EURUSD__FxSpot",
        "ProfitLossOnTrade": -396.6,
        "Uic": 21
      },
      {
        "Amount": -50000,
        "AssetType": "FxSpot",
        "AverageOpenPrice": 8.6839,
        "CalculationReliability": "Ok",
        "CanBeClosed": true,
        "DisplayAndFormat": {
          "Currency": "DKK",
          "Decimals": 4,
          "Description": "British Pound/Danish Krone",
          "Format": "Normal",
          "Symbol": "GBPDKK"
        },
        "InstrumentPriceDayPercentChange": -0.98,
        "NetPositionId": "GBPDKK__FxSpot",
        "ProfitLossOnTrade": 2420,
        "Uic": 25
      }
    ]
  },
  "State": "Active"
}
expected_status
response

response - get the response of the request.

status_code