CreatePriceSubscription

class saxo_openapi.endpoints.trading.prices.CreatePriceSubscription(data)

Sets up an active price subscription on an instrument and returns an initial snapshot of the most recent price.

ENDPOINT = 'openapi/trade/v1/prices/subscriptions'
EXPECTED_STATUS = 201
METHOD = 'POST'
__init__(data)

Instantiate a CreatePriceSubscription request.

Parameters:data (dict (required)) – dict representing the data body, in this case an order spec.
>>> import saxo_openapi
>>> import saxo_openapi.endpoints.trading as tr
>>> import json
>>> client = saxo_openapi.API(access_token=...)
>>> data =
        {
          "Arguments": {
            "Uic": 45,
            "AssetType": "FxSpot"
          },
          "ContextId": "explorer_1552305379377",
          "ReferenceId": "USDSGD"
        }
>>> r = tr.prices.CreatePriceSubscription(data=data)
>>> rv = client.request(r)
>>> print(json.dumps(rv, indent=2))
{
  "ContextId": "explorer_1552305379377",
  "Format": "application/json",
  "InactivityTimeout": 30,
  "ReferenceId": "N_935",
  "RefreshRate": 1000,
  "Snapshot": {
    "AssetType": "FxSpot",
    "LastUpdated": "2019-03-11T21:14:00.578000Z",
    "PriceSource": "SBFX",
    "Quote": {
      "Amount": 100000,
      "Ask": 1.35827,
      "Bid": 1.35754,
      "DelayedByMinutes": 0,
      "ErrorCode": "None",
      "Mid": 1.357905,
      "PriceTypeAsk": "Tradable",
      "PriceTypeBid": "Tradable",
      "RFQState": "None"
    },
    "Uic": 45
  },
  "State": "Active"
}
expected_status
response

response - get the response of the request.

status_code