The risk model API is live: a sandbox to try it, with a key issued on request, and production access for approved clients. The outcome model API is live in pilot.
Send positions or name a fund and get risk back, factor by factor, with funds looked through to what they hold. Use the house model, fit your own, or bring a model you license.
A fund's or a portfolio's risk, broken down by factor.
Send a model specification, fit it, and compare it with production.
Add your own factors and return series to a model.
4 steps, each shown below running against the live API for a test client, exactly as it came back.
Send your positions to us by API, SFTP or secure upload.
Available on request: deliver client holdings by SFTP or secure upload; each file is checked before it is loaded.
"""Send a book: stocks, bonds, US ETFs, mutual funds and cash, with your own quantities and prices (positions/2)."""
from vega_risk import Client, VegaError
BOOK = {"contract": "positions/2", "as_of": "2026-10-15", "base_currency": "USD", "price_source": "client", "lines": [
{"identifier_type": "ticker", "identifier": "AAPL", "asset_class": "equity", "quantity": 400, "price": 250.0, "currency": "USD"},
{"identifier_type": "ticker", "identifier": "MSFT", "asset_class": "equity", "quantity": 150, "price": 500.0, "currency": "USD"},
{"identifier_type": "ticker", "identifier": "JPM", "asset_class": "equity", "quantity": 120, "price": 300.0, "currency": "USD"},
{"identifier_type": "cusip", "identifier": "91282CKP5", "asset_class": "bond", "quantity": 50000, "price": 101.2,
"price_kind": "clean", "currency": "USD"},
{"identifier_type": "isin", "identifier": "US91282CKG59", "asset_class": "bond", "quantity": 40000, "price": 99.5,
"price_kind": "clean", "currency": "USD"},
{"identifier_type": "ticker", "identifier": "SPY", "asset_class": "fund", "quantity": 40, "price": 600.0, "currency": "USD"},
{"identifier_type": "ticker", "identifier": "AGG", "asset_class": "fund", "quantity": 600, "price": 100.0, "currency": "USD"},
{"identifier_type": "ticker", "identifier": "VT", "asset_class": "fund", "quantity": 200, "price": 120.0, "currency": "USD"},
{"identifier_type": "ticker", "identifier": "GABBX", "asset_class": "fund", "quantity": 500, "price": 30.0, "currency": "USD"},
{"identifier_type": "ticker", "identifier": "PAHIX", "asset_class": "fund", "quantity": 3000, "price": 6.0, "currency": "USD"},
{"identifier_type": "client", "identifier": "CASH-USD", "asset_class": "cash", "quantity": 25000, "price": 1.0, "currency": "USD"},
]}
vega = Client()
try:
vega.books.create("zz-golden", "Zz golden book (FAKE)", BOOK)
except VegaError as e:
if e.code != "book_exists":
raise
vega.books.put_positions("zz-golden", BOOK) # the same book again: a new version of the same date
s = vega.books.positions_status("zz-golden")
print(f"received via {s.via}: {s.lines} lines, {s.mapped} mapped, {s.unmapped} unmapped, {s.not_mapped} cash / not mapped")
print(f"checks: {s.verdict}; ready for risk: {s.risk_ready}")
print(f"positions sha256: {s.sha256}")
received via api: 11 lines, 10 mapped, 0 unmapped, 1 cash / not mapped checks: accepted; ready for risk: True positions sha256: fcab5210f364ba023f8f628cb417925773355b4e5986520bf5e2b548f6860d92Recorded 2026-10-21T07:24:59+00:00
"""The same book by secure upload: open a session, PUT the file to its signed link (no key on the upload), read it back.
The positions are exactly those of gp_positions_post: the stored book has the same sha256 whichever route it came by."""
import hashlib
import json
import httpx
from vega_risk import Client
POSITIONS = {"contract": "positions/2", "as_of": "2026-10-15", "base_currency": "USD", "price_source": "client", "lines": [
{"identifier_type": "ticker", "identifier": "AAPL", "asset_class": "equity", "quantity": 400, "price": 250.0, "currency": "USD"},
{"identifier_type": "ticker", "identifier": "MSFT", "asset_class": "equity", "quantity": 150, "price": 500.0, "currency": "USD"},
{"identifier_type": "ticker", "identifier": "JPM", "asset_class": "equity", "quantity": 120, "price": 300.0, "currency": "USD"},
{"identifier_type": "cusip", "identifier": "91282CKP5", "asset_class": "bond", "quantity": 50000, "price": 101.2,
"price_kind": "clean", "currency": "USD"},
{"identifier_type": "isin", "identifier": "US91282CKG59", "asset_class": "bond", "quantity": 40000, "price": 99.5,
"price_kind": "clean", "currency": "USD"},
{"identifier_type": "ticker", "identifier": "SPY", "asset_class": "fund", "quantity": 40, "price": 600.0, "currency": "USD"},
{"identifier_type": "ticker", "identifier": "AGG", "asset_class": "fund", "quantity": 600, "price": 100.0, "currency": "USD"},
{"identifier_type": "ticker", "identifier": "VT", "asset_class": "fund", "quantity": 200, "price": 120.0, "currency": "USD"},
{"identifier_type": "ticker", "identifier": "GABBX", "asset_class": "fund", "quantity": 500, "price": 30.0, "currency": "USD"},
{"identifier_type": "ticker", "identifier": "PAHIX", "asset_class": "fund", "quantity": 3000, "price": 6.0, "currency": "USD"},
{"identifier_type": "client", "identifier": "CASH-USD", "asset_class": "cash", "quantity": 25000, "price": 1.0, "currency": "USD"},
]}
BOOK = {"book_id": "zz-golden-upload", "name": "Zz golden book (FAKE), by secure upload", "positions": POSITIONS}
body = json.dumps(BOOK, sort_keys=True).encode()
sha = hashlib.sha256(body).hexdigest()
vega = Client()
s = vega.request("POST", "/model-deliveries", json={
"kind": "positions", "label": "zz golden by upload", "sizes": {"book.json": len(body)},
"manifest": {"files": [{"path": "book.json", "format": "json", "sha256": sha}]}})
up = s["uploads"][0]
r = httpx.put(up["url"], content=body, headers=dict(up["headers"], **{"content-length": str(len(body))}), timeout=60)
print("upload:", r.status_code, "| session", s["delivery_id"][:8], "kind", s["kind"])
print("state:", vega.request("GET", f"/model-deliveries/{s['delivery_id']}")["state"], "(the poller brings it in as book zz-golden-upload)")
upload: 200 | session b85e35ab kind positions state: uploaded (the poller brings it in as book zz-golden-upload)Recorded 2026-10-21T07:25:00+00:00
Funds are broken into the holdings they own, and the risk comes back factor by factor.
"""Risk back, with the funds looked through to what they hold, and as of when."""
from vega_risk import Client
vega = Client()
r = vega.books.risk("zz-golden")
print(f"{r.total_vol_pct:.2f}% a year: factor {r.factor_vol_pct:.2f}%, specific {r.specific_vol_pct:.2f}% ({r.model.label})")
for d in r.top_drivers[:3]:
print(f" {d.label or d.factor}: {d.share_of_variance_pct:.1f}% of the variance")
lt = r.look_through
print(f"{lt.funds_looked_through} of {lt.funds} funds looked through ({lt.looked_through_pct:.1f}% of the book); "
f"the model covers {lt.modelled_pct:.1f}%")
for f in lt.holdings:
print(f" {f.key}: holdings as of {f.holdings_as_of} ({f.holdings_source})" + ("" if f.looked_through else ", not looked through"))
10.74% a year: factor 8.08%, specific 7.08% (House model Vega Global v1.7 (certified), recorded snapshot 21) US equity market: 42.8% of the variance US equity: Information Technology: 18.5% of the variance US equity style: Beta: -4.5% of the variance 5 of 5 funds looked through (30.2% of the book); the model covers 94.7% fund:SPY: holdings as of 2026-06-30 (sec_nport_f3) fund:AGG: holdings as of 2026-05-31 (sec_nport_f3) fund:VT: holdings as of 2026-07-31 (sec_nport_f3) fund:GABBX: holdings as of 2026-06-30 (sec_nport_f3) fund:PAHIX: holdings as of 2026-05-31 (sec_nport_f3)Recorded 2026-10-21T07:25:01+00:00
Choose your own factors and settings. Every model you fit is fingerprinted and stays labeled research, not certified, until a person signs it off. Only a signed-off model can become a book's default; otherwise the house model is shown.
"""Your own model: the house fixed-income recipe with a shorter volatility half-life, fitted, fingerprinted, carded."""
from vega_risk import Client
vega = Client()
spec = vega.specs.house("fixed_income").set(name="zz_client_hl42", covariance__vol_half_life=42)
print("recipe fingerprint:", spec.fingerprint, "(the same recipe always gives this fingerprint)")
fit = vega.fits.create(spec).wait()
card = vega.models.card(fit)
print("model:", card.model.id)
print("certification:", card.certification, "| card sha256:", card.card_sha256)
recipe fingerprint: 7729f6271dd5058b (the same recipe always gives this fingerprint) model: factory:7729f6271dd5058b@rec_s21:cac08f1ec07c7ab2 certification: candidate | card sha256: 385c74f41117f6c6f06b3e3965bdef76a4e341726959c7c5c21f5c37d800dcd1Recorded 2026-10-21T07:25:51+00:00
"""Your model against the house on the same book, with the backtest by year."""
from vega_risk import Client
vega = Client()
mine = next(m.model for m in vega.models.list() if m.model.name == "zz_client_hl42")
cmp = vega.books.compare("zz-golden", model_b=mine.id)
a, b = round(cmp.a.total_vol_pct, 2), round(cmp.b.total_vol_pct, 2)
print(f"house {a:.2f}% -> yours {b:.2f}% ({b - a:+.2f} points)")
print("method:", cmp.b.method)
bt = (cmp.backtest or {}).get("b") or {} # your model's backtest on the recorded fixed-income books
print("verdict:", (bt.get("verdict") or {}).get("verdict"))
agg = ((bt.get("books") or {}).get("fund:AGG") or {}).get("model") or {}
for row in agg.get("by_year") or []: # bias by year beside the whole window, never a bare figure
print(f" AGG bias {row['year']}: {row['bias']:.3f} over {row['n']} days")
house 10.74% -> yours 10.75% (+0.01 points) method: fit: funds on the fit's own vectors (30% of the book), stocks and bonds on the house's unit exposures (64%), the fit's covariance verdict: rejected AGG bias 2024: 0.980 over 144 days AGG bias 2025: 0.940 over 250 days AGG bias 2026: 1.115 over 196 daysRecorded 2026-10-21T07:25:51+00:00
This example model is rejected: in the backtest its risk forecasts were significantly worse than the house model's for one of the test funds, and significantly better for none. Fits that do as well as the house are accepted.
"""Where last month's return came from: each factor's contribution, from the book's exposures."""
from vega_risk import Client
vega = Client()
a = vega.books.attribution("zz-golden")
print(f"{a.period_start} to {a.period_end} ({a.trading_days} trading days): factor return {a.factor_return_pct:+.2f}%")
print("total:", "withheld" if a.total_return_pct is None else f"{a.total_return_pct:+.2f}%", f"({a.priced_pct:.0f}% of the book priced)")
for c in a.contributions[:3]:
print(f" {c.factor}: {c.contribution_pct:+.3f}%")
2026-09-16 to 2026-10-15 (21 trading days): factor return +2.26% total: withheld (23% of the book priced) ind_45: +1.183% market: +1.029% sty_profitability: +0.542%Recorded 2026-10-21T07:25:52+00:00
Available on request: send the files of a risk model you already license by SFTP or secure upload; it is scored on the same scorecard as ours, as deliveries build up.
Available on request: deliver a licensed model's files by SFTP or secure upload; we load them and score the model on the same scorecard as ours, as deliveries build up.
"""The same book on a vendor's model, delivered to us as files, scored the same way.
(The vendor here is FAKE and its model made up: test files, not a real vendor's data.)"""
from vega_risk import Client
vega = Client()
vendor = next(m.model for m in vega.models.list() if m.model.id.startswith("foreign:"))
r = vega.books.risk("zz-golden", model=vendor.id)
h = vega.books.risk("zz-golden")
print(f"{vendor.name} (a FAKE vendor's model): {r.total_vol_pct:.2f}% a year on the {r.vendor_coverage_pct:.1f}% of the book it covers "
f"(house: {h.total_vol_pct:.2f}% on the whole book)")
print("fingerprint (the delivery's hash):", vendor.fingerprint)
Fake Risk Co Fake Global Equity 1.0 (a FAKE vendor's model): 21.66% a year on the 93.8% of the book it covers (house: 10.71% on the whole book) fingerprint (the delivery's hash): c41e65f4a71773d6Recorded 2026-10-21T16:02:36+00:00
"""A vendor's model files with our covariance and your own factor: the hybrid, and how it scores against the vendor's own.
(The vendor here is FAKE and its history synthetic: a test history, not a real vendor's data.)"""
from vega_risk import Client
vega = Client()
hybrid = next(m.model for m in vega.models.list() if m.model.id.startswith("composite:"))
card = vega.models.card(hybrid.id).raw
print(card["provenance"]["said"])
print("model:", hybrid.id, "| run:", card["run"]["inputs_hash"], "| card sha256:", card["card_sha256"][:16])
print("covariance:", card["spec"]["join"]["cross_block"]["params"], "on the vendor's factor returns + your", card["spec"]["custom"][0]["name"])
sc = card["scorecard"]
def by_year(rows):
return ", ".join(f"{y} {r['b']:.2f}" + ("*" if r["indicative"] else "") for y, r in rows.items())
for code in ("H0", "H3", "H4"):
s = sc[code]
rb = s["random_books"]
print(f"{s['what']}: random books median bias {rb['bias_median']:.2f} over the whole window; by year: {by_year(rb['by_year'])}")
t = s["client_tilt"]
if t.get("bias") is None:
print(" client-tilt book:", t.get("withheld"))
continue
print(f" client-tilt book bias {t['bias']:.2f} over the whole window; by year: {by_year(t['by_year'])}")
print("bias 1.00 = the model's risk matched what happened; * = fewer than 63 days that year (indicative)")
print("cards (sha256):", {c: sc[c]["card"]["sha256"][:16] for c in ("H0", "H3", "H4")})
Fake Risk Co (a FAKE vendor), synthetic history 2024-2024
model: composite:ffb5b95320001831 | run: e88bf3fe83f13099 | card sha256: 3429fa8765412356
covariance: {'corr_half_life': 126, 'nw_lags': 5, 'vol_half_life': 63} on the vendor's factor returns + your CLIENT_A
the vendor as delivered: random books median bias 1.00 over the whole window; by year: 2023 1.01, 2024 1.03
client-tilt book bias 2.71 over the whole window; by year: 2015 3.52*, 2023 2.76, 2024 2.66
ours + the client factor (this model): random books median bias 1.03 over the whole window; by year: 2023 1.01, 2024 1.03
client-tilt book bias 0.97 over the whole window; by year: 2015 1.26*, 2023 0.99, 2024 0.95
ours + a client factor with no information (control): random books median bias 1.04 over the whole window; by year: 2023 1.01, 2024 1.03
client-tilt book bias 2.25 over the whole window; by year: 2015 2.93*, 2023 2.29, 2024 2.21
bias 1.00 = the model's risk matched what happened; * = fewer than 63 days that year (indicative)
cards (sha256): {'H0': '2f3313ea41a01659', 'H3': '790fe5850c1857ca', 'H4': 'afa8fdd0839eec49'}
Recorded 2026-10-21T07:25:56+00:00Install the package, then run these lines with your key.
pip install vega-risk
from vega_risk import Client
vega = Client(api_key="vk_test_...") # a sandbox key: demo books on recorded data
risk = vega.books.risk("demo:vega-60-40")
print(f"{risk.total_vol_pct:.2f}% a year;", "top drivers:", ", ".join(d.factor for d in risk.top_drivers[:3]))
Last verified 2026-10-21T07:25:58+00:00
Send positions, get look-through risk back, and build your own risk model on top.
See each step running →Each call below ran against the live API for a test client and is shown exactly as it came back.
Many books in one call, persisted and resumable.
"""Many books in one call: a batch job, its progress, and each item's result (the same object the single GET returns)."""
from vega_risk import Client
vega = Client()
books = [b.book_id for b in vega.books.iter()][:20]
items = [dict(book_id=b, kind=k) for b in books for k in ("risk", "exposures")]
job = vega.batches.create(items, idempotency_key="gp-quant-batch-" + "-".join(books)[:80])
print("batch", job.batch_id, "|", job.status, "|", len(items), "items")
done = vega.batches.wait(job.batch_id)
print("status:", done.status, "| progress:", done.progress.done, "of", done.progress.total)
for it in done.items:
if it.kind == "risk" and it.status == "done":
r = it.result
print(f" {it.book_id}: {r['total_vol_pct']:.2f}% a year ({r['model']['label']}, model as of {r['model_as_of']})")
same = vega.batches.create(items, idempotency_key="gp-quant-batch-" + "-".join(books)[:80])
print("the same Idempotency-Key, the same batch:", same.batch_id == job.batch_id)
batch bt_26e54c9c1698b669 | done | 6 items status: done | progress: 6 of 6 zz-golden: 10.71% a year (House model Vega Global v1.7 (certified), recorded snapshot 24, model as of 2026-10-19) zz-golden-sftp: 10.71% a year (House model Vega Global v1.7 (certified), recorded snapshot 24, model as of 2026-10-19) zz-golden-upload: 10.71% a year (House model Vega Global v1.7 (certified), recorded snapshot 24, model as of 2026-10-19) the same Idempotency-Key, the same batch: TrueRecorded 2026-10-21T16:02:59+00:00
Risk and models on a past date, as they stood then.
"""What was reported on a past date: risk as of three dates (the model served that day, the book as it stood then)."""
from vega_risk import Client
vega = Client()
for d in ("2026-10-15", "2026-10-16", "2026-10-19"):
r = vega.books.risk("zz-golden", as_of=d)
print(f"as of {d}: {r.total_vol_pct:.4f}% a year | model as of {r.model_as_of} (run {r.model.run}) | positions as of {r.positions_as_of}")
a, b = vega.books.risk("zz-golden", as_of="2026-10-16"), vega.books.risk("zz-golden", as_of="2026-10-16")
print("2026-10-16 asked twice, the same result:", a.raw == b.raw)
for d in ("2026-10-15", "2026-10-19"):
c = vega.models.card("house:vega_global_v1_7", as_of=d)
print(f"model card as of {d}: sha256 {c.card_sha256[:16]}")
as of 2026-10-15: 10.7405% a year | model as of 2026-10-15 (run f305dc77b9caaa91) | positions as of 2026-10-15 as of 2026-10-16: 10.8158% a year | model as of 2026-10-16 (run 8b4baa4941949183) | positions as of 2026-10-15 as of 2026-10-19: 10.7053% a year | model as of 2026-10-19 (run c3087a274e9a5161) | positions as of 2026-10-15 2026-10-16 asked twice, the same result: True model card as of 2026-10-15: sha256 178373e71cba3e0c model card as of 2026-10-19: sha256 12107dfc271b7f72Recorded 2026-10-21T16:03:06+00:00
Exposures, covariance and specific risk as numbers you can load, for any model.
"""The model's own numbers: factor covariance, each security's exposures and specific risk, on a date, for every model you use.
(The vendor here is FAKE and its model made up: test files, not a real vendor's data.)"""
import math
from vega_risk import Client
vega = Client()
house = "house:vega_global_v1_7"
cov = vega.models.covariance(house)
print(f"{cov.model['label']}: {cov.n} factors, covariance as of {cov.model_as_of} ({cov.units.split(';')[0]})")
two = vega.models.covariance(house, factors=["market", "KRD_10Y"])
for f, row in zip(two.factors, two.sigma):
print(f" {f}: annual vol {100 * math.sqrt(252 * row[two.factors.index(f)]):.2f}%")
keys = [ln.key for ln in vega.books.positions("zz-golden").lines if getattr(ln, "key", None)][:3]
ex = vega.models.exposures(house, keys)
sp = vega.models.specific(house, keys)
for k in keys:
top = sorted(ex.exposures[k].raw.items(), key=lambda kv: -abs(kv[1]))[:3]
print(f" {k}: " + ", ".join(f"{f} {v:+.3f}" for f, v in top) + f" | specific vol {100 * math.sqrt(252 * sp.specific[k]):.2f}% a year")
for m in vega.models.list():
if m.model.id != house:
c = vega.models.covariance(m.model.id)
print(f"{m.model.id}: {c.n} factors, {m.model.label}" + (" (a FAKE vendor's model)" if m.model.id.startswith("foreign:") else ""))
House model Vega Global v1.7 (certified), recorded snapshot 24: 277 factors, covariance as of 2026-10-19 (daily decimal variance) market: annual vol 12.30% KRD_10Y: annual vol 0.84% equity:320193: sty_profitability +1.762, ind_45 +1.000, market +1.000 | specific vol 24.84% a year equity:789019: ind_45 +1.000, market +1.000, sty_liquidity -0.823 | specific vol 27.59% a year equity:19617: ind_40 +1.000, market +1.000, sty_resid_vol -0.439 | specific vol 14.92% a year factory:7729f6271dd5058b@rec_s24:c3087a274e9a5161: 277 factors, Your fixed-income model zz_client_hl42 (research, not certified), fitted on recorded snapshot 24 foreign:7:c41e65f4a71773d6: 9 factors, Your vendor model Fake Risk Co Fake Global Equity 1.0 (as delivered; delivered 2026-10-20) (a FAKE vendor's model) foreign:7:d8394ace6d2cb9f9: 9 factors, Your vendor model Fake Risk Co Fake Global Equity 1.0 (as delivered; delivered 2026-10-20) (a FAKE vendor's model) foreign:7:1e38380b34c2b9ab: 9 factors, Your vendor model Fake Risk Co Fake Global Equity 1.0 (as delivered; delivered 2026-10-20) (a FAKE vendor's model) composite:08531eb047bf5564: 101 factors, Hybrid of Fake Risk Co (a FAKE vendor), synthetic history 2015-2024: the vendor's exposures, our covariance, plus your factor CLIENT_A (research; delivery of 2024-11-29)Recorded 2026-10-21T16:03:13+00:00
Risk before and after a hypothetical change to the book, under the house model, your own fits or a licensed model; nothing is stored or sent.
"""Where the risk comes from, position by position (the parts add up to the total), and a change's effect before you make it."""
from vega_risk import Client
vega = Client()
c = vega.books.contributions("zz-golden")
print(f"total {c.total_vol_pct:.2f}% a year; the shares add up to {c.check.sum_of_shares_pct:.6f}%")
for p in c.positions[:5]:
print(f" {p.key}: weight {p.weight:.3f}, {p.share_of_variance_pct:5.1f}% of the variance, marginal {p.marginal_vol_pct:+.2f}% per unit weight")
w = vega.books.what_if("zz-golden", [dict(identifier="SPY", identifier_type="ticker", asset_class="fund", delta_weight=0.05),
dict(identifier="AGG", identifier_type="ticker", asset_class="fund", delta_weight=-0.05)])
for k in ("total_vol_pct", "factor_vol_pct", "specific_vol_pct"):
print(f" {k.replace('_vol_pct', '')}: {w.before[k]:.3f}% -> {w.after[k]:.3f}% ({w.difference[k]:+.3f})")
print(w.note)
total 10.71% a year; the shares add up to 100.000000% equity:320193: weight 0.214, 47.2% of the variance, marginal +23.63% per unit weight equity:789019: weight 0.160, 37.9% of the variance, marginal +25.31% per unit weight equity:19617: weight 0.077, 4.5% of the variance, marginal +6.27% per unit weight fund:SPY: weight 0.051, 4.2% of the variance, marginal +8.85% per unit weight fund:VT: weight 0.051, 3.2% of the variance, marginal +6.68% per unit weight total: 10.705% -> 11.137% (+0.432) factor: 8.083% -> 8.641% (+0.558) specific: 7.019% -> 7.027% (+0.008) weights of the book's valued lines; nothing is stored or tradedRecorded 2026-10-21T16:03:15+00:00
We are building a connector so that an AI assistant you already use can ask the risk model about a client's portfolio, with the permissions of your key.
{
"mcpServers": {
"vega": {
"command": "vega-risk-mcp",
"env": {"VEGA_API_KEY": "vk_test_..."}
}
}
}
You What's driving risk in the Vega 60/40 book?
Assistant explain_risk_drivers({"book_id": "demo:vega-60-40"})
Assistant Book demo:vega-60-40 as of 2026-10-15, model: House model Vega Global v1.7 (certified), recorded snapshot 21. Total risk 8.61% a year: factor 8.26%, specific 2.43% (specific is 8.0% of the variance). Largest drivers: US equity market 79.9% of the variance, +6.88 points of volatility; US equity: Information Technology 8.8% of the variance, +0.76 points of volatility; US equity style: Beta 3.2% of the variance, +0.27 points of volatility. By group: equity 85.4%, rates 5.5%, credit 1.1% of the variance. Diversifying (negative share): US equity: Health Care, US equity: Energy, US equity: Financials.
Assistant The book's risk is 8.61% a year under House model Vega Global v1.7 (certified), recorded snapshot 21. Equity factors carry 85.4% of the variance and interest rates 5.5%; the largest single drivers are US equity market (79.9% of the variance), US equity: Information Technology (8.8% of the variance), US equity style: Beta (3.2% of the variance). Specific (security-level) risk is 8.0% of the variance.
Recorded 2026-10-20T07:16:51+00:00You How would trimming tech by 25% change the risk of the Vega 60/40?
Assistant what_if_trim({"book_id": "demo:vega-60-40", "sector": "Information Technology", "trim_pct": 25.0})
Assistant {"sector_weight_before_pct": 23.272516243618053, "sector_weight_after_pct": 17.45438718271354, "change_total_vol_pct": -0.8630730890976137, "funds_looked_through": ["SPY"]} before {"total_vol_pct": 8.605024976032178, "factor_vol_pct": 8.261320600287966} after {"total_vol_pct": 7.741951886934564, "factor_vol_pct": 7.437500128016128}
Assistant Looking through the fund to its stocks, technology is 23.3% of the book. Trimming it by 25% (to 17.5%, the weight spread over the fund's other stocks) moves total risk from 8.61% to 7.74% a year (-0.87 points). Largest drivers before: US equity market (80.0% of the variance), US equity: Information Technology (8.8% of the variance); after: US equity market (87.6% of the variance), US equity: Information Technology (4.8% of the variance). This is a what-if on positions sent for checking: nothing was stored or traded.
Recorded 2026-10-20T07:16:51+00:00You Compare the house model with a client model that describes the yield curve by level, slope and curvature, on the Vega 60/40.
Assistant propose_fit({"kind": "fixed_income", "changes": {"name": "curve_lsc", "curve.us": "lsc", "curve.ns_tau": 1.37}})
Assistant {"status": "queued", "fingerprint": "64eaa8389c55b8d2", "note": "a research fit: it has no serving effect; read it with fit_status, compare it with compare_models"}
Assistant fit_status({"job_id": "<the job>"})
Assistant {"status": "done", "model_id": "factory:64eaa8389c55b8d2@rec_s21:cac08f1ec07c7ab2"}
Assistant compare_models({"book_id": "demo:vega-60-40", "model_b": "<the fitted model>"})
Assistant {"total_vol_pct": 8.612609105495384} vs {"total_vol_pct": 8.645616577171268} difference +0.0330
Assistant On the Vega 60/40 the house model gives 8.61% a year and the level-slope-curvature model 8.65% (+0.04 points). In the backtest on this book, the client model's bias by year is 2024: 0.85, 2025: 1.10, 2026: 0.87 against the house's 2024: 0.85, 2025: 1.11, 2026: 0.87 (1.00 = forecasts in line with realised risk). The model is a research run: using it for the book would be a proposal a person approves.
Recorded 2026-10-20T07:16:51+00:00Each output was recorded from a run of the API and is shown exactly as it came back.
from vega_risk import Client
vega = Client(api_key="vk_test_...") # a sandbox key: demo books on recorded data
risk = vega.books.risk("demo:vega-60-40")
print(f"{risk.total_vol_pct:.2f}% a year;", "top drivers:", ", ".join(d.factor for d in risk.top_drivers[:3]))
8.61% a year; top drivers: market, ind_45, sty_beta
curl -s -H "Authorization: Bearer vk_test_..." \ https://vegainvestmentplatform.ai/v1/books/demo:vega-60-40/risk
{"book_id":"demo:vega-60-40","as_of":"2026-10-15","model":{"id":"house:vega_global_v1_7","name":"Vega Global","version":"1.7","fingerprint":"30e3b67358f3","fingerprint_kind":"registry","house":true,"certification":"certified","label":"House model Vega Global v1.7 (certified), recorded snapshot 21","run":"cac08f1ec07c7ab2","stale_since":null},"basis":"stored","total_vol_pct":8.612609105495384,"factor_vol_pct":8.26132060025028,"specific_vol_pct":2.434669904513212,"var_95_1d_pct":null,"beta":null,"lines":2,"modelled_pct":99.6454,"specific_share_pct":7.991176104128068,"top_drivers":[{"factor":"market","label":"US equity market","group":"equity","exposure":0.5969487433026316,"share_of_variance_pct":79.88560529135157,"vol_contribution_pct":6.880234915303047},{"factor":"ind_45","label":"US equity: Information Technology","group":"equity","exposure":0.2309207845979847,"share_of_variance_pct":8.792457567998325,"vol_contribution_pct":0.7572600010982417},{"factor":"sty_beta","label":"US equity style: Beta","group":"equity","exposure":0.034476082652158284,"share_of_variance_pct":3.1547504723103357,"vol_contribution_pct":0.2717063264338586},{"factor":"ind_35","label":"US equity: Health Care","group":"equity","exposure":0.05332277831241319,"share_of_variance_pct":-1.968170646732877,"vol_contribution_pct":-0.16951084433220315},{"factor":"KRD_10Y","label":"US 10-year rate","group":"rates","exposure":0.594772149763435,"share_of_variance_pct":1.6526231645580098,"vol_contribution_pct":0.1423339731502491},{"factor":"ind_10","label":"US equity: Energy","group":"equity","exposure":0.01812757291215174,"share_of_variance_pct":-1.358349229692872,"vol_contribution_pct":-0.11698930944095472},{"factor":"KRD_7Y","label":"US 7-year rate","group":"rates","exposure":0.38544426643874136,"share_of_variance_pct":1.0992340121961701,"vol_contribution_pct":0.0946727286251096},{"factor":"KRD_LONG","label":"US long (20-30 year) rate","group":"rates","exposure":0.4623996369198102,"share_of_variance_pct":1.0257311863015683,"vol_contribution_pct":0.08834221754931469},{"factor":"KRD_5Y","label":"US 5-year rate","group":"rates","exposure":0.3651126463056784,"share_of_variance_pct":1.0046859481609927,"vol_contribution_pct":0.08652967345294629},{"factor":"ind_40","label":"US equity: Financials","group":"equity","exposure":0.06929290120333277,"share_of_variance_pct":-0.9553827173724442,"vol_contribution_pct":-0.08228337890874836}],"groups":[{"group":"equity","share_of_variance_pct":85.42789945743796},{"group":"rates","share_of_variance_pct":5.504630933461055},{"group":"credit","share_of_variance_pct":1.0762935049729272}],"method":"composed","look_through":null,"specific_missing_share":null,"vendor_coverage_pct":null}"""Send a book: stocks, bonds, US ETFs, mutual funds and cash, with your own quantities and prices (positions/2)."""
from vega_risk import Client, VegaError
BOOK = {"contract": "positions/2", "as_of": "2026-10-15", "base_currency": "USD", "price_source": "client", "lines": [
{"identifier_type": "ticker", "identifier": "AAPL", "asset_class": "equity", "quantity": 400, "price": 250.0, "currency": "USD"},
{"identifier_type": "ticker", "identifier": "MSFT", "asset_class": "equity", "quantity": 150, "price": 500.0, "currency": "USD"},
{"identifier_type": "ticker", "identifier": "JPM", "asset_class": "equity", "quantity": 120, "price": 300.0, "currency": "USD"},
{"identifier_type": "cusip", "identifier": "91282CKP5", "asset_class": "bond", "quantity": 50000, "price": 101.2,
"price_kind": "clean", "currency": "USD"},
{"identifier_type": "isin", "identifier": "US91282CKG59", "asset_class": "bond", "quantity": 40000, "price": 99.5,
"price_kind": "clean", "currency": "USD"},
{"identifier_type": "ticker", "identifier": "SPY", "asset_class": "fund", "quantity": 40, "price": 600.0, "currency": "USD"},
{"identifier_type": "ticker", "identifier": "AGG", "asset_class": "fund", "quantity": 600, "price": 100.0, "currency": "USD"},
{"identifier_type": "ticker", "identifier": "VT", "asset_class": "fund", "quantity": 200, "price": 120.0, "currency": "USD"},
{"identifier_type": "ticker", "identifier": "GABBX", "asset_class": "fund", "quantity": 500, "price": 30.0, "currency": "USD"},
{"identifier_type": "ticker", "identifier": "PAHIX", "asset_class": "fund", "quantity": 3000, "price": 6.0, "currency": "USD"},
{"identifier_type": "client", "identifier": "CASH-USD", "asset_class": "cash", "quantity": 25000, "price": 1.0, "currency": "USD"},
]}
vega = Client()
try:
vega.books.create("zz-golden", "Zz golden book (FAKE)", BOOK)
except VegaError as e:
if e.code != "book_exists":
raise
vega.books.put_positions("zz-golden", BOOK) # the same book again: a new version of the same date
s = vega.books.positions_status("zz-golden")
print(f"received via {s.via}: {s.lines} lines, {s.mapped} mapped, {s.unmapped} unmapped, {s.not_mapped} cash / not mapped")
print(f"checks: {s.verdict}; ready for risk: {s.risk_ready}")
print(f"positions sha256: {s.sha256}")
received via api: 11 lines, 10 mapped, 0 unmapped, 1 cash / not mapped checks: accepted; ready for risk: True positions sha256: fcab5210f364ba023f8f628cb417925773355b4e5986520bf5e2b548f6860d92
"""The same book by secure upload: open a session, PUT the file to its signed link (no key on the upload), read it back.
The positions are exactly those of gp_positions_post: the stored book has the same sha256 whichever route it came by."""
import hashlib
import json
import httpx
from vega_risk import Client
POSITIONS = {"contract": "positions/2", "as_of": "2026-10-15", "base_currency": "USD", "price_source": "client", "lines": [
{"identifier_type": "ticker", "identifier": "AAPL", "asset_class": "equity", "quantity": 400, "price": 250.0, "currency": "USD"},
{"identifier_type": "ticker", "identifier": "MSFT", "asset_class": "equity", "quantity": 150, "price": 500.0, "currency": "USD"},
{"identifier_type": "ticker", "identifier": "JPM", "asset_class": "equity", "quantity": 120, "price": 300.0, "currency": "USD"},
{"identifier_type": "cusip", "identifier": "91282CKP5", "asset_class": "bond", "quantity": 50000, "price": 101.2,
"price_kind": "clean", "currency": "USD"},
{"identifier_type": "isin", "identifier": "US91282CKG59", "asset_class": "bond", "quantity": 40000, "price": 99.5,
"price_kind": "clean", "currency": "USD"},
{"identifier_type": "ticker", "identifier": "SPY", "asset_class": "fund", "quantity": 40, "price": 600.0, "currency": "USD"},
{"identifier_type": "ticker", "identifier": "AGG", "asset_class": "fund", "quantity": 600, "price": 100.0, "currency": "USD"},
{"identifier_type": "ticker", "identifier": "VT", "asset_class": "fund", "quantity": 200, "price": 120.0, "currency": "USD"},
{"identifier_type": "ticker", "identifier": "GABBX", "asset_class": "fund", "quantity": 500, "price": 30.0, "currency": "USD"},
{"identifier_type": "ticker", "identifier": "PAHIX", "asset_class": "fund", "quantity": 3000, "price": 6.0, "currency": "USD"},
{"identifier_type": "client", "identifier": "CASH-USD", "asset_class": "cash", "quantity": 25000, "price": 1.0, "currency": "USD"},
]}
BOOK = {"book_id": "zz-golden-upload", "name": "Zz golden book (FAKE), by secure upload", "positions": POSITIONS}
body = json.dumps(BOOK, sort_keys=True).encode()
sha = hashlib.sha256(body).hexdigest()
vega = Client()
s = vega.request("POST", "/model-deliveries", json={
"kind": "positions", "label": "zz golden by upload", "sizes": {"book.json": len(body)},
"manifest": {"files": [{"path": "book.json", "format": "json", "sha256": sha}]}})
up = s["uploads"][0]
r = httpx.put(up["url"], content=body, headers=dict(up["headers"], **{"content-length": str(len(body))}), timeout=60)
print("upload:", r.status_code, "| session", s["delivery_id"][:8], "kind", s["kind"])
print("state:", vega.request("GET", f"/model-deliveries/{s['delivery_id']}")["state"], "(the poller brings it in as book zz-golden-upload)")
upload: 200 | session b85e35ab kind positions state: uploaded (the poller brings it in as book zz-golden-upload)
"""A public fund's lines from its latest filing, largest first."""
from vega_risk import Client
vega = Client()
lt = vega.funds.look_through("TIP", limit=10)
print(f"{lt.fund_name}: {lt.lines_total} lines, holdings as of {lt.holdings_as_of}, {lt.modelled_pct:.1f}% modelled")
for ln in lt.lines:
print(f" {ln.weight * 100:6.2f}% {ln.name}")
iShares TIPS Bond ETF: 49 lines, holdings as of 2026-07-31, 100.0% modelled
3.98% TSY INFL IX N/B 07/35 1.875
3.92% U.S. Treasury Inflation Linked Notes
3.91% U.S. Treasury Inflation-Indexed Notes
3.70% USTN TII 1.875% 07/15/2034
3.54% UNITED STATES TREASURY INFLATION INDEXED BONDS
3.36% TSY INFL IX N/B 10/30 1.125
3.31% UNITED STATES TREASURY INFLATI 04/30 1.625
3.31% U.S. Treasury Inflation Linked Notes
3.28% U.S. Treasury Inflation-Indexed Notes
3.28% USTN TII 1.375% 07/15/2033
"""A book's risk: total volatility and its three largest drivers. Needs VEGA_API_KEY (a sandbox key works)."""
from vega_risk import Client
vega = Client()
risk = vega.books.risk("demo:vega-60-40")
print(f"{risk.total_vol_pct:.2f}% a year (factor {risk.factor_vol_pct:.2f}%, specific {risk.specific_vol_pct:.2f}%)")
print("model:", risk.model.label)
for d in risk.top_drivers[:3]:
print(f" {d.label or d.factor:<40} {d.share_of_variance_pct:6.1f}% of the variance")
8.61% a year (factor 8.26%, specific 2.43%) model: House model Vega Global v1.7 (certified), recorded snapshot 21 US equity market 79.9% of the variance US equity: Information Technology 8.8% of the variance US equity style: Beta 3.2% of the variance
"""Risk back, with the funds looked through to what they hold, and as of when."""
from vega_risk import Client
vega = Client()
r = vega.books.risk("zz-golden")
print(f"{r.total_vol_pct:.2f}% a year: factor {r.factor_vol_pct:.2f}%, specific {r.specific_vol_pct:.2f}% ({r.model.label})")
for d in r.top_drivers[:3]:
print(f" {d.label or d.factor}: {d.share_of_variance_pct:.1f}% of the variance")
lt = r.look_through
print(f"{lt.funds_looked_through} of {lt.funds} funds looked through ({lt.looked_through_pct:.1f}% of the book); "
f"the model covers {lt.modelled_pct:.1f}%")
for f in lt.holdings:
print(f" {f.key}: holdings as of {f.holdings_as_of} ({f.holdings_source})" + ("" if f.looked_through else ", not looked through"))
10.74% a year: factor 8.08%, specific 7.08% (House model Vega Global v1.7 (certified), recorded snapshot 21) US equity market: 42.8% of the variance US equity: Information Technology: 18.5% of the variance US equity style: Beta: -4.5% of the variance 5 of 5 funds looked through (30.2% of the book); the model covers 94.7% fund:SPY: holdings as of 2026-06-30 (sec_nport_f3) fund:AGG: holdings as of 2026-05-31 (sec_nport_f3) fund:VT: holdings as of 2026-07-31 (sec_nport_f3) fund:GABBX: holdings as of 2026-06-30 (sec_nport_f3) fund:PAHIX: holdings as of 2026-05-31 (sec_nport_f3)
"""Where last month's return came from: each factor's contribution, from the book's exposures."""
from vega_risk import Client
vega = Client()
a = vega.books.attribution("zz-golden")
print(f"{a.period_start} to {a.period_end} ({a.trading_days} trading days): factor return {a.factor_return_pct:+.2f}%")
print("total:", "withheld" if a.total_return_pct is None else f"{a.total_return_pct:+.2f}%", f"({a.priced_pct:.0f}% of the book priced)")
for c in a.contributions[:3]:
print(f" {c.factor}: {c.contribution_pct:+.3f}%")
2026-09-16 to 2026-10-15 (21 trading days): factor return +2.26% total: withheld (23% of the book priced) ind_45: +1.183% market: +1.029% sty_profitability: +0.542%
"""The latest public U.S. economic series, with their owners."""
from vega_risk import Client
vega = Client()
snap = vega.economy.snapshot()
for s in snap.series[:10]:
print(f"{s['label']:<45} {s['value']:>12} {s['units']:<10} ({s['obs_date']}, {s['owner']})")
Nonfarm payrolls (SA) 159044.0 thousands (2026-09-01, U.S. Bureau of Labor Statistics) Unemployment rate (SA) 4.2 percent (2026-09-01, U.S. Bureau of Labor Statistics) Average hourly earnings, total private (SA) 37.81 dollars (2026-09-01, U.S. Bureau of Labor Statistics) CPI-U all items (SA) 336.298 index 1982-84=100 (2026-09-01, U.S. Bureau of Labor Statistics) CPI-U less food and energy (SA) 338.896 index 1982-84=100 (2026-09-01, U.S. Bureau of Labor Statistics) Job openings (SA) 7079.0 thousands (2026-08-01, U.S. Bureau of Labor Statistics) Hires (SA) 5192.0 thousands (2026-08-01, U.S. Bureau of Labor Statistics) Quits (SA) 3066.0 thousands (2026-08-01, U.S. Bureau of Labor Statistics) Initial claims (SA) 199000.0 persons (2026-10-10, U.S. Department of Labor, Employment and Training Administration) Continuing claims (SA) 1710000.0 persons (2026-10-03, U.S. Department of Labor, Employment and Training Administration)
from vega_risk import Client
vega = Client(api_key="vk_test_...") # a sandbox key: demo books on recorded data
spec = vega.specs.house("fixed_income").set(name="curve_lsc", curve__us="lsc", curve__ns_tau=1.37)
fit = vega.fits.create(spec).wait() # fitted, then backtested against the house: about a minute
risk = vega.books.risk("demo:vega-60-40", model=fit.model_id)
print(f"{risk.total_vol_pct:.2f}% a year", [d.factor for d in risk.top_drivers[:3]])
8.65% a year ['market', 'ind_45', 'KRD_LEVEL']
"""Change one choice of the house fixed-income recipe, fit it, and compare it with the house on a book."""
from vega_risk import Client
vega = Client()
spec = vega.specs.house("fixed_income").set(name="curve_lsc", curve__us="lsc", curve__ns_tau=1.37)
print("recipe fingerprint:", spec.fingerprint)
fit = vega.fits.create(spec).wait() # fitted, then backtested against the house: about a minute
cmp = vega.books.compare("demo:vega-60-40", model_b=fit)
a, b = round(cmp.a.total_vol_pct, 2), round(cmp.b.total_vol_pct, 2) # the change between the figures as printed
print(f"house {a:.2f}% -> yours {b:.2f}% ({b - a:+.2f} points)")
report = vega.fits.report(fit)
print("verdict:", report.report["backtest"]["verdict"]["verdict"])
for row in report.report["backtest"]["books"]["fund:AGG"]["model"]["by_year"]:
print(f" AGG bias {row['year']}: {row['bias']:.3f} over {row['n']} days")
recipe fingerprint: 64eaa8389c55b8d2 house 8.61% -> yours 8.65% (+0.04 points) verdict: rejected AGG bias 2024: 1.005 over 144 days AGG bias 2025: 0.898 over 250 days AGG bias 2026: 1.042 over 196 days
This example model is rejected: in the backtest its risk forecasts were significantly worse than the house model's for one of the test funds, and significantly better for none. Fits that do as well as the house are accepted.
"""Your own model: the house fixed-income recipe with a shorter volatility half-life, fitted, fingerprinted, carded."""
from vega_risk import Client
vega = Client()
spec = vega.specs.house("fixed_income").set(name="zz_client_hl42", covariance__vol_half_life=42)
print("recipe fingerprint:", spec.fingerprint, "(the same recipe always gives this fingerprint)")
fit = vega.fits.create(spec).wait()
card = vega.models.card(fit)
print("model:", card.model.id)
print("certification:", card.certification, "| card sha256:", card.card_sha256)
recipe fingerprint: 7729f6271dd5058b (the same recipe always gives this fingerprint) model: factory:7729f6271dd5058b@rec_s21:cac08f1ec07c7ab2 certification: candidate | card sha256: 385c74f41117f6c6f06b3e3965bdef76a4e341726959c7c5c21f5c37d800dcd1
"""Your model against the house on the same book, with the backtest by year."""
from vega_risk import Client
vega = Client()
mine = next(m.model for m in vega.models.list() if m.model.name == "zz_client_hl42")
cmp = vega.books.compare("zz-golden", model_b=mine.id)
a, b = round(cmp.a.total_vol_pct, 2), round(cmp.b.total_vol_pct, 2)
print(f"house {a:.2f}% -> yours {b:.2f}% ({b - a:+.2f} points)")
print("method:", cmp.b.method)
bt = (cmp.backtest or {}).get("b") or {} # your model's backtest on the recorded fixed-income books
print("verdict:", (bt.get("verdict") or {}).get("verdict"))
agg = ((bt.get("books") or {}).get("fund:AGG") or {}).get("model") or {}
for row in agg.get("by_year") or []: # bias by year beside the whole window, never a bare figure
print(f" AGG bias {row['year']}: {row['bias']:.3f} over {row['n']} days")
house 10.74% -> yours 10.75% (+0.01 points) method: fit: funds on the fit's own vectors (30% of the book), stocks and bonds on the house's unit exposures (64%), the fit's covariance verdict: rejected AGG bias 2024: 0.980 over 144 days AGG bias 2025: 0.940 over 250 days AGG bias 2026: 1.115 over 196 days
This example model is rejected: in the backtest its risk forecasts were significantly worse than the house model's for one of the test funds, and significantly better for none. Fits that do as well as the house are accepted.
"""The same book on a vendor's model, delivered to us as files, scored the same way.
(The vendor here is FAKE and its model made up: test files, not a real vendor's data.)"""
from vega_risk import Client
vega = Client()
vendor = next(m.model for m in vega.models.list() if m.model.id.startswith("foreign:"))
r = vega.books.risk("zz-golden", model=vendor.id)
h = vega.books.risk("zz-golden")
print(f"{vendor.name} (a FAKE vendor's model): {r.total_vol_pct:.2f}% a year on the {r.vendor_coverage_pct:.1f}% of the book it covers "
f"(house: {h.total_vol_pct:.2f}% on the whole book)")
print("fingerprint (the delivery's hash):", vendor.fingerprint)
Fake Risk Co Fake Global Equity 1.0 (a FAKE vendor's model): 21.66% a year on the 93.8% of the book it covers (house: 10.71% on the whole book) fingerprint (the delivery's hash): c41e65f4a71773d6
"""A vendor's model files with our covariance and your own factor: the hybrid, and how it scores against the vendor's own.
(The vendor here is FAKE and its history synthetic: a test history, not a real vendor's data.)"""
from vega_risk import Client
vega = Client()
hybrid = next(m.model for m in vega.models.list() if m.model.id.startswith("composite:"))
card = vega.models.card(hybrid.id).raw
print(card["provenance"]["said"])
print("model:", hybrid.id, "| run:", card["run"]["inputs_hash"], "| card sha256:", card["card_sha256"][:16])
print("covariance:", card["spec"]["join"]["cross_block"]["params"], "on the vendor's factor returns + your", card["spec"]["custom"][0]["name"])
sc = card["scorecard"]
def by_year(rows):
return ", ".join(f"{y} {r['b']:.2f}" + ("*" if r["indicative"] else "") for y, r in rows.items())
for code in ("H0", "H3", "H4"):
s = sc[code]
rb = s["random_books"]
print(f"{s['what']}: random books median bias {rb['bias_median']:.2f} over the whole window; by year: {by_year(rb['by_year'])}")
t = s["client_tilt"]
if t.get("bias") is None:
print(" client-tilt book:", t.get("withheld"))
continue
print(f" client-tilt book bias {t['bias']:.2f} over the whole window; by year: {by_year(t['by_year'])}")
print("bias 1.00 = the model's risk matched what happened; * = fewer than 63 days that year (indicative)")
print("cards (sha256):", {c: sc[c]["card"]["sha256"][:16] for c in ("H0", "H3", "H4")})
Fake Risk Co (a FAKE vendor), synthetic history 2024-2024
model: composite:ffb5b95320001831 | run: e88bf3fe83f13099 | card sha256: 3429fa8765412356
covariance: {'corr_half_life': 126, 'nw_lags': 5, 'vol_half_life': 63} on the vendor's factor returns + your CLIENT_A
the vendor as delivered: random books median bias 1.00 over the whole window; by year: 2023 1.01, 2024 1.03
client-tilt book bias 2.71 over the whole window; by year: 2015 3.52*, 2023 2.76, 2024 2.66
ours + the client factor (this model): random books median bias 1.03 over the whole window; by year: 2023 1.01, 2024 1.03
client-tilt book bias 0.97 over the whole window; by year: 2015 1.26*, 2023 0.99, 2024 0.95
ours + a client factor with no information (control): random books median bias 1.04 over the whole window; by year: 2023 1.01, 2024 1.03
client-tilt book bias 2.25 over the whole window; by year: 2015 2.93*, 2023 2.29, 2024 2.21
bias 1.00 = the model's risk matched what happened; * = fewer than 63 days that year (indicative)
cards (sha256): {'H0': '2f3313ea41a01659', 'H3': '790fe5850c1857ca', 'H4': 'afa8fdd0839eec49'}
"""Many books in one call: a batch job, its progress, and each item's result (the same object the single GET returns)."""
from vega_risk import Client
vega = Client()
books = [b.book_id for b in vega.books.iter()][:20]
items = [dict(book_id=b, kind=k) for b in books for k in ("risk", "exposures")]
job = vega.batches.create(items, idempotency_key="gp-quant-batch-" + "-".join(books)[:80])
print("batch", job.batch_id, "|", job.status, "|", len(items), "items")
done = vega.batches.wait(job.batch_id)
print("status:", done.status, "| progress:", done.progress.done, "of", done.progress.total)
for it in done.items:
if it.kind == "risk" and it.status == "done":
r = it.result
print(f" {it.book_id}: {r['total_vol_pct']:.2f}% a year ({r['model']['label']}, model as of {r['model_as_of']})")
same = vega.batches.create(items, idempotency_key="gp-quant-batch-" + "-".join(books)[:80])
print("the same Idempotency-Key, the same batch:", same.batch_id == job.batch_id)
batch bt_26e54c9c1698b669 | done | 6 items status: done | progress: 6 of 6 zz-golden: 10.71% a year (House model Vega Global v1.7 (certified), recorded snapshot 24, model as of 2026-10-19) zz-golden-sftp: 10.71% a year (House model Vega Global v1.7 (certified), recorded snapshot 24, model as of 2026-10-19) zz-golden-upload: 10.71% a year (House model Vega Global v1.7 (certified), recorded snapshot 24, model as of 2026-10-19) the same Idempotency-Key, the same batch: True
"""What was reported on a past date: risk as of three dates (the model served that day, the book as it stood then)."""
from vega_risk import Client
vega = Client()
for d in ("2026-10-15", "2026-10-16", "2026-10-19"):
r = vega.books.risk("zz-golden", as_of=d)
print(f"as of {d}: {r.total_vol_pct:.4f}% a year | model as of {r.model_as_of} (run {r.model.run}) | positions as of {r.positions_as_of}")
a, b = vega.books.risk("zz-golden", as_of="2026-10-16"), vega.books.risk("zz-golden", as_of="2026-10-16")
print("2026-10-16 asked twice, the same result:", a.raw == b.raw)
for d in ("2026-10-15", "2026-10-19"):
c = vega.models.card("house:vega_global_v1_7", as_of=d)
print(f"model card as of {d}: sha256 {c.card_sha256[:16]}")
as of 2026-10-15: 10.7405% a year | model as of 2026-10-15 (run f305dc77b9caaa91) | positions as of 2026-10-15 as of 2026-10-16: 10.8158% a year | model as of 2026-10-16 (run 8b4baa4941949183) | positions as of 2026-10-15 as of 2026-10-19: 10.7053% a year | model as of 2026-10-19 (run c3087a274e9a5161) | positions as of 2026-10-15 2026-10-16 asked twice, the same result: True model card as of 2026-10-15: sha256 178373e71cba3e0c model card as of 2026-10-19: sha256 12107dfc271b7f72
"""The model's own numbers: factor covariance, each security's exposures and specific risk, on a date, for every model you use.
(The vendor here is FAKE and its model made up: test files, not a real vendor's data.)"""
import math
from vega_risk import Client
vega = Client()
house = "house:vega_global_v1_7"
cov = vega.models.covariance(house)
print(f"{cov.model['label']}: {cov.n} factors, covariance as of {cov.model_as_of} ({cov.units.split(';')[0]})")
two = vega.models.covariance(house, factors=["market", "KRD_10Y"])
for f, row in zip(two.factors, two.sigma):
print(f" {f}: annual vol {100 * math.sqrt(252 * row[two.factors.index(f)]):.2f}%")
keys = [ln.key for ln in vega.books.positions("zz-golden").lines if getattr(ln, "key", None)][:3]
ex = vega.models.exposures(house, keys)
sp = vega.models.specific(house, keys)
for k in keys:
top = sorted(ex.exposures[k].raw.items(), key=lambda kv: -abs(kv[1]))[:3]
print(f" {k}: " + ", ".join(f"{f} {v:+.3f}" for f, v in top) + f" | specific vol {100 * math.sqrt(252 * sp.specific[k]):.2f}% a year")
for m in vega.models.list():
if m.model.id != house:
c = vega.models.covariance(m.model.id)
print(f"{m.model.id}: {c.n} factors, {m.model.label}" + (" (a FAKE vendor's model)" if m.model.id.startswith("foreign:") else ""))
House model Vega Global v1.7 (certified), recorded snapshot 24: 277 factors, covariance as of 2026-10-19 (daily decimal variance) market: annual vol 12.30% KRD_10Y: annual vol 0.84% equity:320193: sty_profitability +1.762, ind_45 +1.000, market +1.000 | specific vol 24.84% a year equity:789019: ind_45 +1.000, market +1.000, sty_liquidity -0.823 | specific vol 27.59% a year equity:19617: ind_40 +1.000, market +1.000, sty_resid_vol -0.439 | specific vol 14.92% a year factory:7729f6271dd5058b@rec_s24:c3087a274e9a5161: 277 factors, Your fixed-income model zz_client_hl42 (research, not certified), fitted on recorded snapshot 24 foreign:7:c41e65f4a71773d6: 9 factors, Your vendor model Fake Risk Co Fake Global Equity 1.0 (as delivered; delivered 2026-10-20) (a FAKE vendor's model) foreign:7:d8394ace6d2cb9f9: 9 factors, Your vendor model Fake Risk Co Fake Global Equity 1.0 (as delivered; delivered 2026-10-20) (a FAKE vendor's model) foreign:7:1e38380b34c2b9ab: 9 factors, Your vendor model Fake Risk Co Fake Global Equity 1.0 (as delivered; delivered 2026-10-20) (a FAKE vendor's model) composite:08531eb047bf5564: 101 factors, Hybrid of Fake Risk Co (a FAKE vendor), synthetic history 2015-2024: the vendor's exposures, our covariance, plus your factor CLIENT_A (research; delivery of 2024-11-29)
"""Where the risk comes from, position by position (the parts add up to the total), and a change's effect before you make it."""
from vega_risk import Client
vega = Client()
c = vega.books.contributions("zz-golden")
print(f"total {c.total_vol_pct:.2f}% a year; the shares add up to {c.check.sum_of_shares_pct:.6f}%")
for p in c.positions[:5]:
print(f" {p.key}: weight {p.weight:.3f}, {p.share_of_variance_pct:5.1f}% of the variance, marginal {p.marginal_vol_pct:+.2f}% per unit weight")
w = vega.books.what_if("zz-golden", [dict(identifier="SPY", identifier_type="ticker", asset_class="fund", delta_weight=0.05),
dict(identifier="AGG", identifier_type="ticker", asset_class="fund", delta_weight=-0.05)])
for k in ("total_vol_pct", "factor_vol_pct", "specific_vol_pct"):
print(f" {k.replace('_vol_pct', '')}: {w.before[k]:.3f}% -> {w.after[k]:.3f}% ({w.difference[k]:+.3f})")
print(w.note)
total 10.71% a year; the shares add up to 100.000000% equity:320193: weight 0.214, 47.2% of the variance, marginal +23.63% per unit weight equity:789019: weight 0.160, 37.9% of the variance, marginal +25.31% per unit weight equity:19617: weight 0.077, 4.5% of the variance, marginal +6.27% per unit weight fund:SPY: weight 0.051, 4.2% of the variance, marginal +8.85% per unit weight fund:VT: weight 0.051, 3.2% of the variance, marginal +6.68% per unit weight total: 10.705% -> 11.137% (+0.432) factor: 8.083% -> 8.641% (+0.558) specific: 7.019% -> 7.027% (+0.008) weights of the book's valued lines; nothing is stored or traded
Each route below lists only its own responses; these apply to all of them.
| 400 | malformed request (key_in_query, ...) |
| 401 | missing_key, invalid_key, key_revoked, key_expired, jwt_not_accepted |
| 403 | missing_scope |
| 404 | not found for this key (another tenant's id is answered the same way) |
| 409 | fit_not_done, book_exists, idempotency_in_progress |
| 422 | invalid_request, positions_refused (the positions v1 validator's report in detail) |
| 429 | rate_limited, quota_exceeded (Retry-After header) |
| 501 | not_in_sandbox (the sandbox serves recorded data only) |
| 503 | not_bound, audit_unavailable |
No route matches.
The Outcome Model API is live in pilot. Client access opens when our return assumptions are published; request access now and we'll set up your shelf. What follows documents the request it takes and the record it returns.
It builds a model portfolio toward a stated goal, such as reaching an amount by a date or paying an income for a number of years, using Vega's risk model and return assumptions on a fund shelf the manager chooses, such as its own funds.
Every projected figure is labeled hypothetical. Projections are not a forecast or a guarantee.
A person reviews each model before it is delivered. Models reach the manager as files, and what to do with them is the manager's decision. The API does not place trades and does not assign models to accounts.
| Outcome routes (optimize, jobs, model portfolios, saved requests) | Live in pilot (internal and demo accounts) |
|---|---|
| The engine that solves | Runs behind the API; every result records the engine version and configuration that produced it |
| Return assumptions | A draft, not yet published: every result is labeled draft |
| Stress scenarios | One stress scenario, Covid-style, comes back without a figure for now |
POST /v1/shelvesPUT /v1/shelves/{shelf_id}GET /v1/shelvesGET /v1/shelves/{shelf_id}POST /v1/outcomes/optimize (202: a job)GET /v1/jobsGET /v1/jobs/{job_id}GET /v1/jobs/{job_id}/resultGET /v1/model-portfoliosGET /v1/model-portfolios/{model_id}GET /v1/model-portfolios/{model_id}/versionsGET /v1/model-portfolios/{model_id}/versions/{version}POST /v1/model-portfolios/{model_id}/submitPOST /v1/model-portfolios/{model_id}/retireGET /v1/model-portfolios/{model_id}/diffGET /v1/model-portfolios/{model_id}/exportPOST /v1/saved-requestsGET /v1/saved-requestsGET /v1/saved-requests/{saved_id}universe.funds | the funds the engine may use, each a line of your shelf: 1 to 300 unique tickers, in any order. Without it, the engine uses all the funds on your shelf |
|---|---|
outcome.starting_assets | assets today: more than 0, up to 1,000,000,000 |
outcome.account.type | taxable or tax_deferred |
outcome.contributions[] | savings each year in today's dollars: start_year, end_year, amount_per_year; years 1 to 60, end not before start; up to 10 |
outcome.kind | one goal: target_wealth or income |
amount, horizon_years | target_wealth: the target in today's dollars (more than 0), in 1 to 60 years |
amount_per_year, start_year, years | income: the amount a year in today's dollars (more than 0), the first year (1 to 60), and years (1 to 60) or for_life |
outcome.for_life | plan the income for life, which sets the planning age: age 18 to 100, optional sex, optional spouse (age, optional sex), optional fixed_age 50 to 110 |
outcome.guaranteed_income[] | Social Security and other outside income: optional label, start_age 18 to 100, amount_per_year, cola ("cpi" or -5% to 10%); up to 4 |
required_probability | the required chance: 0.5 to 0.99; 0.8 when absent |
outcome.goals[] | several goals instead of one kind: name, priority (needs or wants), kind and its fields, optional required_probability; 1 to 8, not nested |
client | a label for people (label up to 80 characters, summary up to 400). It is not sent to the engine and does not change the result |
Priority is needs or wants; other values are refused, as are other account types, unknown fields and values of the wrong type. A fund that is not on your shelf is refused with 422 fund_not_on_shelf. House benchmark funds are used as reference and are held only when they're on your shelf.
| Who and when | tenant_id, model_id, version, name, created_at, status (draft, submitted, approved, retired), approval (name, email, time, note) once a person signs off |
|---|---|
| What it was computed on | risk_set, cma (version, sha256, draft), engine (sha, configuration, solver, library versions, tolerances), seed, paths |
| The solve | role, solve (status optimal or best_found_within_time, retries). A best_found_within_time solve, or one with retries, is saved but can't be approved |
| The portfolio | lines: series_id, class_id, ticker (display only), name, weight, risk_method (holdings_based, returns_based, proxy_total_vol, proxy_category, money_market), estimated, lookthrough, covered_as_cash, expense_ratio, modeled_share, equity_share, equity_estimated, cusip, isin; cash_target |
| Figures (hypothetical) | analytics: expected_return, vol, p_success, required_probability, meets_goal, expense_ratio, te, sharpe, beta_to_benchmark, cvar95_annual |
| Coverage | look_through, weighted_average_share, share_with_measured_risk_basis |
| Labels | labels (hypothetical, draft, interim), excluded_funds (with the reason), disclosures |
| Integrity | result_sha256, request_fingerprint (same inputs), fingerprint (same content) |
The seed is a hash of what the engine receives, with the configuration, the data, the return assumptions and the risk model, so the same request returns the same result, bit for bit. The client block is a label for people and never changes the result. Which funds you list and every outcome value do; the order you list them in does not.
An illustration of the figures and labels from one run of the engine on a hypothetical client, recorded on snapshot 34. It is the engine's output, not an API response. Fund names are placeholders.
{ "portfolio": { "role": "max_probability", "meets_goal": false,
"weights": [ {"ticker": "FUND_A", "weight": 0.1994, "risk_method": "holdings_based"},
{"ticker": "FUND_B", "weight": 0.1425, "risk_method": "holdings_based"}, "… 9 more" ],
"analytics": { "expected_return": 0.0596, "vol": 0.0531, "cvar95_annual": 0.0594,
"fees": {"expense_ratio": 0.0005}, "projection": {"p_success": 0.6276} } },
"disclosures": [ "Illustrative · hypothetical · not investment advice",
"Hypothetical results produced by a model from assumptions; not the results of any account and not a guarantee." ] }It falls short of the goal, a 62.8% hypothetical chance against 80% required, and the result says so.
Tell us what you would like to build; we review each request and send a key.