SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2505.15155 · NeurIPS · 2025

R&D-Agent-Quant: A Multi-Agent Framework for Data-Centric Factors and Model Joint Optimization

Xiao Yang, Weiqing Liu, Jiang Bian, Xu Yang, Yuante Li, Minrui Xu, Xisen Wang

arXiv · PDF · Open in the Atlas

Code that ran

7 of 10 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 7 have no contract verdict; 0 failures of our instrument; 3 no recorded run), measured 2026-11-24; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2505.15155.json · badge: /api/ran/2505.15155.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
microsoft/qlib canonical (classifier label)
classifier basis not recorded on the link
2 ran · 2 no recorded run
SJTU-DMTai/MASTER community
Papers with Code archive
5 ran · 1 no recorded run
FunctionStatusWhere it lives
Gate Ran
ran on a synthesized input
SJTU-DMTai/MASTER/qlib-update/pytorch_master_ts.py
code served (permissive licence) · get_code("71e2b1c20027624e")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 2, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
from torch import nn

class Gate(nn.Module):

    def __init__(self, d_input, d_output, beta=1.0):
        super().__init__()
        self.trans = nn.Linear(d_input, d_output)
        self.d_output = d_output
        self.t = beta

    def forward(self, gate_input):
        output = self.trans(gate_input)
        output = torch.softmax(output / self.t, dim=-1)
        return self.d_output * output


INIT_ARGS = {
    'd_input': 4,
    'd_output': 3,
    'beta': 1.0
}

ARGS = {
    'gate_input': torch.randn(2, 4)
}

gate = Gate(**INIT_ARGS)
result = gate(**ARGS)
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family float — no output shape is stated: observe_signature.py observed this class with its constructor sizes canonicalised where it could, which the node does not record, so its shape is not stated as this setup block's
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
PositionalEncoding Ran
ran on a synthesized input
SJTU-DMTai/MASTER/qlib-update/pytorch_master_ts.py
code served (permissive licence) · get_code("c43b48bd5345165d")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 3, dtype family float, shape (2, 3, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import math
import torch
from torch import nn

class PositionalEncoding(nn.Module):

    def __init__(self, d_model, max_len=100):
        super(PositionalEncoding, self).__init__()
        pe = torch.zeros(max_len, d_model)
        position = torch.arange(0, max_len, dtype=torch.float).unsqueeze(1)
        div_term = torch.exp(torch.arange(0, d_model, 2).float() * (-math.log(10000.0) / d_model))
        pe[:, 0::2] = torch.sin(position * div_term)
        pe[:, 1::2] = torch.cos(position * div_term)
        self.register_buffer('pe', pe)

    def forward(self, x):
        return x + self.pe[:x.shape[1], :]


INIT_ARGS = {
    'd_model': 4,
    'max_len': 100
}

ARGS = {
    'x': torch.randn(2, 3, 4)
}

if __name__ == '__main__':
    model = PositionalEncoding(**INIT_ARGS)
    output = model(**ARGS)
    print(output.shape)
    print(output)
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 3, dtype family float, shape (2, 3, 4) — shape (2, 3, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
SAttention Ran
ran on a synthesized input
SJTU-DMTai/MASTER/qlib-update/pytorch_master_ts.py
code served (permissive licence) · get_code("f9912fe8791826a9")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 3, dtype family float, shape (3, 2, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import math
import torch
from torch import nn

INIT_ARGS = {
    'd_model': 4,
    'nhead': 2,
    'dropout': 0.1,
}

ARGS = {
    'x': torch.randn(3, 2, 4),
}

if __name__ == '__main__':
    from torch.nn.modules.linear import Linear
    from torch.nn.modules.dropout import Dropout
    from torch.nn.modules.normalization import LayerNorm

    class SAttention(nn.Module):

        def __init__(self, d_model, nhead, dropout):
            super().__init__()
            self.d_model = d_model
            self.nhead = nhead
            self.temperature = math.sqrt(self.d_model / nhead)
            self.qtrans = nn.Linear(d_model, d_model, bias=False)
            self.ktrans = nn.Linear(d_model, d_model, bias=False)
            self.vtrans = nn.Linear(d_model, d_model, bias=False)
            attn_dropout_layer = []
            for i in range(nhead):
                attn_dropout_layer.append(Dropout(p=dropout))
            self.attn_dropout = nn.ModuleList(attn_dropout_layer)
            self.norm1 = LayerNorm(d_model, eps=1e-05)
            self.norm2 = LayerNorm(d_model, eps=1e-05)
            self.ffn = nn.Sequential(Linear(d_model, d_model), nn.ReLU(), Dropout(p=dropout), Linear(d_model, d_model), Dropout(p=dropout))

        def forward(self, x):
            x = self.norm1(x)
            q = self.qtrans(x).transpose(0, 1)
            k = self.ktrans(x).transpose(0, 1)
            v = self.vtrans(x).transpose(0, 1)
            dim = int(self.d_model / self.nhead)
            att_output = []
            for i in range(self.nhead):
                if i == self.nhead - 1:
                    qh = q[:, :, i * dim:]
                    kh = k[:, :, i * dim:]
                    vh = v[:, :, i * dim:]
                else:
                    qh = q[:, :, i * dim:(i + 1) * dim]
                    kh = k[:, :, i * dim:(i + 1) * dim]
                    vh = v[:, :, i * dim:(i + 1) * dim]
                atten_ave_matrixh = torch.softmax(torch.matmul(qh, kh.transpose(1, 2)) / self.temperature, dim=-1)
                if self.attn_dropout:
                    atten_ave_matrixh = self.attn_dropout[i](atten_ave_matrixh)
                att_output.append(torch.matmul(atten_ave_matrixh, vh).transpose(0, 1))
            att_output = torch.concat(att_output, dim=-1)
            xt = x + att_output
            xt = self.norm2(xt)
            att_output = xt + self.ffn(xt)
            return att_output

    model = SAttention(**INIT_ARGS)
    output = model(**ARGS)
    print(f"Output shape: {output.shape}")
    print(f"Expected shape: {ARGS['x'].shape}")
    assert output.shape == ARGS['x'].shape, f"Shape mismatch: {output.shape} vs {ARGS['x'].shape}"
    print("Success!")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 3, dtype family float, shape (3, 2, 4) — shape (3, 2, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
TAttention Ran
ran on a synthesized input
SJTU-DMTai/MASTER/qlib-update/pytorch_master_ts.py
code served (permissive licence) · get_code("d545f61fb9ddb363")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 3, dtype family float, shape (2, 5, 8) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
from torch import nn
from torch.nn.modules.linear import Linear
from torch.nn.modules.dropout import Dropout
from torch.nn.modules.normalization import LayerNorm

class TAttention(nn.Module):

    def __init__(self, d_model, nhead, dropout):
        super().__init__()
        self.d_model = d_model
        self.nhead = nhead
        self.qtrans = nn.Linear(d_model, d_model, bias=False)
        self.ktrans = nn.Linear(d_model, d_model, bias=False)
        self.vtrans = nn.Linear(d_model, d_model, bias=False)
        self.attn_dropout = []
        if dropout > 0:
            for i in range(nhead):
                self.attn_dropout.append(Dropout(p=dropout))
            self.attn_dropout = nn.ModuleList(self.attn_dropout)
        self.norm1 = LayerNorm(d_model, eps=1e-05)
        self.norm2 = LayerNorm(d_model, eps=1e-05)
        self.ffn = nn.Sequential(Linear(d_model, d_model), nn.ReLU(), Dropout(p=dropout), Linear(d_model, d_model), Dropout(p=dropout))

    def forward(self, x):
        x = self.norm1(x)
        q = self.qtrans(x)
        k = self.ktrans(x)
        v = self.vtrans(x)
        dim = int(self.d_model / self.nhead)
        att_output = []
        for i in range(self.nhead):
            if i == self.nhead - 1:
                qh = q[:, :, i * dim:]
                kh = k[:, :, i * dim:]
                vh = v[:, :, i * dim:]
            else:
                qh = q[:, :, i * dim:(i + 1) * dim]
                kh = k[:, :, i * dim:(i + 1) * dim]
                vh = v[:, :, i * dim:(i + 1) * dim]
            atten_ave_matrixh = torch.softmax(torch.matmul(qh, kh.transpose(1, 2)), dim=-1)
            if self.attn_dropout:
                atten_ave_matrixh = self.attn_dropout[i](atten_ave_matrixh)
            att_output.append(torch.matmul(atten_ave_matrixh, vh))
        att_output = torch.concat(att_output, dim=-1)
        xt = x + att_output
        xt = self.norm2(xt)
        att_output = xt + self.ffn(xt)
        return att_output


INIT_ARGS = {
    'd_model': 8,
    'nhead': 2,
    'dropout': 0.1
}

ARGS = {
    'x': torch.randn(2, 5, 8)
}
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 3, dtype family float, shape (2, 5, 8) — shape (2, 5, 8) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
TemporalAttention Ran
ran on a synthesized input
SJTU-DMTai/MASTER/qlib-update/pytorch_master_ts.py
code served (permissive licence) · get_code("5b2b0939a4f0d910")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 2, dtype family float, shape (2, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
from torch import nn

class TemporalAttention(nn.Module):

    def __init__(self, d_model):
        super().__init__()
        self.trans = nn.Linear(d_model, d_model, bias=False)

    def forward(self, z):
        h = self.trans(z)
        query = h[:, -1, :].unsqueeze(-1)
        lam = torch.matmul(h, query).squeeze(-1)
        lam = torch.softmax(lam, dim=1).unsqueeze(1)
        output = torch.matmul(lam, z).squeeze(1)
        return output


INIT_ARGS = {
    'd_model': 4
}

ARGS = {
    'z': torch.randn(2, 3, 4)
}

if __name__ == '__main__':
    model = TemporalAttention(**INIT_ARGS)
    output = model(**ARGS)
    print(f"Output shape: {output.shape}")
    print(f"Output: {output}")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family float, shape (2, 4) — shape (2, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
decompose_portofolio_weight Ran
ran on a synthesized input
microsoft/qlib/qlib/backtest/profit_attribution.py
code served (permissive licence) · get_code("9506113369d1f295")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import pandas as pd
import numpy as np

# Create sample data for stock_weight_df
# Every row corresponds to a day, every column corresponds to a stock
dates = pd.date_range('2016-01-05', periods=2, freq='D')
stock_codes = ['SH600004', 'SH600006', 'SH600017', 'SH600022', 'SH600026']
stock_weight_data = np.array([
    [0.001543, 0.001570, 0.002732, 0.001320, 0.003000],
    [0.001538, 0.001569, 0.002770, 0.001417, 0.002945]
])
stock_weight_df = pd.DataFrame(stock_weight_data, index=dates, columns=stock_codes)

# Create sample data for stock_group_df
# Every row corresponds to a day, every column corresponds to a stock
# Values are group IDs (e.g., industry codes)
group_data = np.array([
    [801780.0, 801170.0, 801040.0, 801880.0, 801180.0],
    [801780.0, 801170.0, 801040.0, 801880.0, 801180.0]
])
stock_group_df = pd.DataFrame(group_data, index=dates, columns=stock_codes)

ARGS = {
    "stock_weight_df": stock_weight_df,
    "stock_group_df": stock_group_df
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, pandas — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_benchmark_weight Ran
ran on a synthesized input
microsoft/qlib/qlib/backtest/profit_attribution.py
code served (permissive licence) · get_code("d8c63f96a1c38715")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned DataFrame. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import pandas as pd
from pathlib import Path
from io import StringIO
import tempfile

# Create a temporary CSV file with benchmark weight data
csv_data = """code,date,index,weight
000001,2024-01-01,CSI300,5.5
000002,2024-01-01,CSI300,4.2
000003,2024-01-01,CSI300,3.8
000001,2024-01-02,CSI300,5.6
000002,2024-01-02,CSI300,4.1
000003,2024-01-02,CSI300,3.9
000001,2024-01-03,CSI300,5.4
000002,2024-01-03,CSI300,4.3
000003,2024-01-03,CSI300,3.7
"""

# Write to a temporary file
temp_file = tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.csv')
temp_file.write(csv_data)
temp_file.close()
temp_path = Path(temp_file.name)

ARGS = {
    'bench': 'CSI300',
    'start_date': pd.Timestamp('2024-01-01'),
    'end_date': pd.Timestamp('2024-01-03'),
    'path': temp_path,
    'freq': 'day'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
pandas — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type DataFrame — a DataFrame output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataFrame output the recorded ndim 2 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
MASTER Not yet run
unverified (harvested, no recorded run)
SJTU-DMTai/MASTER/qlib-update/pytorch_master_ts.py
code served (permissive licence) · get_code("b1b110b56127770c")
How it ran

no invocation recorded.

get_stock_weight_df Not yet run
unverified (harvested, no recorded run)
microsoft/qlib/qlib/backtest/profit_attribution.py
code served (permissive licence) · get_code("e7ee36a13c448d7b")
How it ran

no invocation recorded.

set_global_logger_level Not yet run
unverified (harvested, no recorded run)
microsoft/qlib/qlib/log.py
code served (permissive licence) · get_code("c859b0baafb6ea25")
How it ran

no invocation recorded.

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 10 distinct functions with an identity, 4 are also present in other papers whose code we hold (4 with at least one paper dated earlier, 0 the same month, 0 later) and 6 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
decompose_portofolio_weight 1 other paper
1 dated earlier
2009.11189 (2020-09)
Qlib: An AI-oriented Quantitative Investment Platform
get_benchmark_weight 1 other paper
1 dated earlier
2009.11189 (2020-09)
Qlib: An AI-oriented Quantitative Investment Platform
get_stock_weight_df 1 other paper
1 dated earlier
2009.11189 (2020-09)
Qlib: An AI-oriented Quantitative Investment Platform
set_global_logger_level 1 other paper
1 dated earlier
2009.11189 (2020-09)
Qlib: An AI-oriented Quantitative Investment Platform

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-24.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Financial markets pose fundamental challenges for asset return prediction due to their high dimensionality, non-stationarity, and persistent volatility. Despite advances in large language models and multi-agent systems, current quantitative research pipelines suffer from limited automation, weak interpretability, and fragmented coordination across key components such as factor mining and model innovation. In this paper, we propose R&D-Agent for Quantitative Finance, in short R&D-Agent(Q), the first data-centric multi-agent framework designed to automate the full-stack research and development of quantitative strategies via coordinated factor-model co-optimization. R&D-Agent(Q) decomposes the quant process into two iterative stages: a Research stage that dynamically sets goal-aligned prompts, formulates hypotheses based on domain priors, and maps them to concrete tasks, and a Development stage that employs a code-generation agent, Co-STEER, to implement task-specific code, which is then executed in real-market backtests. The two stages are connected through a feedback stage that thoroughly evaluates experimental outcomes and informs subsequent iterations, with a multi-armed bandit scheduler for adaptive direction selection. Empirically, R&D-Agent(Q) achieves up to 2× higher annualized returns than classical factor libraries using 70% fewer factors, and outperforms state-of-the-art deep time-series models on real markets. Its joint factor-model optimization delivers a strong balance between predictive accuracy and strategy robustness. Our code is available at: https://github.com/microsoft/RD-Agent.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2505.15155")
get_code_for_paper("2505.15155")
have("2505.15155")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2505.15155.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2505.15155.svg)](https://syntology.ai/paper/2505.15155)

Connect an agent — have() is free.