How do I create a custom data model?

Prev Next

You can create a custom data model (CDM) for a supported entity type to control the behaviour of entities of that type (all of them or a subset).

A CDM can be standalone, or part of a hierarchy with parents and children of its own. Work through a tutorial.

With a CDM in place, you can create entities under (that is, in the context of) the CDM in order to enforce the requirements. If you have existing entities created separately, you can optionally induct them in order to enforce the requirements going forward.

Methods

Call the CreateCustomDataModel API and specify a supported entity type as a parameter in the URL, for example:

curl -X POST 'https://<your-domain>.lusid.com/api/api/datamodel/Instrument'
  -H 'Content-Type: application/json-patch+json' 
  -H 'Authorization: Bearer <your-API-access-token>'
  -d '{
  "id": {
    "scope": "CDMs",
    "code": "Equity"
  },
  "displayName": "Equity instruments",
  "description": "CDM controlling the behaviour of equities",
  "parentDataModel": {
    "scope": "CDMs",
    "code": "All"
  },
  "conditions": "InstrumentDefinition.InstrumentType eq 'Equity'",
  "properties": [
    {
      "propertyKey": "Instrument/MyProperties/ExchangeCode",
      "required": true
    }
  ],
  "identifierTypes": [
    {
      "identifierKey": "Instrument/default/Isin",
      "required": true
    }
  ],
  "attributeAliases": [
    {
      "attributeName": "Instrument/MyProperties/ExchangeCode",
      "attributeAlias": "Exchange"
    }
  ],
  "recommendedSortBy": [
    {
      "attributeName": "Name",
      "sortOrder": "ASC"
    }
  ],
  "supplementalPropertyKeys": ["Portfolio/MyProperties/ManagerName"]
}'

Navigate to Data Management > Custom Data Models and select a supported entity type:

Right-click the chosen widget and select Add child:

Complete the New data model dialog:

Coming soon

Request fields

This section supplements the API documentation and on-screen help text in the LUSID web app.

A CDM:

  • Must have a scope and a code that together uniquely identify it.

  • Must have a displayName and can have a description.

  • Can have a parentDataModel, identified by its scope and code. Note a CDM inherits every attribute of its parent (all the following points), so there is no need to specify these again.

  • Can have conditions that use LUSID filter syntax to restrict applicability to a subset of entities.

  • Can specify a set of allowed identifierTypes for entities that support market or user-defined identifiers (such as Instrument), and optionally make values required. No other identifiers can be added to entities.

  • Can specify a set of allowed properties, and optionally make values required. No other properties can be added to entities. Note you can use a wildcard expression to match multiple properties, for example Instrument/MyProperties/* (though these cannot be made required, so users are not forced to enter values).

  • Can specify a set of attributeAliases to give fields, identifiers and properties more intuitive names in LUSID web app dashboards.

  • Can specify an ordered set of fields, identifiers and properties to recommendedSortBy in LUSID web app dashboards.

  • Can specify a set of supplementalPropertyKeys. These are automatically returned in LUSID web app dashboards, to reduce the need for dashboard configuration.

Subsequent updates

You can call the UpdateCustomDataModel to update any aspect of an existing CDM. Note any fields omitted in the request are removed; there is no patch facility. To delete a CDM, call the DeleteCustomDataModel API.