Problem
The challenge comes from QRT on the ENS Challenge Data platform. An allocation is a trading strategy. For each allocation on a given day, the task is to predict whether its return on the next day is positive or negative. It is a binary classification problem on a very noisy financial signal.
Data
Each row is one allocation on one day:
TS, an anonymised and shuffled timestamp. Rows with the sameTSbelong to the same day.ALLOCATION, the label of the strategy, andGROUP, an anonymised group of strategies (for example long-short or momentum).RET_1toRET_20, the allocation’s returns over the past 20 days.SIGNED_VOLUME_1toSIGNED_VOLUME_20, its signed volumes over the same days.MEDIAN_DAILY_TURNOVERover those 20 days.- The target is the sign of the return on day 21.
Because the timestamps are shuffled, the days carry no calendar order. What they do carry is the cross section: all allocations of one day can be looked at together. A day holds between 65 and 276 allocations.
Features
The 20 days become a tensor of shape batch × time × channels, like the colour channels of an image. Each day has 10 channels for each allocation:
- the return, standardised per row
- the signed volume, standardised per row
- the return on a global scale, since the per-row standardisation hides how big a move is
- the market return, the mean return of all allocations that day
- the return relative to the market
- the return relative to its peers, the same group on the same day
- a Sharpe-like ratio, the return divided by the row’s standard deviation
- the volume on a global scale
- the market volume
- a flag for a missing volume
Everything is clipped to because of a few extreme outliers. Next to the time series there are static features: the allocation and group as integer codes for the embeddings, and the median daily turnover plus the two standard deviations from the per-row standardisation. These three are log transformed and standardised with the mean and standard deviation of the training set.
Model
The network has three components and a small head.
A: a transformer over the 20 days
The 10 channels of each day are projected to a vector of size with a linear layer and layer normalisation. A learned positional embedding marks the order of the days. Two transformer encoder layers with 4 attention heads then let all 20 days attend to each other. There is no causal mask, since all 20 days are in the past.
The 20 output vectors are reduced in two ways and concatenated. Attention pooling learns a score per day and takes the weighted average
so a quiet day gets little weight and a large move gets more. The last vector , the most recent day, is added as it is.
B: embeddings for allocation and group
The allocation and group codes go through learned embeddings of size 16 and 2. They are concatenated with the three static features and passed through a two-layer MLP. Dropout on the allocation embedding stops the model from simply memorising each of the 278 allocations.
C: a transformer across the allocations of one day
The outputs of A and B give one vector per row. These rows are regrouped per day into a tensor of days × allocations × features and go through a second transformer encoder, this time across allocations instead of across time. Allocations on the same day move together a lot, so each one gets to see what the others are doing. There is no positional embedding, as the order of the allocations means nothing. Days have different numbers of allocations, so they are padded and the padding is masked in the attention.
Head
The row vector from A and B and the output of C are concatenated and mapped to a single logit by a small MLP. The predicted sign is positive when the logit is above zero.
Training
- The loss is binary cross-entropy on the logits (
BCEWithLogitsLoss). - AdamW with a learning rate of and weight decay , and a one-cycle learning rate schedule that warms up first and then decays to almost zero.
- A batch is a set of 8 whole days with all their allocations, because component C needs the full cross section of a day.
- Validation is done on whole days. The test set shares no days with the training set, so a random split over rows would be too optimistic. The folds are a
KFoldover the dates with 8 splits. - The signal is very noisy, so the final predictions average the logits of models trained with 3 different seeds on all days.
The notebook, with the full feature pipeline and training loop, is on GitHub.