https://www.brainiac.software/api/v1/portfolio-analytics/performance-twr-mwr$0.04 USDCTime-weighted and money-weighted returns
Compute linked TWR, Modified Dietz and XIRR from valuations and external cash flows, with optional annualisation.
Body
| Field | Required | Notes |
|---|---|---|
valuations | Yes | array; Array |
flows | No | array; Default: []; Array |
annualize | No | boolean; Default: false |
Request exampleJSON
{
"valuations": [
{
"date": "2026-01-01",
"value": 100000
},
{
"date": "2026-07-02",
"value": 105000,
"beforeFlow": true
},
{
"date": "2027-01-01",
"value": 120000
}
],
"flows": [
{
"date": "2026-07-02",
"amount": 10000
}
],
"annualize": true
}Response exampleJSON
{
"twr": 0.09565217391304359,
"modifiedDietz": 0.09522567179754761,
"xirr": 0.09532897919588461,
"days": 365,
"subPeriods": [
{
"from": "2026-01-01",
"to": "2026-07-02",
"return": 0.050000000000000044
},
{
"from": "2026-07-02",
"to": "2027-01-01",
"return": 0.04347826086956519
}
],
"status": "ok",
"sources": [
{
"source": "Caller-supplied holdings, returns, valuations and transactions processed locally",
"url": "https://www.brainiac.software/api/v1/portfolio-analytics",
"retrievedAt": "2026-11-14",
"status": "ok"
}
],
"limitations": [
"Outputs are calculations on caller-supplied inputs for human review. No market data is fetched, and this is not investm…",
"TWR links sub-period returns between external flow dates using beforeFlow valuations when provided.",
"…"
]
}cURL
curl -i -X POST "https://www.brainiac.software/api/v1/portfolio-analytics/performance-twr-mwr" \
-H 'content-type: application/json' \
-H 'Idempotency-Key: <fresh-64-character-random-hex-key>' \
--data-binary @- <<'JSON'
{
"valuations": [
{
"date": "2026-01-01",
"value": 100000
},
{
"date": "2026-07-02",
"value": 105000,
"beforeFlow": true
},
{
"date": "2027-01-01",
"value": 120000
}
],
"flows": [
{
"date": "2026-07-02",
"amount": 10000
}
],
"annualize": true
}
JSONhttps://www.brainiac.software/api/v1/portfolio-analytics/risk-metrics$0.03 USDCVolatility, Sharpe, Sortino and drawdown
Annualised volatility, Sharpe, Sortino, Calmar, max drawdown with peak/trough/recovery indices, skewness and excess kurtosis from a return series.
Body
| Field | Required | Notes |
|---|---|---|
returns | Yes | array; Array |
periodsPerYear | No | number; Default: 12 |
riskFreePerPeriod | No | Default: 0 |
mar | No | number | null |
Request exampleJSON
{
"returns": [
0.02,
-0.01,
0.03,
-0.04,
0.015,
0.01,
-0.02,
0.025,
0.005,
-0.015,
0.03,
0.01
],
"periodsPerYear": 12,
"riskFreePerPeriod": 0.002,
"mar": null
}Response exampleJSON
{
"volatility": 0.07603826787755083,
"annualReturn": 0.05886860527185367,
"sharpe": 0.4734458188602223,
"sortino": 0.6952709657232169,
"maxDrawdown": -0.040000000000000036,
"drawdownPeakIndex": 3,
"drawdownTroughIndex": 4,
"recoveryIndex": 11,
"calmar": 1.4717151317963404,
"skewness": -0.7658791422339498,
"excessKurtosis": -0.16094695621217464,
"sources": [
{
"source": "Caller-supplied holdings, returns, valuations and transactions processed locally",
"url": "https://www.brainiac.software/api/v1/portfolio-analytics",
"retrievedAt": "2026-11-14",
"status": "ok"
}
],
"limitations": [
"Outputs are calculations on caller-supplied inputs for human review. No market data is fetched, and this is not investm…",
"Volatility, Sharpe and Sortino use the sample standard deviation; Sortino downside deviation averages squared losses ov…",
"…"
]
}cURL
curl -i -X POST "https://www.brainiac.software/api/v1/portfolio-analytics/risk-metrics" \
-H 'content-type: application/json' \
-H 'Idempotency-Key: <fresh-64-character-random-hex-key>' \
--data-binary @- <<'JSON'
{
"returns": [
0.02,
-0.01,
0.03,
-0.04,
0.015,
0.01,
-0.02,
0.025,
0.005,
-0.015,
0.03,
0.01
],
"periodsPerYear": 12,
"riskFreePerPeriod": 0.002,
"mar": null
}
JSONhttps://www.brainiac.software/api/v1/portfolio-analytics/var-cvar$0.04 USDCValue-at-Risk and Expected Shortfall
Historical, parametric normal and Monte Carlo VaR/ES at caller confidence levels from a return series.
Body
| Field | Required | Notes |
|---|---|---|
returns | Yes | array; Array |
confidence | Yes | array; Array |
methods | No | array; Default: ["historical","parametric","monte_carlo"]; Array |
portfolioValue | No | number |
horizonPeriods | No | integer; Default: 1 |
simulations | No | integer; Default: 10000 |
seed | No | integer; Default: 42 |
Request exampleJSON
{
"returns": [
-0.031,
0.012,
-0.008,
0.022,
-0.045,
0.005,
0.017,
-0.012,
0.009,
-0.021,
0.014,
-0.002,
0.026,
-0.018,
0.003,
0.011,
-0.027,
0.007,
0.019,
-0.006
],
"confidence": [
0.9,
0.95
],
"methods": [
"historical",
"parametric",
"monte_carlo"
],
"portfolioValue": 1000000,
"horizonPeriods": 1,
"simulations": 10000,
"seed": 42
}Response exampleJSON
{
"results": [
{
"method": "historical",
"confidence": 0.9,
"var": 0.031,
"es": 0.038,
"varAmount": 31000
},
{
"method": "parametric",
"confidence": 0.9,
"var": 0.026078892030377016,
"es": 0.03525120030116119,
"varAmount": 26078.892030377017
},
"…"
],
"sources": [
{
"source": "Caller-supplied holdings, returns, valuations and transactions processed locally",
"url": "https://www.brainiac.software/api/v1/portfolio-analytics",
"retrievedAt": "2026-11-14",
"status": "ok"
}
],
"limitations": [
"Outputs are calculations on caller-supplied inputs for human review. No market data is fetched, and this is not investm…",
"VaR and ES are positive loss fractions. Historical uses order statistics; parametric and Monte Carlo use the sample mea…",
"…"
]
}cURL
curl -i -X POST "https://www.brainiac.software/api/v1/portfolio-analytics/var-cvar" \
-H 'content-type: application/json' \
-H 'Idempotency-Key: <fresh-64-character-random-hex-key>' \
--data-binary @- <<'JSON'
{
"returns": [
-0.031,
0.012,
-0.008,
0.022,
-0.045,
0.005,
0.017,
-0.012,
0.009,
-0.021,
0.014,
-0.002,
0.026,
-0.018,
0.003,
0.011,
-0.027,
0.007,
0.019,
-0.006
],
"confidence": [
0.9,
0.95
],
"methods": [
"historical",
"parametric",
"monte_carlo"
],
"portfolioValue": 1000000,
"horizonPeriods": 1,
"simulations": 10000,
"seed": 42
}
JSONhttps://www.brainiac.software/api/v1/portfolio-analytics/brinson-attribution$0.04 USDCBrinson-Fachler attribution
Allocation, selection and interaction effects by segment for one or more periods, with optional Carino linking.
Body
| Field | Required | Notes |
|---|---|---|
periods | Yes | array; Array |
linking | No | string; One of: carino, none; Default: "carino" |
normalizeWeights | No | boolean; Default: true |
allowNegativeWeights | No | boolean; Default: false |
Request exampleJSON
{
"periods": [
{
"segments": [
{
"name": "Equity",
"wp": 0.5,
"wb": 0.4,
"rp": 0.1,
"rb": 0.08
},
{
"name": "Bonds",
"wp": 0.3,
"wb": 0.4,
"rp": 0.04,
"rb": 0.05
},
{
"name": "Cash",
"wp": 0.2,
"wb": 0.2,
"rp": 0.02,
"rb": 0.03
}
]
}
],
"linking": "carino",
"normalizeWeights": true
}Response exampleJSON
{
"portfolioReturn": 0.066,
"benchmarkReturn": 0.058,
"activeReturn": 0.008,
"segments": [
{
"name": "Equity",
"allocation": 0.0021999999999999993,
"selection": 0.008000000000000002,
"interaction": 0.002
},
{
"name": "Bonds",
"allocation": 0.0008000000000000003,
"selection": -0.004000000000000001,
"interaction": 0.0010000000000000005
},
"…"
],
"totals": {
"allocation": 0.0029999999999999996,
"selection": 0.0020000000000000013,
"interaction": 0.0030000000000000005
},
"sources": [
{
"source": "Caller-supplied holdings, returns, valuations and transactions processed locally",
"url": "https://www.brainiac.software/api/v1/portfolio-analytics",
"retrievedAt": "2026-11-14",
"status": "ok"
}
],
"limitations": [
"Outputs are calculations on caller-supplied inputs for human review. No market data is fetched, and this is not investm…",
"Brinson-Fachler single-period effects: allocation (wp−wb)(rb−Rb), selection wb(rp−rb), interaction (wp−wb)(rp−rb)."
]
}cURL
curl -i -X POST "https://www.brainiac.software/api/v1/portfolio-analytics/brinson-attribution" \
-H 'content-type: application/json' \
-H 'Idempotency-Key: <fresh-64-character-random-hex-key>' \
--data-binary @- <<'JSON'
{
"periods": [
{
"segments": [
{
"name": "Equity",
"wp": 0.5,
"wb": 0.4,
"rp": 0.1,
"rb": 0.08
},
{
"name": "Bonds",
"wp": 0.3,
"wb": 0.4,
"rp": 0.04,
"rb": 0.05
},
{
"name": "Cash",
"wp": 0.2,
"wb": 0.2,
"rp": 0.02,
"rb": 0.03
}
]
}
],
"linking": "carino",
"normalizeWeights": true
}
JSONhttps://www.brainiac.software/api/v1/portfolio-analytics/factor-regression$0.04 USDCFactor regression of excess returns
OLS of portfolio excess returns on caller-supplied factors with intercept, betas, alpha and optional Newey-West standard errors.
Body
| Field | Required | Notes |
|---|---|---|
returns | Yes | array; Array |
riskFree | No | Default: 0 |
factors | Yes | object |
periodsPerYear | No | number; Default: 12 |
neweyWestLags | No | integer; Default: 0 |
Request exampleJSON
{
"returns": [
0.025,
-0.012,
0.035,
-0.045,
0.018,
0.012,
-0.021,
0.028,
0.007,
-0.016,
0.033,
0.013
],
"riskFree": [
0.002,
0.002,
0.002,
0.002,
0.002,
0.002,
0.002,
0.002,
0.002,
0.002,
0.002,
0.002
],
"factors": {
"MKT_RF": [
0.02,
-0.01,
0.03,
-0.04,
0.015,
0.01,
-0.02,
0.025,
0.005,
-0.015,
0.03,
0.01
],
"SMB": [
0.005,
0.002,
-0.003,
0.004,
-0.001,
0,
0.003,
-0.002,
0.001,
0.002,
-0.004,
0.001
],
"HML": [
-0.002,
0.003,
0.001,
-0.004,
0.002,
0.001,
-0.001,
0,
0.003,
-0.002,
0.001,
0.002
]
},
"periodsPerYear": 12,
"neweyWestLags": 0
}Response exampleJSON
{
"alphaPerPeriod": -0.0016174328233197332,
"alphaAnnualized": -0.01923745952752709,
"betas": [
{
"factor": "MKT_RF",
"beta": 1.160864263661775,
"se": 0.017006267834078596
},
{
"factor": "SMB",
"beta": 0.3452662232048083,
"se": 0.13645405346721115
},
"…"
],
"alphaSe": 0.0002994694423945589,
"rSquared": 0.9991221247271498,
"n": 12,
"sources": [
{
"source": "Caller-supplied holdings, returns, valuations and transactions processed locally",
"url": "https://www.brainiac.software/api/v1/portfolio-analytics",
"retrievedAt": "2026-11-14",
"status": "ok"
}
],
"limitations": [
"Outputs are calculations on caller-supplied inputs for human review. No market data is fetched, and this is not investm…",
"OLS of excess returns on caller-supplied factors with intercept via Householder QR. Alpha is annualised as (1+α)^P−1.",
"…"
]
}cURL
curl -i -X POST "https://www.brainiac.software/api/v1/portfolio-analytics/factor-regression" \
-H 'content-type: application/json' \
-H 'Idempotency-Key: <fresh-64-character-random-hex-key>' \
--data-binary @- <<'JSON'
{
"returns": [
0.025,
-0.012,
0.035,
-0.045,
0.018,
0.012,
-0.021,
0.028,
0.007,
-0.016,
0.033,
0.013
],
"riskFree": [
0.002,
0.002,
0.002,
0.002,
0.002,
0.002,
0.002,
0.002,
0.002,
0.002,
0.002,
0.002
],
"factors": {
"MKT_RF": [
0.02,
-0.01,
0.03,
-0.04,
0.015,
0.01,
-0.02,
0.025,
0.005,
-0.015,
0.03,
0.01
],
"SMB": [
0.005,
0.002,
-0.003,
0.004,
-0.001,
0,
0.003,
-0.002,
0.001,
0.002,
-0.004,
0.001
],
"HML": [
-0.002,
0.003,
0.001,
-0.004,
0.002,
0.001,
-0.001,
0,
0.003,
-0.002,
0.001,
0.002
]
},
"periodsPerYear": 12,
"neweyWestLags": 0
}
JSONhttps://www.brainiac.software/api/v1/portfolio-analytics/mean-variance-optimize$0.05 USDCMarkowitz mean-variance optimisation
Minimum variance, target return, max Sharpe or target volatility portfolios from expected returns and a covariance matrix, with bounds.
Body
| Field | Required | Notes |
|---|---|---|
assets | Yes | array; Array |
expectedReturns | Yes | array; Array |
covariance | No | array; Array |
returns | No | array; Array |
objective | Yes | string; One of: min_variance, target_return, max_sharpe, target_volatility |
targetReturn | No | number |
targetVolatility | No | number |
riskFree | No | number; Default: 0 |
bounds | No | object; Default: {"min":0,"max":1}; Object |
groups | No | array; Default: []; Array |
frontierPoints | No | integer; Default: 0 |
shrinkage | No | string; One of: none, ledoit_wolf; Default: "none" |
Request exampleJSON
{
"assets": [
"A",
"B",
"C"
],
"expectedReturns": [
0.06,
0.08,
0.1
],
"covariance": [
[
0.01,
0.0045,
0.004
],
[
0.0045,
0.0225,
0.012
],
[
0.004,
0.012,
0.04
]
],
"objective": "target_return",
"targetReturn": 0.08,
"riskFree": 0.02,
"bounds": {
"min": 0,
"max": 1
},
"groups": [],
"frontierPoints": 0,
"shrinkage": "none"
}Response exampleJSON
{
"weights": [
{
"asset": "A",
"weight": 0.34756097560975596
},
{
"asset": "B",
"weight": 0.3048780487804878
},
"…"
],
"expectedReturn": 0.07999999999999999,
"volatility": 0.11222527431520025,
"sharpe": 0.5346389248422032,
"activeConstraints": [],
"status": "optimal",
"sources": [
{
"source": "Caller-supplied holdings, returns, valuations and transactions processed locally",
"url": "https://www.brainiac.software/api/v1/portfolio-analytics",
"retrievedAt": "2026-11-14",
"status": "ok"
}
],
"limitations": [
"Outputs are calculations on caller-supplied inputs for human review. No market data is fetched, and this is not investm…",
"Mean-variance uses an active-set quadratic programme on the covariance; unconstrained solutions match the analytic Σ⁻¹ …"
]
}cURL
curl -i -X POST "https://www.brainiac.software/api/v1/portfolio-analytics/mean-variance-optimize" \
-H 'content-type: application/json' \
-H 'Idempotency-Key: <fresh-64-character-random-hex-key>' \
--data-binary @- <<'JSON'
{
"assets": [
"A",
"B",
"C"
],
"expectedReturns": [
0.06,
0.08,
0.1
],
"covariance": [
[
0.01,
0.0045,
0.004
],
[
0.0045,
0.0225,
0.012
],
[
0.004,
0.012,
0.04
]
],
"objective": "target_return",
"targetReturn": 0.08,
"riskFree": 0.02,
"bounds": {
"min": 0,
"max": 1
},
"groups": [],
"frontierPoints": 0,
"shrinkage": "none"
}
JSONhttps://www.brainiac.software/api/v1/portfolio-analytics/risk-parity-weights$0.04 USDCEqual-risk-contribution and inverse-volatility weights
Spinu ERC (or caller risk-budget) weights and inverse-volatility weights with risk-contribution breakdown.
Body
| Field | Required | Notes |
|---|---|---|
assets | Yes | array; Array |
covariance | Yes | array; Array |
riskBudget | No | — |
method | No | string; One of: erc, inverse_volatility; Default: "erc" |
Request exampleJSON
{
"assets": [
"A",
"B",
"C"
],
"covariance": [
[
0.01,
0.0045,
0.004
],
[
0.0045,
0.0225,
0.012
],
[
0.004,
0.012,
0.04
]
],
"riskBudget": null,
"method": "erc"
}Response exampleJSON
{
"weights": [
0.47817014333330193,
0.29216033634018823,
"…"
],
"riskContributions": [
0.3333333333313619,
0.33333333333466947,
"…"
],
"portfolioVolatility": 0.10031567969401549,
"inverseVolatility": [
0.4615384615384615,
0.3076923076923077,
"…"
],
"iterations": 19,
"converged": true,
"sources": [
{
"source": "Caller-supplied holdings, returns, valuations and transactions processed locally",
"url": "https://www.brainiac.software/api/v1/portfolio-analytics",
"retrievedAt": "2026-11-14",
"status": "ok"
}
],
"limitations": [
"Outputs are calculations on caller-supplied inputs for human review. No market data is fetched, and this is not investm…",
"ERC uses Spinu (2013): minimise ½yᵀΣy − Σ b_i ln y_i, then w = y/Σy."
]
}cURL
curl -i -X POST "https://www.brainiac.software/api/v1/portfolio-analytics/risk-parity-weights" \
-H 'content-type: application/json' \
-H 'Idempotency-Key: <fresh-64-character-random-hex-key>' \
--data-binary @- <<'JSON'
{
"assets": [
"A",
"B",
"C"
],
"covariance": [
[
0.01,
0.0045,
0.004
],
[
0.0045,
0.0225,
0.012
],
[
0.004,
0.012,
0.04
]
],
"riskBudget": null,
"method": "erc"
}
JSONhttps://www.brainiac.software/api/v1/portfolio-analytics/rebalance-trades$0.03 USDCRebalance trades to target weights
Compute buys and sells that restore target weights with tolerance bands, a cash buffer, minimum trade size and whole-share rounding.
Body
| Field | Required | Notes |
|---|---|---|
holdings | Yes | array; Array |
cash | No | number; Default: 0 |
targets | Yes | object |
band | No | object; Default: {"type":"absolute","value":0}; Object |
cashBuffer | No | number; Default: 0 |
minTradeValue | No | number; Default: 0 |
fractional | No | boolean; Default: false |
restricted | No | array; Default: []; Array |
Request exampleJSON
{
"holdings": [
{
"symbol": "VTI",
"quantity": 200,
"price": 250
},
{
"symbol": "BND",
"quantity": 300,
"price": 72
},
{
"symbol": "VXUS",
"quantity": 100,
"price": 60
}
],
"cash": 5000,
"targets": {
"VTI": 0.6,
"BND": 0.3,
"VXUS": 0.1
},
"band": {
"type": "absolute",
"value": 0.02
},
"cashBuffer": 0.01,
"minTradeValue": 100,
"fractional": false,
"restricted": []
}Response exampleJSON
{
"totalValue": 82600,
"investable": 81774,
"trades": [
{
"symbol": "BND",
"side": "buy",
"quantity": 33,
"value": 2376
},
{
"symbol": "VXUS",
"side": "buy",
"quantity": 29,
"value": 1740
}
],
"untouched": [
{
"symbol": "VTI",
"reason": "within_band",
"drift": 0.0053268765133172025
}
],
"cashAfter": 884,
"weightsAfter": {
"VTI": 0.6053268765133172,
"BND": 0.29026634382566585,
"VXUS": 0.0937046004842615
},
"sources": [
{
"source": "Caller-supplied holdings, returns, valuations and transactions processed locally",
"url": "https://www.brainiac.software/api/v1/portfolio-analytics",
"retrievedAt": "2026-11-14",
"status": "ok"
}
],
"limitations": [
"Outputs are calculations on caller-supplied inputs for human review. No market data is fetched, and this is not investm…",
"Sells execute first. Buys are scaled pro rata when they would breach the cash buffer. Whole-share rounding truncates to…"
]
}cURL
curl -i -X POST "https://www.brainiac.software/api/v1/portfolio-analytics/rebalance-trades" \
-H 'content-type: application/json' \
-H 'Idempotency-Key: <fresh-64-character-random-hex-key>' \
--data-binary @- <<'JSON'
{
"holdings": [
{
"symbol": "VTI",
"quantity": 200,
"price": 250
},
{
"symbol": "BND",
"quantity": 300,
"price": 72
},
{
"symbol": "VXUS",
"quantity": 100,
"price": 60
}
],
"cash": 5000,
"targets": {
"VTI": 0.6,
"BND": 0.3,
"VXUS": 0.1
},
"band": {
"type": "absolute",
"value": 0.02
},
"cashBuffer": 0.01,
"minTradeValue": 100,
"fractional": false,
"restricted": []
}
JSONhttps://www.brainiac.software/api/v1/portfolio-analytics/correlation-matrix$0.03 USDCCorrelation and Ledoit-Wolf covariance
Pearson and Spearman correlation, optional covariance, rolling windows and Ledoit-Wolf shrinkage covariance from caller series.
Body
| Field | Required | Notes |
|---|---|---|
series | Yes | object |
methods | No | array; Default: ["pearson","spearman","ledoit_wolf"]; Array |
missing | No | string; One of: pairwise, listwise; Default: "pairwise" |
rollingWindow | No | — |
Request exampleJSON
{
"series": {
"A": [
0.02,
-0.01,
0.03,
-0.04,
0.015,
0.01,
-0.02,
0.025,
0.005,
-0.015,
0.03,
0.01
],
"B": [
0.025,
-0.012,
0.035,
-0.045,
0.018,
0.012,
-0.021,
0.028,
0.007,
-0.016,
0.033,
0.013
],
"C": [
0.005,
0.002,
-0.003,
0.004,
-0.001,
0,
0.003,
-0.002,
0.001,
0.002,
-0.004,
0.001
]
},
"methods": [
"pearson",
"spearman",
"ledoit_wolf"
],
"missing": "pairwise",
"rollingWindow": null
}Response exampleJSON
{
"pairCounts": [
[
12,
12,
"…"
],
[
12,
12,
"…"
],
"…"
],
"sources": [
{
"source": "Caller-supplied holdings, returns, valuations and transactions processed locally",
"url": "https://www.brainiac.software/api/v1/portfolio-analytics",
"retrievedAt": "2026-11-14",
"status": "ok"
}
],
"limitations": [
"Outputs are calculations on caller-supplied inputs for human review. No market data is fetched, and this is not investm…",
"Pearson uses pairwise-complete observations; Spearman is Pearson on average ranks. Ledoit-Wolf uses listwise mean-centr…"
],
"pearson": [
[
1,
0.9991821892446439,
"…"
],
[
0.9991821892446439,
1,
"…"
],
"…"
],
"psd": true,
"spearman": [
[
1,
0.9964973622679556,
"…"
],
[
0.9964973622679556,
1,
"…"
],
"…"
],
"ledoitWolf": {
"shrinkage": 0.18298785245889854,
"covariance": [
[
0.00042268464205499846,
0.0004078252303142664,
"…"
],
[
0.0004078252303142664,
0.0005235118842352271,
"…"
],
"…"
]
}
}cURL
curl -i -X POST "https://www.brainiac.software/api/v1/portfolio-analytics/correlation-matrix" \
-H 'content-type: application/json' \
-H 'Idempotency-Key: <fresh-64-character-random-hex-key>' \
--data-binary @- <<'JSON'
{
"series": {
"A": [
0.02,
-0.01,
0.03,
-0.04,
0.015,
0.01,
-0.02,
0.025,
0.005,
-0.015,
0.03,
0.01
],
"B": [
0.025,
-0.012,
0.035,
-0.045,
0.018,
0.012,
-0.021,
0.028,
0.007,
-0.016,
0.033,
0.013
],
"C": [
0.005,
0.002,
-0.003,
0.004,
-0.001,
0,
0.003,
-0.002,
0.001,
0.002,
-0.004,
0.001
]
},
"methods": [
"pearson",
"spearman",
"ledoit_wolf"
],
"missing": "pairwise",
"rollingWindow": null
}
JSONhttps://www.brainiac.software/api/v1/portfolio-analytics/stress-test$0.03 USDCScenario stress test on holdings
Apply caller-defined asset-class, factor and rate shocks to holdings and report P/L by holding and in total.
Body
| Field | Required | Notes |
|---|---|---|
holdings | Yes | array; Array |
scenarios | Yes | array; Array |
Request exampleJSON
{
"holdings": [
{
"id": "VTI",
"value": 50000,
"mapping": {
"assetClass": "us_equity"
},
"betas": {
"equity": 1
}
},
{
"id": "BND",
"value": 21600,
"mapping": {
"assetClass": "bonds"
},
"duration": 6.2
}
],
"scenarios": [
{
"name": "equity -20%, rates +100bp",
"assetClassShocks": {
"us_equity": -0.2
},
"factorShocks": {},
"rateShockBp": 100
}
]
}Response exampleJSON
{
"scenarios": [
{
"name": "equity -20%, rates +100bp",
"pnl": -11339.2,
"pnlPct": -0.1583687150837989,
"byHolding": [
{
"id": "VTI",
"pnl": -10000
},
{
"id": "BND",
"pnl": -1339.2
}
],
"unmapped": []
}
],
"sources": [
{
"source": "Caller-supplied holdings, returns, valuations and transactions processed locally",
"url": "https://www.brainiac.software/api/v1/portfolio-analytics",
"retrievedAt": "2026-11-14",
"status": "ok"
}
],
"limitations": [
"Outputs are calculations on caller-supplied inputs for human review. No market data is fetched, and this is not investm…",
"Asset-class shocks take priority over factor betas. Bonds with duration apply ΔP/P = −D·Δy + ½C·Δy². Options are not re…"
]
}cURL
curl -i -X POST "https://www.brainiac.software/api/v1/portfolio-analytics/stress-test" \
-H 'content-type: application/json' \
-H 'Idempotency-Key: <fresh-64-character-random-hex-key>' \
--data-binary @- <<'JSON'
{
"holdings": [
{
"id": "VTI",
"value": 50000,
"mapping": {
"assetClass": "us_equity"
},
"betas": {
"equity": 1
}
},
{
"id": "BND",
"value": 21600,
"mapping": {
"assetClass": "bonds"
},
"duration": 6.2
}
],
"scenarios": [
{
"name": "equity -20%, rates +100bp",
"assetClassShocks": {
"us_equity": -0.2
},
"factorShocks": {},
"rateShockBp": 100
}
]
}
JSONhttps://www.brainiac.software/api/v1/portfolio-analytics/monte-carlo-goal$0.05 USDCMonte Carlo retirement or savings goal
Project a contribution/withdrawal plan with mulberry32 Monte Carlo paths and report success probability and terminal wealth percentiles.
Body
| Field | Required | Notes |
|---|---|---|
startValue | Yes | number |
years | Yes | integer |
annualContribution | No | number; Default: 0 |
annualWithdrawal | No | number; Default: 0 |
timing | No | string; One of: start, end; Default: "start" |
meanReturn | Yes | number |
volatility | Yes | number |
inflation | No | number; Default: 0 |
paths | No | integer; Default: 2000 |
seed | No | integer; Default: 42 |
percentiles | No | array; Default: [10,50,90]; Array |
Request exampleJSON
{
"startValue": 500000,
"years": 30,
"annualContribution": 0,
"annualWithdrawal": 30000,
"timing": "start",
"meanReturn": 0.05,
"volatility": 0.12,
"inflation": 0,
"paths": 2000,
"seed": 42,
"percentiles": [
10,
50,
90
]
}Response exampleJSON
{
"successProbability": 0.421,
"terminalPercentiles": {
"10": 0,
"50": 0,
"90": 896865.8322841673
},
"medianDepletionYear": 21,
"sources": [
{
"source": "Caller-supplied holdings, returns, valuations and transactions processed locally",
"url": "https://www.brainiac.software/api/v1/portfolio-analytics",
"retrievedAt": "2026-11-14",
"status": "ok"
}
],
"limitations": [
"Outputs are calculations on caller-supplied inputs for human review. No market data is fetched, and this is not investm…",
"Paths are generated sequentially with one mulberry32/Box-Muller stream in path-major order. Percentiles use linear inte…"
]
}cURL
curl -i -X POST "https://www.brainiac.software/api/v1/portfolio-analytics/monte-carlo-goal" \
-H 'content-type: application/json' \
-H 'Idempotency-Key: <fresh-64-character-random-hex-key>' \
--data-binary @- <<'JSON'
{
"startValue": 500000,
"years": 30,
"annualContribution": 0,
"annualWithdrawal": 30000,
"timing": "start",
"meanReturn": 0.05,
"volatility": 0.12,
"inflation": 0,
"paths": 2000,
"seed": 42,
"percentiles": [
10,
50,
90
]
}
JSONhttps://www.brainiac.software/api/v1/portfolio-analytics/wash-sale-detect$0.04 USDCDetect potential US wash sales
Flag IRC §1091 wash sales in caller transactions with FIFO lots, disallowed losses and replacement basis adjustments per IRS Publication 550.
Body
| Field | Required | Notes |
|---|---|---|
transactions | Yes | array; Array |
identicalGroups | No | array; Default: []; Array |
lotMethod | No | string; One of: fifo; Default: "fifo" |
Request exampleJSON
{
"transactions": [
{
"id": "t1",
"date": "2026-01-10",
"symbol": "X",
"side": "buy",
"quantity": 100,
"amount": 1000
},
{
"id": "t2",
"date": "2026-03-01",
"symbol": "X",
"side": "sell",
"quantity": 100,
"amount": 750
},
{
"id": "t3",
"date": "2026-03-20",
"symbol": "X",
"side": "buy",
"quantity": 100,
"amount": 800
}
],
"identicalGroups": [],
"lotMethod": "fifo"
}Response exampleJSON
{
"washSales": [
{
"saleId": "t2",
"replacementId": "t3",
"sharesAffected": 100,
"disallowedLoss": 250,
"replacementAdjustedBasis": 1050,
"holdingPeriodStart": "2026-01-10"
}
],
"allowedLosses": [],
"sources": [
{
"source": "IRS Publication 550 (2025), Wash Sales",
"url": "https://www.irs.gov/publications/p550",
"retrievedAt": "2026-11-14",
"status": "ok"
}
],
"limitations": [
"Outputs are calculations on caller-supplied inputs for human review. No market data is fetched, and this is not investm…",
"Implements IRS Publication 550 wash-sale matching on caller-declared identical groups with FIFO lots. Options, IRAs and…"
]
}cURL
curl -i -X POST "https://www.brainiac.software/api/v1/portfolio-analytics/wash-sale-detect" \
-H 'content-type: application/json' \
-H 'Idempotency-Key: <fresh-64-character-random-hex-key>' \
--data-binary @- <<'JSON'
{
"transactions": [
{
"id": "t1",
"date": "2026-01-10",
"symbol": "X",
"side": "buy",
"quantity": 100,
"amount": 1000
},
{
"id": "t2",
"date": "2026-03-01",
"symbol": "X",
"side": "sell",
"quantity": 100,
"amount": 750
},
{
"id": "t3",
"date": "2026-03-20",
"symbol": "X",
"side": "buy",
"quantity": 100,
"amount": 800
}
],
"identicalGroups": [],
"lotMethod": "fifo"
}
JSONhttps://www.brainiac.software/api/v1/portfolio-analytics/fee-drag-project$0.02 USDCProject long-run fee drag
Compare terminal wealth with and without expense ratios, advisory fees and loads under multiplicative or subtractive fee methods.
Body
| Field | Required | Notes |
|---|---|---|
initial | Yes | number |
annualContribution | No | number; Default: 0 |
years | Yes | integer |
grossReturn | Yes | number |
fees | No | array; Default: []; Array |
frontLoad | No | number; Default: 0 |
feeMethod | No | string; One of: multiplicative, subtractive; Default: "multiplicative" |
includeByYear | No | boolean; Default: false |
Request exampleJSON
{
"initial": 100000,
"annualContribution": 0,
"years": 30,
"grossReturn": 0.07,
"fees": [
{
"name": "expense ratio",
"rate": 0.005
},
{
"name": "advisory",
"rate": 0.01
}
],
"frontLoad": 0,
"feeMethod": "multiplicative"
}Response exampleJSON
{
"terminalNoFees": 761225.5042662045,
"terminalWithFees": 483726.90707946173,
"feeDrag": 277498.5971867428,
"feeDragPct": 0.364541907268651,
"byYear": [],
"sources": [
{
"source": "Caller-supplied holdings, returns, valuations and transactions processed locally",
"url": "https://www.brainiac.software/api/v1/portfolio-analytics",
"retrievedAt": "2026-11-14",
"status": "ok"
}
],
"limitations": [
"Outputs are calculations on caller-supplied inputs for human review. No market data is fetched, and this is not investm…",
"Multiplicative fees apply V×(1+g)×(1−Σf); subtractive fees apply V×(1+g−Σf). Front load reduces the initial amount and …"
]
}cURL
curl -i -X POST "https://www.brainiac.software/api/v1/portfolio-analytics/fee-drag-project" \
-H 'content-type: application/json' \
-H 'Idempotency-Key: <fresh-64-character-random-hex-key>' \
--data-binary @- <<'JSON'
{
"initial": 100000,
"annualContribution": 0,
"years": 30,
"grossReturn": 0.07,
"fees": [
{
"name": "expense ratio",
"rate": 0.005
},
{
"name": "advisory",
"rate": 0.01
}
],
"frontLoad": 0,
"feeMethod": "multiplicative"
}
JSONhttps://www.brainiac.software/api/v1/portfolio-analytics/tracking-error-capture$0.03 USDCTracking error and capture ratios
Tracking error, information ratio, up/down capture, batting average and optional active share versus a benchmark.
Body
| Field | Required | Notes |
|---|---|---|
portfolio | Yes | array; Array |
benchmark | Yes | array; Array |
periodsPerYear | No | number; Default: 12 |
holdings | No | object; Object |
captureMethod | No | string; One of: arithmetic, geometric; Default: "arithmetic" |
Request exampleJSON
{
"portfolio": [
0.025,
-0.012,
0.035,
-0.045,
0.018,
0.012,
-0.021,
0.028,
0.007,
-0.016,
0.033,
0.013
],
"benchmark": [
0.02,
-0.01,
0.03,
-0.04,
0.015,
0.01,
-0.02,
0.025,
0.005,
-0.015,
0.03,
0.01
],
"periodsPerYear": 12,
"holdings": {
"portfolio": {
"A": 0.4,
"B": 0.3,
"C": 0.3
},
"benchmark": {
"A": 0.3,
"B": 0.2,
"D": 0.5
}
}
}Response exampleJSON
{
"trackingError": 0.010492421507493353,
"informationRatio": 1.6202170288201965,
"upCapture": 1.1793103448275861,
"downCapture": 1.1058823529411763,
"battingAverage": 0.6666666666666666,
"activeShare": 0.5,
"sources": [
{
"source": "Caller-supplied holdings, returns, valuations and transactions processed locally",
"url": "https://www.brainiac.software/api/v1/portfolio-analytics",
"retrievedAt": "2026-11-14",
"status": "ok"
}
],
"limitations": [
"Outputs are calculations on caller-supplied inputs for human review. No market data is fetched, and this is not investm…",
"Tracking error is the annualised sample standard deviation of active returns. Information ratio uses mean(active)×P / T…"
]
}cURL
curl -i -X POST "https://www.brainiac.software/api/v1/portfolio-analytics/tracking-error-capture" \
-H 'content-type: application/json' \
-H 'Idempotency-Key: <fresh-64-character-random-hex-key>' \
--data-binary @- <<'JSON'
{
"portfolio": [
0.025,
-0.012,
0.035,
-0.045,
0.018,
0.012,
-0.021,
0.028,
0.007,
-0.016,
0.033,
0.013
],
"benchmark": [
0.02,
-0.01,
0.03,
-0.04,
0.015,
0.01,
-0.02,
0.025,
0.005,
-0.015,
0.03,
0.01
],
"periodsPerYear": 12,
"holdings": {
"portfolio": {
"A": 0.4,
"B": 0.3,
"C": 0.3
},
"benchmark": {
"A": 0.3,
"B": 0.2,
"D": 0.5
}
}
}
JSONhttps://www.brainiac.software/api/v1/portfolio-analytics/allocation-xray$0.03 USDCLook-through allocation x-ray
Aggregate caller-supplied fund look-through holdings by asset class, sector, region and top underlying positions.
Body
| Field | Required | Notes |
|---|---|---|
positions | Yes | array; Array |
top | No | integer; Default: 10 |
Request exampleJSON
{
"positions": [
{
"id": "FUND1",
"value": 60000,
"lookThrough": [
{
"security": "AAPL",
"weight": 0.07,
"assetClass": "equity",
"sector": "Technology",
"region": "US"
},
{
"security": "UST10",
"weight": 0.03,
"assetClass": "bond",
"sector": "Government",
"region": "US"
}
],
"otherWeight": 0.9,
"otherClass": {
"assetClass": "equity",
"sector": "Unclassified",
"region": "Unknown"
}
},
{
"id": "AAPL",
"value": 10000,
"assetClass": "equity",
"sector": "Technology",
"region": "US"
}
],
"top": 10
}Response exampleJSON
{
"total": 70000,
"byAssetClass": {
"equity": 0.9742857142857143,
"bond": 0.025714285714285714
},
"bySector": {
"Technology": 0.20285714285714285,
"Government": 0.025714285714285714,
"Unclassified": 0.7714285714285715
},
"byRegion": {
"US": 0.22857142857142856,
"Unknown": 0.7714285714285715
},
"topUnderlying": [
{
"security": "AAPL",
"value": 14200,
"weight": 0.20285714285714285,
"via": [
"FUND1",
"direct"
]
},
{
"security": "UST10",
"value": 1800,
"weight": 0.025714285714285714,
"via": [
"FUND1"
]
}
],
"sources": [
{
"source": "Caller-supplied holdings, returns, valuations and transactions processed locally",
"url": "https://www.brainiac.software/api/v1/portfolio-analytics",
"retrievedAt": "2026-11-14",
"status": "ok"
}
],
"limitations": [
"Outputs are calculations on caller-supplied inputs for human review. No market data is fetched, and this is not investm…",
"Look-through exposures use caller-supplied fund holdings. Unclassified remainder is reported explicitly and never redis…"
]
}cURL
curl -i -X POST "https://www.brainiac.software/api/v1/portfolio-analytics/allocation-xray" \
-H 'content-type: application/json' \
-H 'Idempotency-Key: <fresh-64-character-random-hex-key>' \
--data-binary @- <<'JSON'
{
"positions": [
{
"id": "FUND1",
"value": 60000,
"lookThrough": [
{
"security": "AAPL",
"weight": 0.07,
"assetClass": "equity",
"sector": "Technology",
"region": "US"
},
{
"security": "UST10",
"weight": 0.03,
"assetClass": "bond",
"sector": "Government",
"region": "US"
}
],
"otherWeight": 0.9,
"otherClass": {
"assetClass": "equity",
"sector": "Unclassified",
"region": "Unknown"
}
},
{
"id": "AAPL",
"value": 10000,
"assetClass": "equity",
"sector": "Technology",
"region": "US"
}
],
"top": 10
}
JSON