Skip to content

Portfolio API

Base path: /api/v1/portfolio

All four resources require a valid Tradeboard API key. Portfolio analysis is read-only and never places orders.

Endpoints

MethodPathAuthenticationSuccess response
GET/benchmarks?apikey=...Valid API keyJSON benchmark inventory
POST/backtestapikey in JSONFull JSON analysis
POST/tearsheetapikey in JSONDownloadable HTML
POST/holdingsapikey in JSON plus active broker sessionCurrent-holdings summary and analysis

The heavier JSON endpoints use PORTFOLIO_API_RATE_LIMIT, which defaults to 10 per minute. Tearsheet rendering uses PORTFOLIO_TEARSHEET_RATE_LIMIT, which defaults to 5 per minute. /benchmarks uses the shared API limit.

GET /benchmarks

Reads available index symbols from the downloaded instrument master. The list therefore varies by broker and master-contract coverage.

json
{
  "status": "success",
  "data": [
    {"symbol": "NIFTY", "exchange": "NSE_INDEX", "name": "Nifty 50"}
  ]
}

POST /backtest

json
{
  "apikey": "YOUR_TRADEBOARD_API_KEY",
  "holdings": [
    {"symbol": "INFY", "exchange": "NSE", "weight": 40},
    {"symbol": "HDFCBANK", "exchange": "NSE", "weight": 60}
  ],
  "start_date": "2021-01-01",
  "end_date": "2026-01-01",
  "benchmark": "NIFTY",
  "benchmark_exchange": "NSE_INDEX",
  "rebalance": "quarterly",
  "drift_band": 0.05,
  "cost_model": "indian_equity",
  "cost_exchange": "NSE",
  "slippage": 0.0005,
  "initial_capital": 100000,
  "risk_free_rate": 0.06,
  "source": "db"
}

Request fields

FieldRequiredContractDefault
apikeyYesValid Tradeboard API key-
holdingsYes1-50 unique holdings-
holdings[].symbolYes1-64 characters, normalized uppercase-
holdings[].exchangeNoNSE or BSENSE
holdings[].weightYesNon-negative number; weights are normalized by ratio-
start_date, end_dateYesDate strings accepted by the history layer-
benchmarkNoIndex symbol or nullnull
benchmark_exchangeNoNSE_INDEX, BSE_INDEX, or GLOBAL_INDEXNSE_INDEX
rebalanceNonever, monthly, quarterly, or yearlynever
drift_bandNoFraction from 0 through 0.990
cost_modelNoindian_equity or flat_bpsindian_equity
brokerage_pctNoBrokerage as a fraction from 0 through 0.050
cost_exchangeNoNSE or BSE; which exchange's transaction charge appliesNSE
chargesNoNested object of per-charge overrides, {"<group>": {"<charge>": <rate or null>}}. Rates must be non-negative{}
gst_rateNoGST as a fraction from 0 through 1, or null to use the built-in ratenull
cost_bpsNoFlat cost from 0 through 1000 basis points0
slippageNoFraction from 0 through 0.10
initial_capitalNoPositive number100000
risk_free_rateNoFraction from 0 through 0.50
sourceNodb or apidb

PortfolioBacktestSchema does not allow unknown fields: any key outside this list returns HTTP 400.

charges and gst_rate exist because statutory rates change with the budget and differ by market. Leave them out to use the built-in Indian delivery-equity schedule.

source=db reads local Historify data and still requires a valid Tradeboard API key. source=api also requires an active broker session and calls broker history sequentially.

The success response contains the complete simulation generation, including equity, benchmark, metrics, holding contributions, correlations, diversification, allocation, costs, rebalancing, walk-forward, Monte Carlo, crisis, health, and insight sections.

POST /tearsheet

Accepts the same request shape as /backtest. Success returns a self-contained HTML attachment:

text
Content-Type: text/html; charset=utf-8
Content-Disposition: attachment; filename="portfolio-tearsheet.html"

POST /holdings

json
{
  "apikey": "YOUR_TRADEBOARD_API_KEY",
  "lookback_days": 365,
  "benchmark": "NIFTY",
  "benchmark_exchange": "NSE_INDEX",
  "risk_free_rate": 0.06,
  "source": "db"
}

/holdings uses its own schema, which accepts only these six fields; anything else returns HTTP 400.

FieldRequiredContractDefault
apikeyYesValid Tradeboard API key-
lookback_daysNoInteger from 60 through 3650365
benchmarkNoIndex symbol or nullNIFTY
benchmark_exchangeNoNSE_INDEX, BSE_INDEX, or GLOBAL_INDEXNSE_INDEX
risk_free_rateNoFraction from 0 through 0.50
sourceNodb or apidb

Unlike /backtest, benchmark here defaults to NIFTY rather than null. There is no holdings array: the positions come from the broker. This endpoint always needs an active broker session to read current holdings. Historical prices then come from the selected db or api source.

The result is a historical scenario for today's market-value allocation, not the account's actual performance. The holdings response does not contain purchase dates or cash flows, so the service cannot reconstruct realized returns.

Errors

StatusMeaning
400Invalid schema, duplicate symbols, weights, dates, or cost policy
403Invalid API key or required broker session absent
422Missing/incompatible history or no usable current holdings
429Configured rate limit exceeded
500Unexpected internal failure

A missing benchmark can leave benchmark-relative sections empty without invalidating an otherwise usable portfolio simulation.