01 · Experiment

Can a policy learn when to buy or sell from a price sequence?

The project framed trading as an OpenAI Gym environment. The state described the market observation; actions changed the portfolio; reward reflected the resulting gain or loss. Two deep-learning policies—an RNN family model and a Transformer—were compared under the same educational setup.

State price history + portfolioPolicy RNN or TransformerAction buy / sellReward portfolio change
TrainJan 2014 → Aug 2018
TestSep 2018 → Aug 2019

02 · Policies

Sequential memory versus parallel attention.

RNN policy

Process the series step by step

  • Two linear layers
  • Convolution layer
  • Gated recurrent unit
  • History carried through recurrent state

Transformer policy

Attend across the observed sequence

  • Two encoder layers
  • Two attention heads
  • Embedding dimension of 50
  • Positional encoding preserves order

The report intentionally omitted a Transformer decoder: the policy needed a representation for action selection, not a translation back into another sequence.

03 · Reported results

The Transformer led in this run—but the numbers require context.

Training profit · 10 episodes

RNN
$797
Transformer
$1,080

Test profit · reported run

RNN
$7,557
Transformer
$10,347
Episodes to reach 1.1× portfolio ratio
11RNN
2Transformer

Values above are transcribed from the attached report. They are historical experiment outputs, not independently rerun results and not evidence of future returns.

04 · Reading the results

The Transformer won this experiment, not the broader argument.

In the chosen setup, the Transformer policy earned the higher reported profit and reached the target portfolio ratio in fewer episodes. Using a held-out time period was also better than reporting training performance alone. The experiment therefore shows that attention was a credible alternative to recurrent processing for this task.

It does not show that Transformers are better trading systems. The comparison used one index, one historical window, 10 training episodes, and no repeated random seeds. It did not account for transaction costs, slippage, drawdown, or risk-adjusted return, and stopping evaluation at a profit threshold may have favored the apparent winner. A defensible conclusion is narrower: the Transformer outperformed the RNN under this environment and stopping rule; whether that result generalizes remains unknown.

Archive & provenance

Aggregate Intellect originally published this study; selected source artifacts remain inspectable here.

This educational study was originally published through Aggregate Intellect, founded in Toronto in 2018, as part of its A.I. Socratic Circles (AISC). The original page was later removed, so this edited presentation is hosted here. A small public evidence repository contains the written paper and notebook; neither should be read as financial advice or as a validated trading strategy.