Loading the API reference…

Browse the API reference

Evaluate a membership expression

post https://quant-ws.prod.thinkalpha.io/universes/evaluate

Evaluates a membership expression on demand and returns the resulting members, without saving a universe. Use it to preview an expression before it becomes a universe definition, or to compute a one-off set such as "S&P 500 technology names weighing at least 5%".

Expression. membership is a MembershipExpr tree: static lists, filtered queries over security reference data, ETF holdings used as index proxies, top-N rankings, set operations, and references to existing universes. Each node type is described on MembershipExpr. A universeRef node uses the referenced universe's current snapshot, so the caller must have read access to every universe the expression references, at any depth; an unknown or unreadable reference returns 404 before anything is evaluated. Referenced universes keep their own OTC policy; otcPolicy on this request applies to every leaf of this expression, including the members a reference contributes.

Limits. Expressions are checked before evaluation and rejected with 400 when they exceed any of these limits:

  • at most 500 nodes in total, counting membership nodes and predicate nodes;
  • membership nesting at most 20 levels, predicate nesting at most 20 levels counted from the root of the expression (every membership node above a filter, and the query itself, uses one of those levels), and universeRef chains at most 16 universes deep, with no cycles;
  • at most 500 items in any single and, or or operands array;
  • at most 1,000 in values and 10,000 staticList instruments across the whole expression;
  • at most 16 distinct matches patterns, each at most 200 characters.

Evaluation is also bounded by the work it does: at most 500,000 source rows scanned, 10,000,000 predicate evaluations and 2,000,000 member visits (set-operation folds, de-duplication, ranking). Exceeding a work limit returns 400; narrow the expression. An evaluation that runs longer than 30 seconds returns 408. The service runs a limited number of evaluations at a time; when that limit is reached, the request returns 408 immediately and can be retried with backoff.

Result. The response is an anonymous snapshot: members sorted by instrument, the evaluation time, and sourceDate when the result has a single business date. Nothing is stored, and the result is not cached; repeat the request to re-evaluate.

To read a saved universe's members, use GET /universes/{idOrSlug}/constituents.

OTC (over-the-counter) securities trade outside a listing exchange; see UniverseOtcPolicy.

Authentication
Bearer token or Client credentials (HTTP Basic)

Request body application/json required

An ad-hoc membership expression to evaluate, with an optional OTC policy.

An ad-hoc membership expression to evaluate, with an optional OTC policy.

  • object required

    The membership expression to evaluate. See `MembershipExpr` for the node types and the limits above for size and work caps.

  • otcPolicy UniverseOtcPolicy

    How over-the-counter (OTC) securities are treated in this evaluation. Defaults to `include`. Applies to equity and ETF members; see `UniverseOtcPolicy`.

Responses

The members the expression selects right now, sorted by instrument.

  • timestamp string<date-time> required

    When the evaluation ran.

  • sourceDate string<date>

    Business date of the underlying source data, when the result has exactly one (ETF holdings). Absent otherwise.

  • UniverseConstituent[] required

    The selected members, sorted by instrument (equities by symbol, then options).

  • count integer required

    Number of members.

    >= 0<= 9007199254740991