Close Navigation
.
Retrieval-Augmented Diffusion for SDF Portfolios

Retrieval-Augmented Diffusion for SDF Portfolios

Posted November 16, 2026 at 2:30 pm

Aryan Manjunatha
Aryan's Quant Blog

Summary

This model combines three ideas that are usually met separately. The objective is not a forecast error but a pricing error: the portfolio is treated as a proxy for a stochastic discount factor, and training minimises a regularised Hansen–Jagannathan distance, which has a closed-form first-order condition worth examining before any network is built. The representation is generated rather than predicted: a diffusion model produces a distribution over embeddings instead of a point estimate. And the diffusion prior is retrieved rather than assumed: instead of corrupting towards isotropic noise, the forward process walks towards the mean and spread of the nearest historical episodes, drawn from a context bank under a strict causal mask. The article derives the objective, explains the retrieval-anchored diffusion, gives a complete PyTorch implementation, and uses the worked example to make a point the architecture obscures — that the regularisation term, not the generative machinery, determines how far the output can move from equal weight.


1. Introduction

Most machine learning applied to the cross-section of returns is a forecasting exercise: predict next period’s return from characteristics, then build a portfolio from the predictions. The approach has a well-documented problem, which is that predictive R2 in the cross-section of returns is tiny and unstable, and the mapping from a slightly better forecast to a better portfolio is not monotone.

Asset pricing offers a different target. The fundamental condition of no-arbitrage is that there exists a stochastic discount factor M such that every excess return has zero price under it. That condition is a moment restriction, and it can be made into a loss function. A line of work in deep asset pricing (Kozak, Nagel & Santosh, 2020; Chen, Pelger & Zhu, 2024) builds the discount factor as a portfolio and trains a network to minimise the resulting pricing errors. The quantity being optimised is economically meaningful in a way that mean squared forecast error is not.

The second and third ideas address the input side. A single embedding of recent market conditions is a point estimate of something inherently uncertain; a diffusion model (Ho, Jain & Abbeel, 2020) replaces it with a distribution that can be sampled. And since financial history is not long but is repetitive, the prior for that generative model need not be uninformative: if today’s conditions resemble a set of identifiable past episodes, the model can be told to generate near them. Retrieval augmentation of this kind came from language modelling (Lewis et al., 2020) and has been applied to time-series diffusion (Liu et al., 2024). The combination — retrieval-anchored diffusion feeding an SDF objective — is the model described here.


2. The model

The pricing condition. No-arbitrage requires, for every asset’s excess return yi,

𝔼[Mt+1yi,t+1]=0,i=1,…,N

Following the GMM tradition, the discount factor is parameterised as a portfolio of the assets themselves — the discount factor and the efficient portfolio are two views of the same object:

Mt+1=1−∑i=1Nwi,tyi,t+1

The objective. Squaring and averaging the pricing errors, and adding a ridge penalty on the weights, gives the regularised Hansen–Jagannathan distance that the network minimises:

ℒSDF(w)=𝔼[(1−∑iwiyi)2]+λ∑iwi2

What that objective actually asks for. This is worth doing by hand before trusting any architecture built on top of it. Differentiating with respect to w and setting the gradient to zero,

−2𝔼[y(1−w′y)]+2λw=0⟹w⋆=(𝔼[yy′]+λI)−1𝔼[y]

The optimum is a ridge-regularised portfolio built from the second-moment matrix and the mean vector — an estimator in the mean–variance family, reached through a pricing argument rather than a utility argument. The derivation treats w as unconstrained; the softmax restricts it to the simplex, which changes the algebra but not the conclusions. Two of those follow immediately and both matter for how the model behaves. The penalty λ governs the size of the tilt: for large λ, w⋆ ≈ λ−1E[y], so the magnitude of the position shrinks like 1/λ — towards zero unconstrained, and towards 1/N on the simplex. And the objective is driven by the first and second moments of returns only; the network’s entire contribution is to make those conditional on the current state.

Weights by construction. The network emits scores and a softmax turns them into weights:

wt=softmax(gϕ(zt)),wi,t>0,∑iwi,t=1

Long-only and fully invested hold exactly. Since an untrained network produces near-uniform scores, training starts at equal weight; combined with the ridge penalty, which on the simplex is minimised at exactly 1/N, the model’s default state is the equal-weighted portfolio and everything it learns is a tilt away from it.

Diffusion, anchored on retrieval. A standard denoising diffusion model corrupts a clean representation x0 towards standard normal noise, with ᾱs the cumulative noise schedule:

q(xs∣x0)=𝒩(α¯sx0, (1−α¯s)I)

Here the terminal distribution is replaced by something informative. Let μR and σR be the mean and standard deviation of the K retrieved neighbours of the current query. The forward process becomes

xs=α¯sx0+1−α¯s(μR+σR⊙ϵ),ϵ~𝒩(0,I)

At s = 0 nothing is corrupted; at the terminal step the sample is drawn from the retrieved distribution rather than from white noise. The reverse chain therefore begins somewhere informative, and the denoiser’s job is the easier one of refining a plausible starting point.

Causal retrieval. The bank stores past segments as key–value pairs, each stamped with the period in which its information set ends. A query at t ranks entries by cosine similarity and takes the top K, but only among entries whose stamp is at or before t:

𝒩K(t)=top-K of {⟨qt,kj⟩‖qt‖‖kj‖:ej≤t}

This mask is not a detail. Retrieval is precisely the mechanism by which a model of this shape can see the future, and the whole construction is only meaningful if the mask is airtight.

Training and assembly. The denoiser is trained to recover the clean embedding while the allocation head is trained on the pricing loss, with one coefficient balancing them: L = LSDF + ρ Ldiff. At inference the reverse chain is run several times and averaged, and the denoised channels are mixed with the raw query through a single interpolation parameter, z = (1 − γ)(q̂ + ĉ) + γ q, where γ controls how much of the generated representation is trusted against the directly encoded one.


3. How it works

  1. Encode. Two encoders read a window of price-derived features and a window of event-derived features for each asset, and a linear layer fuses them into one embedding per asset.
  2. Retrieve. The fused embedding queries the context bank. Entries stamped after the query period are masked to −∞ before the top-K selection, so no retrieved neighbour can carry future information. The neighbours’ mean and standard deviation define the anchor distribution.
  3. Diffuse (training). A noise level is sampled per asset and period; the embedding is corrupted towards the anchor; the denoiser — self-attention over three tokens, the noisy embedding, the anchor mean and a step embedding — predicts the clean embedding. The reconstruction error is the diffusion loss.
  4. Diffuse (inference). The reverse chain starts from the anchor distribution and alternates predicting the clean embedding and re-noising to a lower level. Several draws are averaged.
  5. Allocate. The mixed representation passes through a small head to produce one score per asset; a softmax produces weights that are positive and sum to one.
  6. Score. The pricing loss is evaluated on the realised returns over the holding period, and the two losses are back-propagated together.
  7. Hold. Weights chosen at the close of a decision period are held over the next H periods and then recomputed. The holding period is a modelling choice that interacts with everything else: it sets the horizon of the returns in the loss, the turnover of the book and the number of independent evaluation points.

4. Python implementation

PyTorch. The four blocks are the objective, the retrieval bank, the retrieval-anchored diffusion, and the assembled model.

The objective. Six lines. Everything derived in Section 2 is in them, and the ridge coefficient lam is the parameter that decides how far the model may move from equal weight.

import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F

def sdf_loss(scores, y, lam=1e-2):
    """Regularised Hansen-Jagannathan distance of a long-only, fully invested book.

    scores : (B, N) raw asset scores.  y : (B, N) realised returns over the holding period.
    The softmax starts the model at equal weight, so training only ever learns tilts.
    """
    w = torch.softmax(scores, dim=-1)
    gross = 1.0 + (w * y).sum(-1)                 # gross return of the book
    return ((1.0 - gross) ** 2).mean() + lam * (w ** 2).sum(-1).mean()

The context bank. The bank is kept sorted by end stamp, which turns the causal filter into a single searchsorted and a mask — cheap enough to apply on every query. Keys are stored normalised so that similarity is a dot product.

class ContextBank(nn.Module):
    """Stores past segments as (key, value) pairs stamped with the period they end in."""

    def __init__(self, dim, capacity=4096):
        super().__init__()
        self.register_buffer("keys", torch.zeros(capacity, dim))
        self.register_buffer("vals", torch.zeros(capacity, dim))
        self.register_buffer("ends", torch.zeros(capacity, dtype=torch.long))
        self.size = 0

    @torch.no_grad()
    def add(self, keys, vals, ends):
        n = len(keys)
        sl = slice(self.size, self.size + n)
        self.keys[sl], self.vals[sl], self.ends[sl] = F.normalize(keys, dim=-1), vals, ends
        self.size += n
        order = torch.argsort(self.ends[:self.size])      # keep the bank time-ordered
        self.keys[:self.size] = self.keys[:self.size][order]
        self.vals[:self.size] = self.vals[:self.size][order]
        self.ends[:self.size] = self.ends[:self.size][order]

    @torch.no_grad()
    def query(self, q, t, k=8):
        """Top-k cosine neighbours among entries that finished at or before t.

        q : (B, N, d) queries.  t : (B,) query periods.  Entries stamped later than t
        are masked out, so no retrieved neighbour carries information from the future.
        """
        S = self.size
        sims = F.normalize(q, dim=-1) @ self.keys[:S].T   # (B, N, S)
        n_ok = torch.searchsorted(self.ends[:S].contiguous(), t, right=True)
        idx = torch.arange(S, device=q.device)
        sims = sims.masked_fill(idx[None, None, :] >= n_ok[:, None, None], -torch.inf)
        top = sims.topk(min(k, S), dim=-1)
        v = self.vals[:S][top.indices]                    # (B, N, k, d)
        return v.mean(2), (v.var(2, unbiased=False) + 1e-6).sqrt()

Retrieval-anchored diffusion. Note that noise_towards is used in both directions: forward during training with a sampled step, and inside the sampler to step down the chain. The denoiser is given the anchor mean as an explicit token rather than concatenated, so attention can weigh it against the noisy input.

class Schedule:
    def __init__(self, steps=100, beta0=1e-4, beta1=2e-2):
        self.steps = steps
        beta = torch.linspace(beta0, beta1, steps)
        self.abar = torch.cumprod(1.0 - beta, dim=0)


class Denoiser(nn.Module):
    """Self-attention over a handful of tokens; predicts the clean embedding."""

    def __init__(self, dim, n_heads=4):
        super().__init__()
        self.step_emb = nn.Embedding(512, dim)
        self.attn = nn.MultiheadAttention(dim, n_heads, batch_first=True)
        self.out = nn.Sequential(nn.LayerNorm(dim), nn.Linear(dim, 2 * dim), nn.GELU(),
                                 nn.Linear(2 * dim, dim))

    def forward(self, x_noisy, mu, s):
        shape = x_noisy.shape
        tok = torch.stack([x_noisy, mu, self.step_emb(s).expand_as(x_noisy)], dim=-2)
        tok = tok.reshape(-1, 3, shape[-1])               # attention wants (B, tokens, d)
        a, _ = self.attn(tok, tok, tok, need_weights=False)
        return self.out(a[:, 0, :]).reshape(shape)        # predicted clean embedding


def noise_towards(x0, s, mu, sig, sched):
    """Forward step: corrupt the embedding towards the retrieved distribution.

    Standard diffusion walks towards N(0, I); here the terminal distribution is the
    mean and spread of the retrieved neighbours, so the prior carries information.
    """
    ab = sched.abar[s].view(*s.shape, *([1] * (x0.dim() - s.dim())))
    return ab.sqrt() * x0 + (1 - ab).sqrt() * (mu + sig * torch.randn_like(x0))


@torch.no_grad()
def sample(denoiser, mu, sig, sched, n_draws=4, stride=10):
    """Run the reverse chain from the retrieved prior and average a few draws."""
    out = 0.0
    for _ in range(n_draws):
        x = mu + sig * torch.randn_like(mu)
        for s in range(sched.steps - 1, 0, -stride):
            step = torch.full(mu.shape[:-1], s, dtype=torch.long, device=mu.device)
            x0 = denoiser(x, mu, step)
            x = noise_towards(x0, torch.clamp(step - stride, min=0), mu, sig, sched)
        out = out + denoiser(x, mu, torch.zeros_like(step))
    return out / n_draws

The assembled model. The forward method branches on whether realised returns were supplied: with them, one noise level and the combined loss; without them, the full reverse chain and the weights.

class Radar(nn.Module):
    def __init__(self, n_price, n_event, dim=32, gamma=0.5, rho=0.1):
        super().__init__()
        self.price_enc = nn.GRU(n_price, dim, batch_first=True)
        self.event_enc = nn.GRU(n_event, dim, batch_first=True)
        self.fuse = nn.Linear(2 * dim, dim)
        self.bank = ContextBank(dim)
        self.denoiser = Denoiser(dim)
        self.sched = Schedule()
        self.head = nn.Sequential(nn.LayerNorm(dim), nn.Linear(dim, dim), nn.GELU(),
                                  nn.Linear(dim, 1))
        self.gamma, self.rho = gamma, rho

    def encode(self, price, event):                       # (B, N, L, f) -> (B, N, d)
        B, N = price.shape[:2]
        p = self.price_enc(price.reshape(B * N, *price.shape[2:]))[0][:, -1]
        c = self.event_enc(event.reshape(B * N, *event.shape[2:]))[0][:, -1]
        q = self.fuse(torch.cat([p, c], dim=-1)).view(B, N, -1)
        return q, c.view(B, N, -1)

    def forward(self, price, event, t, y=None, k=8):
        q, c = self.encode(price, event)
        mu, sig = self.bank.query(q, t, k=k)
        if y is not None:                                 # training: one noise level
            s = torch.randint(0, self.sched.steps, q.shape[:-1], device=q.device)
            q_hat = self.denoiser(noise_towards(q, s, mu, sig, self.sched), mu, s)
            c_hat = self.denoiser(noise_towards(c, s, mu, sig, self.sched), mu, s)
            l_diff = F.mse_loss(q_hat, q) + F.mse_loss(c_hat, c)
        else:                                             # inference: the full chain
            q_hat = c_hat = sample(self.denoiser, mu, sig, self.sched)
            l_diff = torch.zeros((), device=q.device)
        z = (1 - self.gamma) * (q_hat + c_hat) + self.gamma * q
        scores = self.head(z).squeeze(-1)
        if y is None:
            return torch.softmax(scores, dim=-1)
        return sdf_loss(scores, y) + self.rho * l_diff, scores

A worked example. The synthetic data embed a deliberately simple signal — a linear combination of the last few steps of both feature channels — so that the pipeline can be checked for whether it recovers a signal that is definitely present. The bank is seeded from the same batch, which is adequate for a mechanical check and is not how a bank would be built in a real walk-forward setting.

torch.manual_seed(0)
rng = np.random.default_rng(0)
B, N, Lp, Le, Fp, Fe, H = 64, 20, 60, 20, 4, 3, 7

price = torch.tensor(rng.standard_normal((B, N, Lp, Fp)) * 0.01, dtype=torch.float32)
event = torch.tensor(rng.standard_normal((B, N, Le, Fe)) * 0.50, dtype=torch.float32)
signal = price[..., -5:, 0].mean(-1) + 0.3 * event[..., -5:, 0].mean(-1)
y = (signal * 0.5 + torch.randn(B, N) * 0.02) * H ** 0.5     # H-period returns
t = torch.arange(B)                                          # one query per period

model = Radar(Fp, Fe)
with torch.no_grad():                                        # seed the bank causally
    q, c = model.encode(price, event)
    model.bank.add(q[:, 0], c[:, 0], t)

opt = torch.optim.Adam(model.parameters(), lr=3e-3)
for epoch in range(40):
    opt.zero_grad()
    loss, scores = model(price, event, t, y=y)
    loss.backward()
    opt.step()
    if epoch % 10 == 0 or epoch == 39:
        print("  epoch %3d  loss %.6f" % (epoch, loss.item()))

model.eval()
with torch.no_grad():
    w = model(price, event, t).numpy()
print("weights sum to %.4f, min %.4f, max %.4f"
      % (w.sum(-1).mean(), w.min(), w.max()))
print("mean distance from equal weight %.5f  (equal weight is %.4f)"
      % (np.abs(w - 1.0 / N).mean(), 1.0 / N))
print("rank correlation of weights with realised return %.3f"
      % np.corrcoef(w.ravel().argsort().argsort(),
                    y.numpy().ravel().argsort().argsort())[0, 1])

Output:

  epoch   0  loss 0.012908
  epoch  10  loss 0.001842
  epoch  20  loss 0.001212
  epoch  30  loss 0.001058
  epoch  39  loss 0.001005
weights sum to 1.0000, min 0.0475, max 0.0523
mean distance from equal weight 0.00060  (equal weight is 0.0500)
rank correlation of weights with realised return 0.529

The last three lines are the most instructive output in this article. The rank correlation of 0.53 between weights and realised returns shows the model found the signal: the ordering is largely right. And yet the weights span only 4.75 % to 5.23 % around an equal weight of 5.00 %, a mean absolute deviation of six basis points. The architecture — encoders, retrieval, a hundred-step diffusion chain, attention denoiser — is identifying the cross-section correctly and then expressing that view in tilts of six basis points. Nothing is broken. This is the closed-form condition of Section 2 operating as derived: with a ridge penalty on simplex-constrained weights, the optimal tilt is proportional to 1/λ, and the generative machinery upstream has no influence over that constant whatsoever. Any evaluation of a model of this family should begin by reporting the distance of its weights from equal weight, because a book that sits on top of 1/N will largely inherit the behaviour of 1/N.


5. Merits

  • The loss is a pricing condition, not a forecast error
    Minimising pricing errors targets the quantity asset pricing theory says should be zero, and it weights assets by their contribution to the portfolio rather than treating every observation as equally important. The objective also has a closed-form optimum, which means the model’s intended behaviour can be checked analytically before training.
  • An informative prior instead of noise
    Anchoring the diffusion on retrieved neighbours means the generative model begins from a plausible configuration. The retrieved mean and spread also carry a natural uncertainty signal: when today resembles many similar past episodes, the anchor is tight; when it resembles few, it is wide.
  • Non-parametric memory alongside parametric learning
    Rare configurations can inform the model through retrieval without needing parameters dedicated to them. The bank can be extended with new history without retraining, which is a genuinely useful property for a model that must keep running.
  • Auditable causality
    Because retrieval eligibility is an explicit timestamp comparison, the most dangerous information leak in the architecture is reduced to one line of code that can be unit-tested. That is better than leakage distributed implicitly through a feature pipeline.
  • Conservative by default
    Softmax weights with a ridge penalty start at equal weight, are long-only and never lever. The model has to earn every deviation, and the deviation it earns is bounded by a parameter that is set rather than learned.
  • Cleanly ablatable
    Retrieval is the only difference between this model and the same model with isotropic noise, so the central claim can be tested by changing one argument. Similarly for each feature channel. A design that makes its own hypotheses falsifiable is worth something.

6. Demerits

  • The regulariser dominates the architecture
    As the worked example shows, how far the book may depart from equal weight is set by λ and the simplex constraint — not by the quality of the representation. A great deal of machinery can therefore produce a portfolio that is nearly 1/N, and reported results that look like a mild improvement on equal weight may be close to arithmetically guaranteed. This should be measured and reported, not assumed away.
  • The pricing framing does less than it appears
    With returns measured over short horizons, the term (1 − w′y)2 is dominated by the constant, and the objective is well approximated by a ridge-penalised mean maximisation. The derivation in Section 2 makes this explicit: the solution is in the mean–variance family. The economic language is correct but should not be mistaken for an economic constraint that the model is enforcing.
  • Nearest neighbours in a learned space need not be economically similar
    Cosine similarity between embeddings produced by an encoder trained on a pricing loss has no guarantee of selecting comparable market conditions. The neighbours are whatever the encoder has learned to place nearby, and that can change during training — which also means the keys written to the bank early in training are stale by the end of it.
  • There are not many genuinely distinct market episodes to retrieve
    Decades of daily data contain a limited number of independent regimes. Retrieval with overlapping windows will frequently return near-duplicates of the same episode, so the effective K is smaller than the nominal K, and the anchor’s spread understates true uncertainty.
  • Causal masking is necessary but not sufficient
    A correct mask prevents retrieval from the future. It does nothing about information entering through the parameters: if encoders, denoiser and head are trained once on the full sample, then every evaluation period was seen in training. Only walk-forward retraining with a bank built as of each date closes that channel, and it multiplies the computational cost.
  • Averaging samples discards the point of being generative
    Running the reverse chain several times and averaging the result converges to a point estimate. If only the mean is used downstream, a deterministic encoder of comparable capacity is the natural baseline, and that comparison is the one a reader will want.
  • Uncertainty lives in embedding space, where it has no units
    The spread produced by the diffusion model is dispersion over learned representations. It is not a calibrated predictive distribution over returns, and it cannot be used as one without a further calibration step that the architecture does not provide.
  • Inference cost is substantial and buys little
    A hundred-step chain, multiplied by several draws, by every asset, at every decision period. The usual finding with diffusion samplers is that far fewer steps suffice; the cost should be justified by an ablation over step count rather than inherited from the image-generation literature.
  • A long list of interacting hyperparameters
    K, γ, ρ, λ, the number of steps, the noise schedule, the embedding dimension, the holding period. Each is chosen on short validation data, and the search itself is a source of selection bias that deflation adjustments exist to penalise (Bailey & López de Prado, 2014; Harvey, Liu & Zhu, 2016).
  • Retrieval presumes history rhymes
    The mechanism is valuable exactly when the present resembles the past, and silently unhelpful when it does not. There is no internal signal that distinguishes “no close neighbours exist” from “the close neighbours are misleading”; both produce a confident-looking anchor.
  • Evaluation choices can dominate the model
    Holding period, rebalancing frequency, the universe filter and the treatment of costs each move results by more than most architectural changes. Multiple comparisons against several baselines require a formal correction — a model confidence set or a test of superior predictive ability — rather than a table of the best numbers (Hansen, 2005; Hansen, Lunde & Nason, 2011).

7. References

  1. Bailey, D. H., & López de Prado, M. (2014). The deflated Sharpe ratio: Correcting for selection bias, backtest overfitting, and non-normality. The Journal of Portfolio Management, 40(5), 94–107. https://doi.org/10.3905/jpm.2014.40.5.094
  2. Chen, L., Pelger, M., & Zhu, J. (2024). Deep learning in asset pricing. Management Science, 70(2), 714–750. https://doi.org/10.1287/mnsc.2023.4695
  3. Hansen, L. P., & Jagannathan, R. (1991). Implications of security market data for models of dynamic economies. Journal of Political Economy, 99(2), 225–262. https://doi.org/10.1086/261749
  4. Hansen, P. R. (2005). A test for superior predictive ability. Journal of Business & Economic Statistics, 23(4), 365–380. https://doi.org/10.1198/073500105000000063
  5. Hansen, P. R., Lunde, A., & Nason, J. M. (2011). The model confidence set. Econometrica, 79(2), 453–497. https://doi.org/10.3982/ECTA5771
  6. Harvey, C. R., Liu, Y., & Zhu, H. (2016). … and the cross-section of expected returns. The Review of Financial Studies, 29(1), 5–68. https://doi.org/10.1093/rfs/hhv059
  7. Ho, J., Jain, A., & Abbeel, P. (2020). Denoising diffusion probabilistic models. Advances in Neural Information Processing Systems, 33. arXiv:2006.11239. https://arxiv.org/abs/2006.11239
  8. Koa, K. J. L., Li, X., & Huang, K.-W. (2026). Retrieval-augmented diffusion modeling for stochastic discount factor portfolios. arXiv:2609.35086. https://arxiv.org/abs/2609.35086
  9. Kozak, S., Nagel, S., & Santosh, S. (2020). Shrinking the cross-section. Journal of Financial Economics, 135(2), 271–292. https://doi.org/10.1016/j.jfineco.2019.06.008
  10. Lewis, P., Perez, E., Piktus, A., Petroni, F., Karpukhin, V., Goyal, N., … Kiela, D. (2020). Retrieval-augmented generation for knowledge-intensive NLP tasks. Advances in Neural Information Processing Systems, 33. arXiv:2005.11401. https://arxiv.org/abs/2005.11401
  11. Liu, J., Yang, L., Li, H., & Hong, S. (2024). Retrieval-augmented diffusion models for time series forecasting. Advances in Neural Information Processing Systems, 37. arXiv:2410.18712. https://arxiv.org/abs/2410.18712
  12. Tashiro, Y., Song, J., Song, Y., & Ermon, S. (2021). CSDI: Conditional score-based diffusion models for probabilistic time series imputation. Advances in Neural Information Processing Systems, 34. arXiv:2107.03502. https://arxiv.org/abs/2107.03502

Disclosure

This article is written for educational purposes. It describes a modelling technique and provides reference code run on synthetic data; it is not investment research, a recommendation, or an offer to buy or sell any security. No performance is claimed or implied, and nothing here should be read as a prediction of returns. Any implementation decision remains the responsibility of the reader.


Continue exploring the series with another article: Deep Learning for Portfolio Optimisation.

Disclosure: Interactive Brokers Third Party

Information posted on IBKR Campus that is provided by third-parties does NOT constitute a recommendation that you should contract for the services of that third party. Third-party participants who contribute to IBKR Campus are independent of Interactive Brokers and Interactive Brokers does not make any representations or warranties concerning the services offered, their past or future performance, or the accuracy of the information provided by the third party. Past performance is no guarantee of future results.

This material is from Aryan's Quant Blog and is being posted with its permission. The views expressed in this material are solely those of the author and/or Aryan's Quant Blog and Interactive Brokers is not endorsing or recommending any investment or trading discussed in the material. This material is not and should not be construed as an offer to buy or sell any security. It should not be construed as research or investment advice or a recommendation to buy, sell or hold any security or commodity. This material does not and is not intended to take into account the particular financial conditions, investment objectives or requirements of individual customers. Before acting on this material, you should consider whether it is suitable for your particular circumstances and, as necessary, seek professional advice.

Disclosure: API Proof-of-Concept Disclosure

The third-party code discussed within this article is not investment or trading advice, and is for proof-of-concept, educational, and illustrative purposes only. IBKR makes no representations or warranty regarding its accuracy or completeness. Users are solely responsible for conducting their own independent testing and due diligence before applying any code or concepts in a live or production environment

Disclosure: API Examples Discussed

Please keep in mind that the examples discussed in this material are purely for technical demonstration purposes, and do not constitute trading advice. Also, it is important to remember that placing trades in a paper account is recommended before any live trading.

Join The Conversation

For specific platform feedback and suggestions, please submit it directly to our team using these instructions.

If you have an account-specific question or concern, please reach out to Client Services.

We encourage you to look through our FAQs before posting. Your question may already be covered!

Leave a Reply

IBKR Campus Newsletters

This website uses cookies to collect usage information in order to offer a better browsing experience. By browsing this site or by clicking on the "ACCEPT COOKIES" button you accept our Cookie Policy.