CreateAllocationKey

class saxo_openapi.endpoints.trading.allocationkeys.CreateAllocationKey(data)

Create an allocation key.

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

Instantiate a CreateAllocationKey request.

Parameters:data (dict (required)) – dict representing the parameters of the requestbody.
>>> import saxo_openapi
>>> import saxo_openapi.endpoints.trading as tr
>>> import json
>>> client = saxo_openapi.API(access_token=...)
>>> data =
        {
          "AllocationKeyName": "MyAllocation_Key",
          "AllocationUnitType": "Percentage",
          "MarginHandling": "Reduce",
          "OneTime": true,
          "OwnerAccountKey": "LZTc7DdejXODf-WSl2aCyQ==",
          "ParticipatingAccountsInfo": [
            {
              "AcceptRemainderAmount": true,
              "AccountKey": "LZTc7DdejXODf-WSl2aCyQ==",
              "Priority": 1,
              "UnitValue": 10.0
            },
            {
              "AcceptRemainderAmount": false,
              "AccountKey": "LZTc7DdejXODf-WSl2aCyQ==",
              "Priority": 1,
              "UnitValue": 90.0
            }
          ]
        }
>>> r = tr.allocationkeys.CreateAllocationKey(data=data)
>>> client.request(r)
>>> print(json.dumps(r.response, indent=4))

Output:

{
  "AllocationKeyId": "227"
}
expected_status
response

response - get the response of the request.

status_code