StockformerOptions<T>

Options & Configuration · AiDotNet.Models.Options

Configuration for Stockformer.

Inheritance: ModelOptions → StockformerOptions<T>

For Beginners

Stockformer splits each stock’s return series into a slow-moving part and a fast-moving part, studies them with different machinery, then predicts both the size of the next move and its direction at the same time. These settings control the sizes involved.

How It Works

Reference: Bohan Ma, Yiheng Wang, Yuchao Lu, Tianzixuan Hu, Jinling Xu, Patrick Houlihan and Xin Liu, “Stockformer: A Price-Volume Factor Stock Selection Model Using Wavelet Transform and Multi-Task Self-Attention Networks”, 2024 (arXiv:2401.06139).

Defaults are taken from the reference implementation’s config/Multitask_Stock.conf (github.com/Eric991005/Multitask-Stockformer), not invented: layers = 2, heads = 1, dims = 128, samples = 1, wave = sym2, level = 1, T1 = 20, T2 = 2, learning_rate = 0.001, batch_size = 12.

Two of those are easy to get wrong by reading the paper alone. The wavelet is a SINGLE-level sym2 split, not a deep multi-resolution pyramid; and attention is SINGLE-headed, despite “multi-task self-attention networks” in the title suggesting otherwise.

Constructors

Constructor Summary
StockformerOptions() Initializes a new instance with default values.
StockformerOptions(StockformerOptions<T> other) Initializes a new instance by copying every property from another instance.

Properties

Property Summary
double DropoutRate { get; set; } Gets or sets the dropout rate.
double LearningRate { get; set; } Gets or sets the learning rate.
double MissingValueSentinel { get; set; } Gets or sets the value treated as “missing” by the masked regression loss.
double TaskLossWeight { get; set; } Gets or sets lambda, the weight on the classification task in L = L_reg + lambda*L_cla.
int HiddenDimension { get; set; } Gets or sets the model width (dims).
int NumAssets { get; set; } Gets or sets the number of stocks (graph nodes) in the cross-section.
int NumDirectionClasses { get; set; } Gets or sets the number of direction classes for the classification task.
int NumFeatures { get; set; } Gets or sets the number of price-volume factors per stock per timestep.
int NumHeads { get; set; } Gets or sets the attention head count (heads).
int NumLayers { get; set; } Gets or sets the number of dual-encoder layers (layers).
int PredictionHorizon { get; set; } Gets or sets the forecast horizon in timesteps (T2).
int SequenceLength { get; set; } Gets or sets the input window length in timesteps (T1).
int SpatialSamples { get; set; } Gets or sets the sparsity parameter of the spatial attention (samples).
int WaveletLevels { get; set; } Gets or sets the number of DWT decomposition levels (level).
int WaveletOrder { get; set; } Gets or sets the Symlet order for the discrete wavelet transform (wave = sym2).

Methods

Method Summary
void Validate() Validates the configuration.