Portfolios

Retrieves a portfolio or a list of portfolios.


Endpoints

Retrieve a Portfolio Object

Parameters

api_key string required
Your authentication key needed to make requests.


format string default: json
Defines return format of response. Options are json or csv. Default is json.

Example Request

cURL
curl -X GET "https://sensaai.com/data/v1/portfolios/332?api_key=API_KEY"
Python
import requests

url = "https://sensaai.com/data/v1/portfolios/332/"
params = {
 "api_key": "API_KEY"  # Replace 'API_KEY' with your actual API key
}

response = requests.get(url, params=params)

if response.status_code == 200:
 data = response.json()
 print(data)
else:
 print(f"Request failed with status code {response.status_code}")
JavaScript
const https = require('https');

const url = "https://sensaai.com/data/v1/portfolios/332/";
const params = {
api_key: "API_KEY", // Replace 'API_KEY' with your actual API key
};

const requestUrl = new URL(url);
requestUrl.search = new URLSearchParams(params);

https.get(requestUrl, (response) => {
let data = '';

response.on('data', (chunk) => {
  data += chunk;
});

response.on('end', () => {
  if (response.statusCode === 200) {
    console.log(data);
  } else {
    console.error(`Request failed with status code ${response.statusCode}`);
  }
});
});

Response

Returns a portfolio object if a valid portfolio ID was provided. Returns an error otherwise.

{
  "id": "332",
  "owner": {
    "id": "1"
  },
  "name": "Quality - Top 50",
  "description": "This portfolio consists of the top 50 stocks with an above 7 rating for Return, Growth and Risk. Portfolio is rebalanced once a quarter.",
  "private": false,
  "createdAt": "2020-06-21T16:17:38.893462+00:00",
  "rebalanceFrequency": 3,
  "maxStocks": 50,
  "maxStocksCriteria": "total_rating",
  "maxStocksCriteriaOrder": "descending",
  "maxSectorConcentration": "1.00",
  "nextRebalanceDate": "2021-01-02",
  "previousRebalanceDate": "2020-10-02",
  "ranges": {
    "returnRating": [
      7.0,
      10.0
    ],
    "growthRating": [
      7.0,
      10.0
    ],
    "riskRating": [
      7.0,
      10.0
    ]
  }
}

Retrieve a List of Portfolio Objects

Parameters

api_key string required
Your authentication key needed to make requests.


format string default: json
Defines return format of response. Options are json or csv. Default is json.

Example Request

cURL
curl -X GET "https://sensaai.com/data/v1/portfolios/?api_key=API_KEY"
Python
import requests

url = "https://sensaai.com/data/v1/portfolios/"
params = {
 "api_key": "API_KEY"  # Replace 'API_KEY' with your actual API key
}

response = requests.get(url, params=params)

if response.status_code == 200:
 data = response.json()
 print(data)
else:
 print(f"Request failed with status code {response.status_code}")
JavaScript
const https = require('https');

const url = 'https://sensaai.com/data/v1/portfolios/';
const params = {
api_key: 'API_KEY', // Replace 'API_KEY' with your actual API key
};

const requestUrl = new URL(url);
requestUrl.search = new URLSearchParams(params);

https.get(requestUrl, (response) => {
let data = '';

response.on('data', (chunk) => {
  data += chunk;
});

response.on('end', () => {
  if (response.statusCode === 200) {
    console.log(data);
  } else {
    console.error(`Request failed with status code ${response.statusCode}`);
  }
});
});

Response

[
  {
    "id": "323",
    "owner": {
      "id": "1"
    },
    "name": "All Stocks Top 50",
    "description": "This portfolio contains the top 50 rated stocks in the SensaAI universe and is rebalanced once a quarter.",
    "private": true,
    "createdAt": "2020-06-02T22:52:14.495073+00:00",
    "rebalanceFrequency": 3,
    "maxStocks": 50,
    "maxStocksCriteria": "total_rating",
    "maxStocksCriteriaOrder": "descending",
    "maxSectorConcentration": "1.00",
    "nextRebalanceDate": "2020-12-01",
    "previousRebalanceDate": "2020-09-01",
    "ranges": {
      
    }
  },
    ...more portfolios
]