This page documents the functionality of all worksheet functions provided by the OpenAPI for Excel add-in.
Generic Functions
This category includes all functions that perform basic, low-level HTTP interactions with Saxo's OpenAPI.
OpenAPIGet()
Description | Generic function for sending a GET request to the OpenAPI. |
Use | Worksheet cells, VBA. |
Arguments | Type | Description | Example |
---|---|---|---|
Request | String | Path to the OpenAPI endpoint including query string parameters. | "/openapi/ref/v1/instruments/details/?AssetTypes=FxSpot&Uics=21" |
Fields | String | List of comma-separated, case-sensitive field names to be returned from the response with full stops identifying nested fields under a specific FieldGroup. | "Description,Exchange.CountryCode,Format.OrderDecimals" |
OpenAPIPost()
Description | Generic function for sending a POST request to the OpenAPI. |
Use | Worksheet cells, VBA. |
Arguments | Type | Description | Example |
---|---|---|---|
Request | String | Path to the OpenAPI endpoint including query string parameters. | "/openapi/trade/v1/orders" |
Body | String | JSON-structured string where double quotes are replaced by single quotes. | "{'AccountKey':'ABCDE12345', 'Amount':100000, 'AssetType':'FxSpot', 'BuySell':'Buy', 'OrderDuration':{'DurationType':'DayOrder'}, 'OrderRelation':'Oco', 'OrderType':'Market', 'Uic':21}" |
OpenAPIPut()
Description | Generic function for sending a PUT request to the OpenAPI. |
Use | Worksheet cells, VBA. |
Arguments | Type | Description | Example |
---|---|---|---|
Request | String | Path to the OpenAPI endpoint including query string parameters. | "/openapi/trade/v1/positions/exercise" |
Body | String | JSON-structured string where double quotes are replaced by single quotes. | "{'AccountKey':'ABCDE12345', 'Amount':100, 'AssetType':'StockOption', 'Uic':5455848}" |
OpenAPIPatch()
Description | Generic function for sending a PATCH request to the OpenAPI. |
Use | Worksheet cells, VBA. |
Arguments | Type | Description | Example |
---|---|---|---|
Request | String | Path to the OpenAPI endpoint including query string parameters. | "/openapi/trade/v1/orders/" |
Body | String | JSON-structured string where double quotes are replaced by single quotes. | "{'AccountKey':'ABCDE12345', 'Amount':200.0, 'OrderDuration':{'DurationType':'GoodTillCancel'}, 'OrderPrice':1264.0, 'OrderType':'Limit'}" |
OpenAPIDelete()
Description | Generic function for sending a DELETE request to the OpenAPI. |
Use | Worksheet cells, VBA. |
Arguments | Type | Description | Example |
---|---|---|---|
Request | String | Path to the OpenAPI endpoint including query string parameters. | "/openapi/trade/v1/orders/75646392/?AccountKey=ABCDE12345" |
OpenAPIGetAsync()
Description | Generic function for sending an asynchronous GET request to the OpenAPI. |
Use | Worksheet cells only. |
Arguments | Type | Description | Example |
---|---|---|---|
Request | String | Path to the OpenAPI endpoint including query string parameters. | "/openapi/ref/v1/instruments/details/?AssetTypes=FxSpot&Uics=21" |
Fields | String | List of comma-separated, case-sensitive field names to be returned from the response with full stops identifying nested fields under a specific FieldGroup. | "Description,Exchange.CountryCode,Format.OrderDecimals" |
OpenAPISubscribe()
Description | Generic function for subscribing to the an OpenAPI endpoint. |
Use | Worksheet cells only. |
Arguments | Type | Description | Example |
---|---|---|---|
Uri | String | Path to the OpenAPI endpoint without query string parameters. | "/openapi/trade/v1/infoprices/subscriptions" |
Arguments | String | List of comma-separated, case-sensitive field names to be returned from the response with full stops identifying nested fields under a specific FieldGroup. | "AssetType:FxSpot,Uics:21,22,23" |
FieldGroups | String | List of comma-separated, case-sensitive FieldGroups to be retrieved from the OpenAPI. | "Quote,Exchange,Format" |
Fields | String | List of comma-separated, case-sensitive field names to be returned from the response with full stops identifying nested fields under a specific FieldGroup. | "Description,Exchange.CountryCode,Format.OrderDecimals" |
Utility Functions
This category includes all functions that service as shortcuts for standard API calls such as getting account keys and refreshing formulas.
OpenAPIGetAccountKey()
Description | Shortcut function to simply obtaining a account key for a given AccountId. Defaults to the user's primary account. |
Use | Worksheet cells, VBA. |
Arguments | Type | Description | Example |
---|---|---|---|
AccountId | String | Optional: AccountId for the requested account. | "101234_USD" |
OpenAPIGetAccountList()
Description | Shortcut function to simply obtaining a list of accounts for a given ClientKey. Defaults to the ClientKey of the logged-in user. |
Use | Worksheet cells only. |
Arguments | Type | Description | Example |
---|---|---|---|
ClientKey | String | Optional: ClientKey for the requested client. | "X1JAJJAsjsdTMK3mBxzd-D2UA==" |
OpenAPIGetAutoResize()
Description | GET function that resizes the output array in a worksheet automatically depending on the returned size. |
Use | Worksheet cells only. |
Arguments | Type | Description | Example |
---|---|---|---|
Request | String | Path to the OpenAPI endpoint including query string parameters. | "/openapi/ref/v1/instruments/details/?AssetTypes=FxSpot&Uics=21" |
Fields | String | List of comma-separated, case-sensitive field names to be returned from the response with full stops identifying nested fields under a specific FieldGroup. | "Description,Exchange.CountryCode,Format.OrderDecimals" |
Headers | Bool | Indicator to instruct the resize formula to include a header row containing the field names of the requested fields. | TRUE |
OpenAPIGetClientKey()
Description | Shortcut function to simplify obtaining the ClientKey of the current logged-in user. |
Use | Worksheet cells, VBA. |
OpenAPIGetContextId()
Description | Shortcut function to simplify obtaining the ConextId of the current session (used internally for subscription functionality). |
Use | Worksheet cells, VBA. |
OpenAPIRefreshCurrentSheetFormula()
Description | Function that refreshes all OpenAPI and Excel formulas on the current sheet. Similar to how the Refresh button in the OpenAPI ribbon refreshes all cells. |
Use | Worksheet cells, VBA. |
OpenAPIRefreshFormula()
Description | Function that refreshes all OpenAPI and Excel formulas across every sheet in the workbook. Similar to how the Refresh button in the OpenAPI ribbon refreshes all cells. |
Use | Worksheet cells, VBA. |