3.1. Data Collection
The dataset constructed in this study is designed for multi-source hardware sensing-based risk perception tasks in real financial trading environments, with data collection spanning from January 2022 to December 2024. All data are acquired from sensors deployed in trading terminals, network links, edge computing nodes, and trading environments, as shown in
Table 1. Specifically, terminal interaction sensing data are collected by touch sensors and inertial measurement sensors deployed on trading workstations and mobile trading devices, primarily recording click frequency, sliding trajectories, input intervals, page dwell time, transaction instruction triggering time, terminal posture changes, and operation response delays, which are used to characterize behavioral variations of traders under different risk states. Network link sensing data are collected by network traffic sensors and link latency sensors deployed at trading network entry points, routing nodes, and edge servers, primarily recording network latency, request frequency, session duration, data transmission intervals, link congestion states, and abnormal access patterns, which are used to reflect the stability of trading links and potential transmission risks.
Device state sensing data are collected by temperature sensors and voltage sensors, primarily recording device temperature, ambient temperature, voltage fluctuations, power supply stability, and hardware operating conditions of trading terminals and edge computing nodes, which are used to identify abnormal risk signals caused by hardware overheating, power anomalies, or performance degradation. Order flow sensing data are collected by order flow intensity sensors and order book depth sensors, primarily recording bid-ask depth, bid-ask spread, order flow intensity, cancellation frequency, transaction triggering time, liquidity variations, and order imbalance, which are used to perceive real-time changes in market microstructure. Trading environment sensing data are collected by environmental temperature and humidity sensors and vibration sensors, primarily recording environmental temperature and humidity variations, vibration intensity around devices, and external physical disturbances, which are used to assist in determining whether external environmental factors affect trading terminals, servers, and network devices. After data collection, all raw data are uniformly processed through sensor identifier binding, timestamp calibration, device state verification, anomaly detection, and missing segment imputation. A unified clock is further adopted to construct multi-frequency time windows, enabling terminal interaction, network link, device state, order flow, and trading environment sensing data to be aligned and fused within a consistent temporal framework.
3.2. Data Preprocessing and Augmentation Strategy
In financial time-series modeling, data preprocessing and temporal augmentation are not merely auxiliary steps before model training, but are critical procedures that directly affect the quality of risk representations and the stability of prediction. The underlying principle is that observed financial market sequences are usually not unbiased and complete expressions of true risk states, but highly noisy observations formed under the joint effects of trading mechanisms, sampling frequencies, market shocks, information transmission delays, and changes in institutional environments. In other words, raw price, return, trading volume, or order flow sequences contain not only effective information reflecting market structures and risk states, but also interference components such as missing observations, abnormal fluctuations, microstructure noise, and distribution drift. Without appropriate preprocessing, these incidental noises may be incorrectly identified by the model as predictive patterns, resulting in overfitting, reduced generalization capability, and unstable performance under extreme market conditions. Therefore, the core objective of data preprocessing is not simply to “clean data”, but to improve the comparability, robustness, and learnability of samples while preserving the economic meaning and dynamic dependency structure of financial time series as much as possible. The core objective of financial temporal augmentation is to perform structurally consistent perturbation and reconstruction of samples without destroying the original economic logic, so that more stable and intrinsic risk representations can be learned from different market scenarios.
Let the original financial time series be denoted as
, where
represents the
d-dimensional observation vector at time
t, which may include multiple features such as price, return, trading volume, bid–ask spread, and volatility proxy variables. Since missing values commonly exist in financial data, the completeness of the sequence should first be corrected. For local missing cases in which both preceding and subsequent time points are observable, linear interpolation based on temporal continuity can be adopted to estimate missing values. The basic idea is to use the local trend of adjacent time points to approximate the missing observation, thereby reducing information loss caused by directly deleting samples. If the observation at time
t is missing and the nearest valid observations exist at
, the interpolation can be expressed as
This method is suitable for short-term missing scenarios because it assumes that changes within adjacent intervals are relatively smooth. For more complex missing patterns in high-frequency financial data, a sliding-window local mean can also be used for robust imputation. Given a window radius of
k, the estimate for the missing position
t can be written as
where
, and
denotes the number of valid observations within the window. The principle of this operation is to approximately recover short-term missing segments by using local statistical information, thereby maintaining statistical consistency at the local scale of the sequence. For price-related variables, raw price sequences are usually not directly used. Instead, return transformations are applied to reduce non-stationarity and enhance the model’s perception of relative changes. Let the asset price be denoted as
. The simple return can be defined as
whereas the log return, which is more commonly used in financial research, is formulated as
The advantage of log returns lies in their better additivity, making them more suitable for describing continuous compounding and subsequent statistical modeling. For variables with large-scale fluctuations, such as trading volume and bid–ask spread, logarithmic compression or power transformation is often used to weaken the influence of extreme values. For example,
where
denotes the original trading volume variable. This transformation can reduce the dominance of large-valued samples in model parameter estimation and improve scale comparability across different samples. Since abnormal fluctuations and heavy-tailed spikes are widely present in financial time series, direct standardization using ordinary mean and standard deviation is easily affected by extreme samples. Therefore, robust standardization is a more reasonable choice. Its basic idea is to replace the mean and standard deviation with the median and interquartile range, thereby obtaining more stable scaling results under skewed or heavy-tailed distributions. Let the sample median of a feature dimension be
, and let the first and third quartiles be
and
, respectively. The robustly standardized result can be expressed as
where
is a very small constant used to prevent division by zero. If the data distribution is relatively stable, the classical
z-score standardization can also be adopted:
where
and
denote the sample mean and standard deviation, respectively. However, in high-frequency financial environments, given the frequent changes in local market structures, rolling and robust normalization are emphasized in this study. Let the local mean and local standard deviation within a rolling window of length
w be denoted as
and
, respectively. Dynamic standardization can then be written as
where
This processing strategy can eliminate local scale differences under conditions closer to real trading environments and reduce the interference of long-term institutional changes in model training. To reduce the adverse effects of abnormal fluctuations, extreme observations should also be winsorized or clipped. The principle of this operation is not to deny the existence of extreme market conditions, but to prevent individual abnormal values from exerting disproportionate dominance over parameter learning during training. Let the lower and upper quantile thresholds be denoted as
and
, respectively, where
. The clipped variable
can be expressed as
This quantile-based clipping strategy can suppress the influence of extreme values on the estimation of the overall distribution while preserving the ranking relationship among samples as much as possible. If tail events need to be preserved while reducing numerical explosion effects, a hyperbolic tangent compression form can also be adopted:
where
is a compression intensity parameter. This method maps values into a bounded interval while retaining positive and negative directional information, thereby improving numerical stability during training. In addition to local missing values and outliers, distribution drift is also prevalent in financial markets. This means that the data-generating mechanism changes across different time periods, leading to distributional inconsistency between the training and testing periods. To address this issue, temporally consistent rolling training should be adopted as much as possible during preprocessing, and detrended or relative expressions should be introduced at the feature level to reduce the influence of long-term drift. For example, for a feature
, its relative state can be characterized by the deviation from the local mean:
Furthermore, the local relative change rate can be defined as
so that the model focuses on deviations relative to the recent background rather than absolute levels. This is more consistent with the basic logic of financial risk identification, in which abnormal deviation is regarded as a potential risk signal. After basic preprocessing is completed, the design of financial temporal augmentation strategies should follow the principle that perturbations should not destroy economic semantics. Unlike computer vision, where general augmentation operations such as random cropping and color perturbation can be directly used, every change in financial time series corresponds to potential market meaning. Therefore, augmentation operations must serve the learning of more robust risk structures rather than generating pseudo-samples lacking realistic interpretation. First, temporal window cropping augmentation can be adopted, in which continuous subsequences with slightly different lengths are extracted from the original sample, allowing the model to identify consistent risk states under different observation windows. Let the original sequence segment be
, the cropping length be
, and the starting point be
s. The augmented sample is then defined as
The rationale behind this operation is that, in real trading decisions, investors usually cannot observe a completely identical fixed window, but instead make judgments based on historical information of varying lengths. Therefore, window cropping can improve the model’s adaptability to changes in observation scope. Second, amplitude scaling augmentation can be used to simulate volatility processes with similar patterns under different levels of market activity. If the return sequence is scaled, the augmented result can be written as
where
is a scaling coefficient close to 1, usually set as
, and
is a small positive value. The essence of this operation is to simulate the manifestation of the same risk structure under different volatility intensities, enabling the model to focus on the volatility pattern itself rather than relying only on absolute magnitude. Unlike completely random noise injection, this transformation preserves the sign of returns, relative trends, and temporal dependencies, and thus has strong financial rationality. Third, local temporal jittering can be used to simulate slight shifts in information arrival time, which is particularly suitable for multimodal alignment scenarios. If the time index of a subsequence is shifted by no more than
, the augmented sample can be expressed as
Here,
should usually satisfy local smoothness or piecewise-constant constraints to avoid completely disrupting the temporal order. This augmentation method reflects the slight time lags that commonly exist among news releases, order book responses, and price reactions in real financial systems, thereby improving the model’s tolerance to asynchronous financial sensing signals. In addition, state-consistent segment replacement augmentation based on economic conditions is emphasized in this study. Let two sample segments be denoted as
and
. If they exhibit high similarity under a certain state indicator, such as similar local volatility, the corresponding segment in
can be used to replace part of
, yielding the augmented sample
To ensure the rationality of replacement, local volatility can be used as a similarity metric. Let the return sequence within window
W be denoted as
. The local volatility can then be defined as
where
is the average return within the window. Replacement is performed only when the two segments satisfy
where
is the similarity threshold. The significance of this strategy lies in extracting and splicing local structures from different samples under similar risk states, thereby enhancing the model’s ability to understand the financial fact that similar states may correspond to different individual paths. In self-supervised or contrastive learning scenarios, two different augmented views are usually constructed for representation consistency constraints. Let the original sample be denoted as
X, and let two financially logical augmented samples be denoted as
and
. The encoder
outputs the representations
and
. Their consistency can then be constrained through a similarity objective, such as cosine similarity, defined as
This setting indicates that samples augmented under consistent economic semantics should remain close in the representation space, thereby encouraging the model to learn risk features that remain stable across noise and local perturbations.
3.3. Proposed Method
3.3.1. Overall
The proposed method is constructed as a unified framework consisting of “multimodal financial sensing encoding–temporal masking-based self-supervised modeling–risk-contrastive representation constraint–downstream task-aligned prediction”. Given multi-source financial samples that have been temporally aligned and feature-normalized, different modalities, including market quotations, order book structures, terminal interactions, network transmission, device status, and news sentiment, are first fed into their corresponding modality encoders. For continuous temporal modalities, temporal convolution and attention-based encoding structures are adopted to extract local volatility patterns and long-range dependencies. For textual sentiment modalities, semantic encoders are used to capture event shocks and market expectation information. Subsequently, modality-specific features are mapped into a unified latent space, and the importance weights of different modalities under the current market state are calculated through a cross-modal attention fusion module, thereby forming a comprehensive risk-state representation. This representation is not directly fed into a supervised predictor, but is first introduced into the self-supervised risk representation learning stage. In this stage, several key temporal segments in the input sequence are masked, forcing the encoder to reconstruct the masked content based on unmasked price movements, order book changes, interaction behaviors, network states, and sentiment signals. In this way, intrinsic dependencies and latent risk structures across different temporal segments can be learned. The contextual representation output by the temporal masking module is further fed into the risk-oriented contrastive learning module. Positive and negative sample pairs are constructed according to local volatility, order book imbalance, sentiment shock intensity, and risk-stage similarity, so that samples under similar risk states are pulled closer in the representation space, whereas samples under different risk states are effectively separated. Consequently, the interference of short-term noise and incidental fluctuations in representation learning can be reduced. After self-supervised pretraining is completed, the learned low-noise risk representation is transferred to the downstream task alignment module. Corresponding prediction heads are designed for different investment risk tasks, including future volatility regression, estimation, risk-level classification, and asset risk ranking, so that the general risk representation can be matched with specific investment decision-making objectives. During the overall training process, the masked reconstruction objective is used to constrain the model to learn temporal structures, the contrastive learning objective is used to optimize the risk representation space, and the downstream task objective is used to calibrate predictive value. These three objectives jointly enable stable, transferable, and interpretable investment risk features to be extracted from multimodal financial sensing signals.
3.3.2. Temporal Masking-Based Risk Structure Modeling Module
The temporal masking-based risk structure modeling module follows a self-supervised learning process of “masked input–encoded representation–decoded reconstruction–structural constraint”. Its core objective is to guide the model to learn stable long-term risk structures from multimodal financial sensing sequences without relying on manually defined risk labels. Let the aligned input sequence be denoted as , where represents the multimodal financial state vector at time t, containing features such as market quotations, order books, terminal interactions, network states, device status, and sentiment signals. First, a binary mask vector is generated according to the masking strategy, and the masked input is obtained as , where denotes a learnable mask embedding. Unlike ordinary random masking, the masking units in this study mainly consist of continuous temporal segments, and risk-related indicators such as local volatility, order book imbalance, and abnormal interaction intensity are incorporated to adjust the masking probability, making high-uncertainty regions more likely to be masked. This design forces the model to recover missing information according to market states before and after the masked segments, cross-modal collaborative relationships, and long-term temporal dependencies, thereby preventing the model from merely memorizing local noise or short-term price spikes.
As shown in
Figure 1, from the perspective of network structure, the masked sequence is first fed into the temporal encoder
to obtain the contextual latent representation
. The encoder consists of a modality embedding layer, a positional encoding layer, and multiple temporal attention blocks. The modality embedding layer projects sensing signals from different sources into a unified dimension
, the positional encoding layer is used to preserve the temporal order of financial sequences, and the temporal attention block calculates dependencies among different temporal segments through query, key, and value mappings. Its basic form is given by
. Through this structure, associations between masked and unmasked segments can be established over the global temporal range, while short-term volatility shocks and long-term risk accumulation processes can be captured simultaneously. Subsequently, the latent representation
H is fed into the decoder
to reconstruct the original observations at the masked positions, yielding
. A lightweight multilayer perceptron or reverse temporal attention structure is adopted as the decoder to prevent excessive model capacity from directly copying input noise. The reconstruction loss is calculated only at the masked positions and can be expressed as
, where
denotes the set of masked temporal indices. For risk-sensitive variables such as volatility, bid–ask spread, and latency, a weighted reconstruction form can also be introduced as
, where
is determined by local risk intensity, enabling the model to focus more on temporal segments with significant risk-state changes.
From a mathematical perspective, temporal masking modeling is essentially intended to maximize the conditional dependence between masked segments and contextual segments, namely to learn . In highly noisy financial environments, random micro-level perturbations are often difficult to predict stably from context, whereas risk states jointly determined by market structure, liquidity changes, and sentiment shocks possess stronger conditional recoverability. Therefore, when the model is required to recover masked segments from context, structurally consistent risk factors are more likely to be preserved, while the influence of unpredictable noise is weakened. This module is also connected to the subsequent contrastive learning branch. The latent representation output by the encoder is fed into the reconstruction decoder to calculate the reconstruction constraint on the one hand, and is used as the risk representation input to the projection layer for consistency constraints with augmented-view representations on the other hand. Therefore, the model can learn not only how to recover masked financial states, but also which structures remain stable under different perturbations. This design is particularly suitable for the investment risk prediction task in this study, because risk is usually not a single-point anomaly but the result of the gradual accumulation of multimodal signals over time. Through masked reconstruction, dynamic transmission relationships among price volatility, order book liquidity, terminal interactions, and external sentiment can be explicitly modeled, thereby yielding low-noise, transferable, and more interpretable risk structure representations.
3.3.3. Risk-oriented Contrastive Learning Representation Constraint Mechanism
The risk-oriented contrastive learning representation constraint mechanism adopts a “dual-branch encoding–projection–similarity constraint” structure. However, its design focus is not arbitrary augmentation of original samples, but the construction of multi-view representations with economic equivalence around financial risk states.
As shown in
Figure 2, let the input multimodal financial risk sequence be denoted as
, where
T represents the temporal length and
C represents the number of fused channels. First, a set of risk-equivalent transformations
is constructed for the original sequence, corresponding to local temporal perturbation, amplitude-preserving scaling, frequency-domain low-noise enhancement, and empirical mode decomposition reconstruction, respectively. After transformation, multiple risk-consistent views
are obtained, while the original view
is retained. These views differ in short-term noise, local amplitude, or frequency-domain details, but their latent risk states should remain consistent; thus, they are defined as positive sample relationships. Each augmented view is fed into the shared-parameter risk encoder
, while the original view is fed into the baseline encoder
, which has an independent but structurally identical architecture. The encoder consists of
one-dimensional temporal convolution blocks,
multi-head temporal attention blocks, and a global risk pooling layer. The input size of the
l-th convolution block is
, the kernel size is
, the stride is
, and the output channel number is
. Therefore, the output width can be expressed as
, and the output feature is denoted as
. Subsequently, the attention layer maps risk dependencies along the temporal dimension into the latent dimension
D, and the output representation is denoted as
. To prevent contrastive learning from directly constraining backbone features and impairing downstream predictive capability, the encoded result is further fed into the projection head
. The projection head consists of
fully connected layers, with the width of the
j-th layer denoted as
, and the final output is
. This design allows the backbone encoder to retain interpretable risk factors, while the projection space mainly undertakes contrastive optimization. For any original sample
, its original representation and augmented representation are respectively defined as
To make the similarity constraint more consistent with financial logic, an ordinary instance-level contrastive loss is not directly adopted. Instead, risk-state weights are introduced. Let the risk-state statistics of samples
i and
j be denoted as
and
, respectively, which may include local volatility, order book imbalance, tail-loss intensity, and sentiment shock intensity. The risk-consistency weight between them is then defined as
where
is the smoothing parameter for risk-state similarity. When the risk states of two samples are closer,
becomes larger, and the model tends to pull them closer in the representation space. Furthermore, the risk-oriented contrastive objective between the augmented views and the original view can be formulated as
where
denotes normalized inner-product similarity and
denotes the temperature coefficient. Unlike ordinary contrastive learning, this loss does not simply distinguish sample identities, but adjusts positive and negative sample boundaries through risk-state similarity, enabling the model to focus more on whether the risk structures are consistent rather than whether the samples originate from the same temporal window. The mathematical rationality of this design can be explained from the perspective of representation invariance. If the risk-equivalent transformation
does not change the latent risk variable
, namely
, the ideal encoder should satisfy
When
is minimized, the positive sample term increases
, and the following constraint tendency can therefore be obtained:
Meanwhile, for samples with large differences in risk states, a larger
forms a stronger separation boundary in the denominator, encouraging the representations to satisfy
where
is a margin function that increases with risk-state differences. Accordingly, this module constructs a risk-aware metric structure in the representation space. Multiple perturbed views under the same risk semantics are compressed into adjacent regions, while samples from different risk stages are pushed farther apart. When applied to the task in this study, this mechanism can effectively reduce the interference of random noise, local spikes, and asynchronous sensing errors in high-frequency financial data during representation learning. The model no longer relies on a single price pattern, but extracts risk factors from multimodal sensing signals that remain stable across windows, assets, and markets. Compared with a self-supervised objective that relies only on masked reconstruction, the risk-oriented contrastive constraint further enhances the discriminability of the representation space, allowing subsequent volatility prediction,
estimation, and risk ranking tasks to obtain clearer, lower-noise, and economically interpretable input features.
3.3.4. Risk Representation and Downstream Prediction Task Alignment Strategy
The risk representation and downstream prediction task alignment strategy adopts a hierarchical design of “shared risk encoding–learnable mapping–mixture-of-experts prediction” in its overall structure, enabling the general risk representation obtained in the self-supervised stage to be effectively transformed into task-specific features required for investment decision-making. As shown in
Figure 3, let the unified risk representation obtained from the preceding modules be denoted as
. It is first fed into the embedding network
for feature compression and reconstruction, yielding the basic embedding vector
. The embedding network consists of multiple linear transformations and nonlinear activations, and the width of each layer is denoted as
. Through layer-wise projection, high-dimensional risk factors are mapped into a compact task space. Subsequently, a learnable mapping module
is introduced to structurally transform the intermediate features, which can be expressed as
where
denotes the transformation matrix and
denotes the nonlinear activation function. This module is used to eliminate the distributional shift between self-supervised representations and downstream tasks, making the risk factors semantically closer to the prediction targets.
In the prediction stage, a risk prediction network based on a mixture-of-experts mechanism is adopted to improve the adaptability of the model under different market states. Let several sub-prediction experts be denoted as
. Each expert is used to model a specific risk pattern, such as a high-volatility phase, liquidity shock phase, or sentiment-driven phase. Its output is given by
where
is composed of a multilayer feedforward network, and the hidden dimension of each layer is denoted as
. Complex risk patterns can therefore be captured through nonlinear mapping. To dynamically select the most appropriate expert, a gating network
is constructed to generate expert weights according to the current risk representation:
where
denotes the gating function. The final prediction is obtained as a weighted combination of the outputs of all experts:
From a mathematical perspective, this structure is equivalent to decomposing the conditional distribution
as
where
is produced by the gating network, and
is modeled by the corresponding expert. This decomposition can effectively characterize the property that different risk states in financial markets correspond to different generation mechanisms. When the market is in different phases, the gating network automatically adjusts the expert weights, enabling the model to select the most appropriate risk pattern for prediction and thus avoiding the limitation that a single model is difficult to adapt to changing environments. To achieve effective alignment between representations and tasks, a joint optimization objective is introduced during training, so that the risk representation not only satisfies self-supervised structural constraints but also minimizes the downstream task loss
. The overall optimization objective can be written as
where
denotes the self-supervised loss from the preceding modules, and
is the trade-off coefficient. This objective ensures that the encoder gradually adjusts the representation space to downstream prediction tasks while preserving general structural information. This design offers several advantages for the task in this study. First, through the embedding and learnable mapping modules, self-supervised risk representations are effectively transformed into a feature space with task semantics, thereby avoiding misalignment between representations and prediction targets. Second, the mixture-of-experts structure can characterize the diversity of financial risks, allowing the model to automatically select the optimal prediction path under different market states and thus improving robustness and generalization capability. Finally, the gating mechanism enables dynamic adaptability. When facing high-frequency noise, structural breaks, and cross-market transfer, the model can adjust its decision logic according to the current risk state, thereby achieving more stable and accurate investment risk prediction.