Stock Metrics

Retrieves performance metrics for a stock.


Endpoint

GET/data/v1/stock_metrics/:ticker

Parameters

api_key string required
Your authentication key needed to make requests.


benchmark int
ID of benchmark portfolio. To retrieve all available benchmarks including their ids please refer to Benchmarks endpoint.


period float
Defines period of returns in years from latest available date. By default metrics provided for longest possible period available.


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/stock_metrics/mmm?api_key=API_KEY"
Python
import requests

url = "https://sensaai.com/data/v1/stock_metrics/mmm/"
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/stock_metrics/mmm/";
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 list of performance metrics if a stock ticker was provided. Returns an error otherwise.

[
  {
    "metric": "Start Period",
    "MMM": "2000-01-03"
  },
  {
    "metric": "End Period",
    "MMM": "2023-10-19"
  },
  {
    "metric": "Risk-Free Rate ",
    "MMM": "0.0%"
  },
  {
    "metric": "Cumulative Return ",
    "MMM": "251.62%"
  },
  {
    "metric": "CAGR﹪",
    "MMM": "5.42%"
  },
  {
    "metric": "Sharpe",
    "MMM": "0.34"
  },
    ...more metrics
]