Backtest a portfolio of companies
curl --request POST \
--url https://api.noonum.ai/v2/backtest \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"holdings": [
{
"companyId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"weight": 0.5
}
],
"years": 5,
"benchmark": "SPY"
}
'import requests
url = "https://api.noonum.ai/v2/backtest"
payload = {
"holdings": [
{
"companyId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"weight": 0.5
}
],
"years": 5,
"benchmark": "SPY"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
holdings: [{companyId: '3c90c3cc-0d44-4b50-8888-8dd25736052a', weight: 0.5}],
years: 5,
benchmark: 'SPY'
})
};
fetch('https://api.noonum.ai/v2/backtest', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.noonum.ai/v2/backtest"
payload := strings.NewReader("{\n \"holdings\": [\n {\n \"companyId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"weight\": 0.5\n }\n ],\n \"years\": 5,\n \"benchmark\": \"SPY\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"metadata": {
"returns": 0.7955,
"annualizedReturn": 0.1242,
"variance": 0.1637,
"sharpeRatio": 0.76,
"maxDrawdown": -0.2747,
"stockCount": 20,
"weekCount": 260,
"warnings": [
"<string>"
]
},
"timeSeries": [
[
1594339200,
10000
],
[
1594944000,
10156.8
]
],
"benchmarkMetadata": {
"symbol": "SPY",
"returns": 0.6512,
"annualizedReturn": 0.1058,
"variance": 0.1423,
"sharpeRatio": 0.74,
"maxDrawdown": -0.2385
},
"benchmarkTimeSeries": [
[
1594339200,
10000
],
[
1594944000,
10089.5
]
]
}Backtest
Backtest a portfolio of companies
Accepts a list of company IDs with weights, resolves each to a tradeable security, fetches historical price data, and computes a buy-and-hold NAV series and statistics over the requested period.
POST
/
backtest
Backtest a portfolio of companies
curl --request POST \
--url https://api.noonum.ai/v2/backtest \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"holdings": [
{
"companyId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"weight": 0.5
}
],
"years": 5,
"benchmark": "SPY"
}
'import requests
url = "https://api.noonum.ai/v2/backtest"
payload = {
"holdings": [
{
"companyId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"weight": 0.5
}
],
"years": 5,
"benchmark": "SPY"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
holdings: [{companyId: '3c90c3cc-0d44-4b50-8888-8dd25736052a', weight: 0.5}],
years: 5,
benchmark: 'SPY'
})
};
fetch('https://api.noonum.ai/v2/backtest', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.noonum.ai/v2/backtest"
payload := strings.NewReader("{\n \"holdings\": [\n {\n \"companyId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"weight\": 0.5\n }\n ],\n \"years\": 5,\n \"benchmark\": \"SPY\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"metadata": {
"returns": 0.7955,
"annualizedReturn": 0.1242,
"variance": 0.1637,
"sharpeRatio": 0.76,
"maxDrawdown": -0.2747,
"stockCount": 20,
"weekCount": 260,
"warnings": [
"<string>"
]
},
"timeSeries": [
[
1594339200,
10000
],
[
1594944000,
10156.8
]
],
"benchmarkMetadata": {
"symbol": "SPY",
"returns": 0.6512,
"annualizedReturn": 0.1058,
"variance": 0.1423,
"sharpeRatio": 0.74,
"maxDrawdown": -0.2385
},
"benchmarkTimeSeries": [
[
1594339200,
10000
],
[
1594944000,
10089.5
]
]
}Authorizations
Enter 'Bearer' followed by a space and then your JWT or API Key.
Example: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
or Bearer YOUR_API_KEY_HERE
Body
application/json
Response
Backtest results
Performance statistics for the portfolio.
Show child attributes
Show child attributes
Portfolio NAV points, each given as [unix_seconds, nav], starting at 10000.
Example:
[[1594339200, 10000], [1594944000, 10156.8]]
Performance statistics for the benchmark.
Show child attributes
Show child attributes
Benchmark price series rebased to 10000 and aligned to the portfolio dates.
Example:
[[1594339200, 10000], [1594944000, 10089.5]]
Was this page helpful?