The Portfolio Creation & Modification API makes it easy to generate portfolio containers that can be used to visualize strategies you are evaluating. This API triggers the creation of a portfolio, and a subsequent request to upload portfolio will populate this newly created portfolio.

This feature also provides basic portfolio management and configurations, including modifying existing portfolio properties, such as alias, name, defaultModelId, etc.

API: Portfolio Creation

The portfolio creation node — mutation.createPortfolio — receives requests in the following format & with these required properties:

mutation{
  createPortfolio(
    portfolio: {
      name: "Example Portfolio",
      defaultModelId: "exampleModelID"
    }) {
      id
      name
      defaultModelId
      alias
    }
}

In the above example, the properties were passed in to the mutation.createPortfolio node as a portfolio object. These properties include:

  • name, which can be any 3-50 character long value that only uses alphanumerics, whitespaces, underscores, or dashes.
  • defaultModelId, which accepts an ID of a model.

A successful request returns the newly created portfolio with the requested properties. From our example above, this request includes id, name, defaultModelId, & alias:

{
  "data": {
    "createPortfolio": {
      "id": "********-****-****-****-123a4b05cddd",
      "name": "Example Portfolio",
      "defaultModelId: "exampleModelID",
      "alias": "example_portfolio"
    }
  }
}

Since an alias wasn't specified in the original request, the API auto-generates an alias from the provided name, e.g. 

"name": "Example Portfolio" ==> "alias": "example_portfolio"

Optional properties for portfolios

Optional properties, such as alias, are used to configure the portfolio. In this below example, we pass in the properties as a mutation with query variables:

mutation

mutation($portfolio: NewPortfolio!){
  createPortfolio(portfolio: $portfolio){
    id
    name
    alias
    rolloverPositionSetToCurrentDate
}

query variables

{
  "portfolio": {
    "name": "example portfolio",
    "defaultModelId": "exampleModelID",
    "alias": "myPortfolio",
    "rolloverPositionSetToCurrentDate": true
  }
}


This portfolio creation request includes the following optional properties:

  • alias is the shorthand name of the portfolio that can be used for in lieu of its computer-generated ID. This field should be unique to the account, meaning no other portfolio can have this alias, and can only include lowercase alphanumeric characters and underscores.
    Please note: If no alias is provided, the platform automatically generates an alias that closely matches the requested portfolio name, as seen in the first example above.
  • rolloverPositionSetToCurrentDate is a configuration that tells the application to roll forward the most recent uploaded positions to the current date. This is useful for backtesting, where it is possible to upload one date of positions to any date and the platform will roll use the market returns of the securities to adjust the weights of the positions going forward. If not specified in the API request, this defaults to "true."

API: Portfolio Update

In addition to portfolio creation, the API also offers a mutation.updatePortfolio node that modifies a portfolio's properties (however, portfolio.id is non-modifiable). This request will change the properties of specified portfolio to what is passed in

mutation

mutation($id: String!, $portfolio: PortfolioUpdate!){
  updatePortfolio(id:$id, portfolio: $portfolio){
    name
    id
    defaultModelId
    alias
    rolloverPositionSetToCurrentDate
  }
}

query variables

{
  "id": "********-****-****-****-123a4b05cddd",
  "portfolio": {
    "name": "Updated Name",
    "defaultModelId": "AXWW4-SH",
    "alias": "updated_name",
    "rolloverPositionSetToCurrentDate": false
  }
}

Upon a successful request, the mutation.updatePortfolio node will return

{
  "data": {
    "updatePortfolio": {
      "name": "Updated Name",
      "id": "********-****-****-****-123a4b05cddd",
      "defaultModelId": "AXWW4-SH",
      "alias": "updated_name",
      "rolloverPositionSetToCurrentDate": false
    }
  }
}

API: Portfolio Deletion 

To conclude the portfolio CRUD workflow, portfolio deletion is available using the API node -- mutation.deletePortfolio(id: String!)

mutation{
  deletePortfolio(id: "insertPortfolioIdOrAliasHere"){
    ok
  }
}

This request schedules the portfolio to be deleted and will hide the portfolio from available portfolios. Please contact [email protected] if deleting this portfolio was done in error. Note that portfolios cannot be retrieved after 14 days after deletion.

Did this answer your question?