CreateChartDataSubscription

class saxo_openapi.endpoints.chart.charts.CreateChartDataSubscription(data)

Sets up a subscription and returns an initial snapshot of most recently completed samples specified by the parameters in the request.

Subsequent samples are delivered over the streaming channel. Most often a single new sample or sample update is delivered at a time, but when a sample closes, you will typcially get two samples: The now closed bar, and the bar just opening.

ENDPOINT = 'openapi/chart/v1/charts/subscriptions'
EXPECTED_STATUS = 201
HEADERS = {'Content-Type': 'application/json'}
METHOD = 'POST'
__init__(data)

Instantiate a CreateChartDataSubscription request.

Parameters:data (dict (required)) – dict representing the data body, in this case an order spec.
>>> import saxo_openapi
>>> import saxo_openapi.endpoints.chart as ch
>>> import json
>>> client = saxo_openapi.API(access_token=...)
>>> data =
        {
          "Arguments": {
            "AssetType": "FxSpot",
            "Count": 2,
            "Horizon": 1,
            "Uic": 21
          },
          "ContextId": "20190830035501020",
          "Format": "application/json",
          "ReferenceId": "UIC_21",
          "RefreshRate": 1000
        }
>>> r = ch.charts.CreateChartDataSubscription(data=data)
>>> client.request(r)
>>> print(json.dumps(rv, indent=2))
{
  "ContextId": "20190830035501020",
  "Format": "application/json",
  "InactivityTimeout": 30,
  "ReferenceId": "UIC_21",
  "RefreshRate": 1000,
  "Snapshot": {
    "Data": [
      {
        "CloseAsk": 1.10631,
        "CloseBid": 1.10611,
        "HighAsk": 1.10636,
        "HighBid": 1.10616,
        "LowAsk": 1.10631,
        "LowBid": 1.10611,
        "OpenAsk": 1.10632,
        "OpenBid": 1.10612,
        "Time": "2019-09-09T16:54:00.000000Z"
      },
      {
        "CloseAsk": 1.10631,
        "CloseBid": 1.10611,
        "HighAsk": 1.10632,
        "HighBid": 1.10612,
        "LowAsk": 1.10631,
        "LowBid": 1.10611,
        "OpenAsk": 1.10632,
        "OpenBid": 1.10612,
        "Time": "2019-09-09T16:55:00.000000Z"
      }
    ],
    "DataVersion": 1592272523
  },
  "State": "Active"
}
expected_status
response

response - get the response of the request.

status_code