Uploading Portfolios via the API

Learn how to upload position sets to portfolios

Edgar Nuñez avatar
Written by Edgar Nuñez
Updated over a week ago

You can use the API to add or remove daily position sets for portfolios in your account. For more information on position sets, please see the article on Using Position Sets. This article will walk you through the steps to upload a position set to a portfolio, review the results, and delete position sets from the portfolio for a particular date range.

To read about uploading portfolio data via the application, please read Upload Positions to a Portfolio.

Portfolio ID

When running your own requests, please be sure to replace the portfolio ID with an appropriate ID from your own account. If you're not familiar with how to obtain a portfolio ID, please see the article on Requesting Portfolios.

Uploading a Position Set

A position set can be uploaded for single date per API request. Note that position sets do not need to be uploaded for subsequent days without trades, as our system will automatically adjust the position sizes based on the daily returns of all equities in the model.

Below is an example of how to structure a request to upload a position set, with variables set for date 2017-06-01, holding $500 in Microsoft and $1000 in Apple, $10 in a custom basket with ticker MY_BASKET, $100 in cash (US dollars), as well as $10 in some other asset that is not covered by the model, with identifier ASSET_ID:

Mutation

mutation($portfolioId: String!, $modelId: String!, $data: PositionSetDateInput!) {
  uploadPositionSetDate(portfolioId: $portfolioId, data: $data) {
    coverage(modelId: $modelId) {
date
summary {
percentGmvAvailable
percentGmvNotAvailable
}
missingEquities {
id {
ticker
mic
sedol
}
percentGmv
}
missingSwaps {
id
percentGmv
}
missingCurrencies {
id
percentGmv
}
}
  }
}

Variables

{
  "portfolioId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "modelId": "xxxxx-xx",
  "data": {
    "date": "2017-06-01",
    "equities": [
      {
        "id": {"ticker": "MSFT", "mic": "XNAS"},
        "economicExposure": 500
      }, {
        "id": {"ticker": "AAPL", "mic": "XNAS"},
        "economicExposure": 3000,
"lotId": "AAPL_3000"
      }, {
"id": {"ticker": "AAPL", "mic": "XNAS"},
"economicExposure": 1000,
"lotId": "AAPL_1000"
}
    ],
"swaps": [
{
"id": "MY_BASKET",
"economicExposure": 10
}
],
"currencies": [
{
"id": "USD",
"economicExposure": 100
}
],
"otherAssets": [
{
"id": "ASSET_ID",
"economicExposure": 10
}
]
  }
}

A few notes:

  • To provide a custom equity value, the optional equity key can be set with the override value of the position set.

  • lotId on a particular position helps distinguish one purchase from another, and enables the ability to assign different 'tags' to each lot. In the case above, AAPL is listed twice and differentiated with its unique lotId.

  • Swaps are previously registered baskets and are provided in a position set under the corresponding "swaps" array, as referenced by the ID used to register the basket.

  • A currencies array is used to list cash positions using their ISO-4217 3-letter currency code as the ID and a weight (“economicExposure”) of each currency.

  • More information about how to correctly format a position set can be found at Using Positions Sets.

Coverage Report

Note the “coverage” section of the query:

...
    coverage (modelId: $modelId) {
      date
      summary {
        percentGmvAvailable
        percentGmvNotAvailable
      }
      missingEquities {
        id {
          ticker
          mic
          sedol
        }
        percentGmv
      }
missingSwaps {
id
percentGmv
}
missingCurrencies {
id
percentGmv
}
    }
...

This sets up the request to return a coverage report following the upload, letting you know which securities were successfully or unsuccessfully mapped, given the specified data model. In the summary section, percentGmvAvailable provides the percent GMV over all available positions in the position set; whereas percentGmvNotAvailable lets you know the percent GMV over all missing positions in the position set. The missing equities will list the unsuccessfully mapped securities and their sizes as a percentage of the GMV.

Request the Position Set

To verify the position set was uploaded to your portfolio, you can use the following:

Query

query($portfolioId: String!, $date: Date!) {
  portfolio (id: $portfolioId) {
    name
    dates (from: $date, to: $date) {
      date
      equities {
        id {
          ticker
          mic
          sedol
        }
economicExposure
lotId
      }
    }
  }
}

Variables

{
  "portfolioId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "date": "2017-06-01"
}

Deleting Position Sets

To remove position sets from the portfolio, you can use the following:

Mutation

mutation ($portfolioId: String!, $dates: [Date]!) {
  deletePositionSetDates($portfolioId, $dates) {
    count
  }
}

Variables

{
  "portfolioId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "dates": [
    "2017-06-01",
    "2017-06-02",
    "2017-06-05"
  ]
}

The count request in the query will let you know the number of dates of data successfully deleted from the portfolio.

Did this answer your question?