An intra-day quantitative trading adaptive method and system based on spectral concentration
By determining market conditions through spectrum concentration and activating matching indicator channels to generate trading signals, the problem of poor strategy adaptability of existing mass trading systems in A-share intraday trading has been solved. This achieves efficient and stable trading signal generation and risk control operations, meeting the real-time and compliance requirements of T+0 trading.
Patent Information
- Application Number
- CN202611543785.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-08
- Publication Date
- 2026-11-03
AI Technical Summary
Existing mass trading systems struggle to achieve low-latency, oscillation-resistant real-time quantitative determination of status, automatic routing of strategy links, and configurable modular strategy assembly in A-share intraday trading. This results in poor strategy adaptability, insufficient real-time performance and stability, and high strategy iteration costs.
The market status is determined in real time by using the spectral concentration method. An anti-oscillation state machine is used to output a stable market status label, which is then activated to generate trading signals by activating matching heterogeneous indicator channels. The trading signals are generated through modular serial filtering and combined with signal cooling and persistence to execute risk control operations tick by tick.
It achieves stable determination of market status and efficient signal generation in intraday trading of A-shares, reduces strategy iteration costs, improves market adaptability and real-time trading, and meets the compliance requirements of T+0 trading.
Smart Images

Figure CN123032476A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of quantitative trading technology, and in particular to an adaptive method and system for intraday quantitative trading based on spectral concentration. Background Technology
[0002] This scenario targets intraday trading in A-shares. Its core characteristic is the rapid alternation between trending and range-bound market conditions within a short timeframe of tens of minutes within a single trading day, placing extremely high demands on strategy adaptability, real-time judgment, and architectural flexibility. Current technologies for this scenario suffer from three systemic deficiencies: 1. Strategy Adaptation Level Traditional quantitative strategies are mostly designed for a single market state. Trend-following strategies will frequently trigger reverse signals and cause losses in a volatile market, while mean-reversion strategies will suffer significant drawdowns in a trending market due to holding positions against the trend. Fixed strategy combinations cannot adapt to intraday changes in market conditions, and adding or replacing strategies requires modifying the source code, resulting in long debugging cycles and high maintenance costs.
[0003] 2. State Recognition Level Mainstream market state determination methods are all unsuitable for the low latency and high stability requirements of minute-level trading: Hidden Markov Models require large amounts of training data, are parameter-sensitive, and have high real-time inference latency; the ADX indicator has strong lag and frequent noise signals in the critical interval; the volatility threshold method cannot distinguish between high volatility trends and high volatility oscillations; machine learning classifiers have high training costs, weak generalization ability, and black-box characteristics that are not conducive to attribution; and all methods generally suffer from frequent state jumps near the threshold, which can cause signal oscillations and result in invalid orders in live trading.
[0004] 3. Architecture Integration Level The existing plug-in strategy framework only implements pluggable replacement of strategies and does not establish a state-driven automatic routing mechanism: all indicators run in parallel at all times, and oscillating indicators will cause reverse interference in trending markets, while trending indicators will cause lag and misleading in oscillating markets; strategy switching relies on manual intervention, lacks an indicator management system classified by functional attributes, and has low strategy iteration efficiency.
[0005] Overall, existing commercial trading systems in this scenario generally lack three core capabilities: low-latency, oscillation-resistant real-time quantitative status determination, automatic routing of strategy links based on market status, and configurable modular strategy assembly. As a result, they are unable to meet the comprehensive requirements of real-time performance, stability, and scalability for minute-level T0 trading pairs. Summary of the Invention
[0006] The purpose of this invention is to overcome the shortcomings of the above-mentioned background technology and provide an adaptive method and system for intraday quantitative trading based on spectrum concentration. This system enables a set of methods to determine the market status in real time and stably, automatically assemble matching trading indicator combinations to generate signals, and complete risk control and position closing within the day, thus avoiding mismatch between strategy and market environment.
[0007] This invention provides an adaptive intraday quantitative trading method based on spectral concentration, comprising the following steps: S1, State determination: extracting spectral concentration from the frequency domain and outputting a stable market state label through an anti-oscillation state machine; and / or S2, Generating state-driven routes and signals: using the state label as the routing key, activating matching heterogeneous indicator channels, and generating trading signals through modular serial filtering; and / or S3, Signal execution and risk control: after the trading signals are cooled and persisted, the order layer executes stop-loss and fixed-loss orders tick by tick, and forces liquidation at the end of the trading day.
[0008] In the above technical solution, the specific process of step S1 is as follows: S11, Market data preprocessing: Receive minute-level market data of the target security, extract the closing price sequence from the market data, perform pre-smoothing processing on the closing price sequence using a moving average window ma_window to obtain a smoothed price sequence, take the nearest fft_window samples of the smoothed price sequence for first-order difference to obtain a difference sequence, and eliminate the influence of non-stationary trend terms on spectrum estimation; S12, Spectrum concentration calculation: Perform fast Fourier transform on the difference sequence to obtain a frequency domain complex sequence, utilize the conjugate symmetry of the real number sequence, retain only the single-sided positive frequency component and remove the zero-frequency DC component to obtain an effective single-sided power spectrum, identify the dominant frequency component with the largest power in the power spectrum, calculate the normalized ratio of the power of the dominant frequency component to the total power of the non-DC components in the entire frequency band, obtain the spectrum concentration CR, and output the dominant period corresponding to the dominant frequency as an auxiliary diagnostic quantity and the CR value synchronously; S13, Anti-oscillation market state determination: Determine the spectrum concentration CR using a two-layer nested state machine and output a stable market state label.
[0009] In the above technical solution, in step S12, the formula for calculating the spectral concentration CR is as follows: CR=P_dominant / P_total, where P_dominant is the power of the main frequency component, P_total is the total power of the non-DC component, and CR is a continuous dimensionless scalar with values in (0,1].
[0010] In the above technical solution, in step S13, the market state label includes trend state and oscillation state.
[0011] In the above technical solution, the specific process of step S13 is as follows: S131. Continuous confirmation counting by the first-layer state machine: map the current spectrum concentration CR value to the raw state raw_state with a fixed initial threshold theta, use a counter persisted across K-lines as the counting layer, and update the confirmed state confirmed_state to this direction only when the raw_state remains consistent for consecutive state_confirm_count sampling cycles; if the continuous consistency condition is not met, confirmed_state remains the value of the previous round unchanged; S132. Asymmetric dead zone correction by the second-layer state machine: taking the current confirmed_state as the condition reference, apply direction-asymmetric dual-threshold constraints to the final effective state, set a trend state entry threshold theta_enter and a trend state exit threshold theta_exit, where theta_exit < theta_enter, and a dead zone is formed between the two; when the current state is the oscillation state, the state switches to the trend state only when CR>theta_enter; when the current state is the trend state, the state switches to the oscillation state only when CR<theta_exit; when CR falls into the dead zone, the state remains unchanged; S133. Series operation of the two-layer mechanism: the counting layer restricts the temporal continuity of state switching, and the dead zone layer restricts the amplitude separability of state switching, the dual constraints suppress high-frequency oscillation in the critical region, and the state quantities including confirmed_state, count value, previous round of raw_state, CR value, and dominant cycle are all persisted in the independent context of each stock code, so as to ensure state isolation in the scenario of multiple underlying assets and output market state labels.
[0012] In the above technical solution, the specific process of step S2 is as follows: S21. Dual-channel routing: using the market state label as the routing key, route the signal generation process to the matched indicator channel, wherein when the state label is the trend state, the system activates the trend channel; when the state label is the oscillation state, the system activates the oscillation channel; when the state label switches, the system routes to the corresponding channel and suppresses the indicator calculation of the other channel, and the channel structure remains unchanged when specific indicators in the same channel are replaced or expanded; S22. Building-block type channel signal generation: the activated channel generates trading signals in a multi-layer series filtering manner, each layer encapsulates the calculation and judgment logic of an independent indicator, only exposes a binary pass / fail interface to the outside, and each layer is configured with an independent Boolean switch parameter use_ The system reads the switch status of each layer through the strategy configuration file: when the switch is on, the layer performs indicator calculation and judgment; when the switch is off, the layer degenerates into a constant pass no-operation and does not participate in the calculation. Short-circuit execution semantics are adopted between layers, that is, if any open layer fails the judgment, the current signal flow is immediately terminated and the calculation of all subsequent layers is skipped. The channel end outputs the trading signal based on the final calculation result. S23, Signal Cooling and Persistence: The channel end applies a cooling check to the trading signal, records the timestamp of the last signal in the same direction, and calculates the time interval between the current signal and the last signal in the same direction. If the interval is less than the cooling period signal_cooldown, the system blocks the signal to prevent excessive orders in a short period of time. Signals that pass the cooling check are persisted to the signal storage layer. The stored content includes stock code, signal direction, signal time, batch ID, and decouples signal generation and order execution in time.
[0013] In the above technical solution, the content of the indicator channel in step S21 is as follows: Trend Channel: Main Signal Layer QRS: A linear regression is established based on the highest and lowest price sequences of the most recent N_qrs K-lines to extract the slope β and goodness of fit R². The current β is standardized by Z-score using the β sequence of historical K-lines as a benchmark to obtain β_zscore. R² is normalized using the historical rolling average to obtain R²_norm. β_zscore and R²_norm are multiplied to form the QRS composite quantity QRS=β_zscore×R²_norm. The golden cross / death cross signal generated by QRS crossing the threshold is used as the main signal. If QRS does not cross the threshold, the system short-circuit and terminates the current channel, and does not execute subsequent layers; Confirmation Layer LLT: A second-order recursive low-delay trend line is used to perform linear regression on the most recent llt_slope_window K-lines to obtain the slope. The slope direction must be consistent with the direction of the main signal layer QRS signal to pass; otherwise, it will short-circuit and terminate; Confirmation Layer EMA: The bullish and bearish trends of the fast and slow moving averages are calculated and confirmed. State, enabled by use_ema=True; Confirmation Layer Kalman: Constructs a state vector using short-term moving averages, long-term moving averages, and volume position factors. The posterior state is calculated using a regularized least-squares estimation of the observation matrix, a diagonal state transition matrix, and standard Kalman gain. The short-term slope of the posterior price sequence is used for direction verification. Enabled by use_kalman=True; Oscillation Channel: Main Signal Layer KDJ: Detects golden crosses / death crosses between the K and D lines as the main signal. If no crossover occurs, the system short-circuits and terminates the current channel; Resonance Confirmation Layer RSI: Calculates the RSI value and determines whether it meets the following criteria: buy signals require RSI to be below the oversold threshold, and sell signals require RSI to be above the overbought threshold. Confirmation is achieved through extreme region resonance rather than direction following, limiting effective signals to the extreme RSI region; Confidence Layer RSRS: Standardizes the long-term historical Z-score of the linear regression slope of the most recent N_rsrs K lines as an optional confidence layer. Enabled by use_rsrs=True.
[0014] In the above technical solution, in step S22, each stock context maintains an incremental QRS state table to reduce computational complexity. The column set covers the complete intermediate results from the original high and low prices to the final QRS. When each new K-line arrives, a row is added to the end of the table and the derived columns of that row are recalculated. The historical rows remain unchanged, reducing the computational complexity of a single round and decoupling the backtesting overhead from the amount of historical data.
[0015] In the above technical solution, the specific strategy of step S3 is as follows: Read the persistent trading signal from the signal storage layer, execute the order using the best bid / ask price on the next tick after the signal time, and after opening a position, run bidirectional risk control monitoring at the tick level, including: Fixed stop loss: The system uses the opening price as an absolute reference, and forces a stop loss when the position loss exceeds stop_loss_rate; Chandelier take profit: When holding a long position, dynamically maintain the highest price during the holding period, and trigger take profit when the price retracement from the highest point exceeds chandelier_exit_rate and the net profit after deducting both sides' transaction fees is still positive; When holding a short position, dynamically maintain the lowest price during the holding period, and trigger take profit when the price rebound rate from the lowest point exceeds a threshold and the net profit is positive; The system sets the stop loss priority higher than the take profit priority to prevent logical competition between the two mechanisms during rapid declines.
[0016] The present invention also provides an intraday quantitative trading adaptive system based on spectrum concentration, including a computer device having a processor and a memory, wherein the processor processes a computer program stored in the memory, and the computer program is capable of executing an intraday quantitative trading adaptive method based on spectrum concentration.
[0017] This invention relates to an adaptive method and system for intraday quantitative trading based on spectral concentration, which has the following beneficial effects: 1. Innovation in frequency domain determination: Using FFT spectral concentration as the single continuous measure for market state determination, the computation time complexity is O(n log n), which is highly real-time. This is fundamentally different from existing methods based on HMM, ADX, volatility threshold or machine learning. No training process is required, the physical meaning of the parameters is clear, and they are easy to interpret and optimize.
[0018] 2. Asymmetric dead zone oscillation elimination: The asymmetric dual threshold and continuous confirmation counting mechanism work together to effectively suppress the problem of repeated state switching caused by frequent fluctuations in spectrum concentration in the critical range, and ensure the stability of trading signals at the market state boundary.
[0019] 3. Dual-channel routing eliminates mismatch: In trending markets, only trend-following indicator links are activated, and in oscillating markets, only oscillating indicator links are activated. This fundamentally avoids the lagging and misleading effects of trend indicators in oscillating markets and the reverse interference of oscillating indicators in trending markets, thereby improving the market adaptability of the strategy.
[0020] 4. Modular architecture reduces iteration costs: By managing strategy combinations through Boolean switch parameters and configuration files, adding or removing indicators does not require modifying the source code, shortening the strategy iteration cycle from days to minutes, and significantly reducing strategy development costs.
[0021] 5. Short-circuit execution improves computational efficiency: The short-circuit mechanism of the serial channel ensures that invalid signals are filtered out early, and the computation of subsequent layers can be skipped, which significantly reduces CPU utilization in multi-target parallel operation scenarios.
[0022] 6. Decoupling of signals and orders in T0 scenarios: Signals interact with the order conversion module through a persistent storage layer. The two modules run independently and support multi-threaded parallel processing of multiple targets. The order layer independently implements tick-by-tick dynamic profit-taking and stop-loss and forced liquidation at the end of the trading day, ensuring compliance with the requirement that A-share T0 trading does not involve overnight positions. The system has been running stably in the enterprise's internal live trading environment. Attached Figure Description
[0023] Figure 1 This is an overall workflow architecture diagram of Embodiments 1-2 of the intraday quantitative trading adaptive method based on spectrum concentration of the present invention. It shows the complete data flow of market data access, FFT spectrum concentration calculation, market status determination, dual-channel routing, multi-layer filtering channels and signal output. It also shows the hierarchical structure and independent switch configuration of the trend channel (L1: QRS main signal → L2: LLT confirmation → L3: EMA optional → L4: Kalman optional) and the oscillation channel (L1: KDJ main signal → L2: RSI confirmation → L3: RSRS optional). Figure 2 This is a flowchart illustrating steps S2-S3 in Embodiment 2 of the intraday quantitative trading adaptive method based on spectral concentration of the present invention. The left diagram discloses the FFT spectral concentration calculation flowchart, showing the detailed steps of differential preprocessing, fast Fourier transform, power spectrum calculation, main frequency identification, and concentration ratio calculation. The right diagram discloses a schematic diagram of the asymmetric dead zone dual threshold state machine, showing the switching conditions between trend state and oscillation state, dead zone range, and confirmation counting mechanism. Figure 3 This is a schematic diagram of the architecture of the intraday quantitative trading adaptive system based on spectrum concentration of the present invention. Detailed Implementation
[0024] The present invention will now be described in further detail with reference to the accompanying drawings and embodiments, but these embodiments should not be construed as limiting the present invention.
[0025] This invention relates to an adaptive signal generation and execution technology for intraday T+0 trading (same-day buy and sell) at the minute level in the A-share market. This technology uses Fourier frequency domain analysis to determine the market status in real time, uses status tags to drive dual-channel routing, generates trading signals through modular, switchable, serially filtered channels, and completes intraday closing through tick-by-tick risk control.
[0026] Example 1 See Figure 1This embodiment of the intraday quantitative trading adaptive method based on spectral concentration uses market conditions as the core hub to construct a complete adaptive signal processing link from market data access to intraday position closing. This link is connected in series in three steps according to the data flow direction, with the output of the preceding step serving as the input of the subsequent step: State determination: Extract the spectral concentration from the frequency domain, and output a stable market state label through an anti-oscillation state machine; State-driven routing and signal generation: Using state tags as routing keys, matching heterogeneous indicator channels are activated, and trading signals are generated through modular serial filtering. Signal execution and risk control: After the signal is cooled and persisted, the order layer executes the chandelier profit-taking and fixed stop loss tick by tick, and forces liquidation at the end of the trading day.
[0027] The status label (output of step 1) determines which channel is activated (input of step 2), and the trading signal output by the channel (output of step 2) drives the order risk control (input of step 3). These three are different steps of the same method connected in series according to the data flow under the same inventive concept. These three steps can also be considered as parallel independent solutions (see embodiment 3 for details).
[0028] Example 2 This embodiment is basically the same as Embodiment 1, except that: The method in this embodiment includes the following steps performed in sequence: S1, Market Data Preprocessing The system receives minute-level market data for the target security, including timestamps, opening price, highest price, lowest price, closing price, trading volume, and best bid / ask price. The system extracts the closing price sequence from the market data and pre-smooths it using a moving average window `ma_window` (default 15 in this embodiment) to obtain a smoothed price sequence, eliminating the interference of micro-tick fluctuations on subsequent spectrum analysis. The system then performs first-order differencing on the nearest `fft_window` (default 30 in this embodiment) samples of the smoothed price sequence to obtain a differencing sequence, eliminating the influence of non-stationary trend terms on spectrum estimation. This differencing sequence is the output of this step and is passed to the next step.
[0029] S2, Spectral Concentration Calculation (e.g.) Figure 2 (As shown) The system performs a Fast Fourier Transform (FFT) on the difference sequence output by S1 to obtain a complex sequence in the frequency domain. Utilizing the conjugate symmetry of the real sequence, the system retains only the positive frequency components on one side and removes the zero-frequency DC component (corresponding to price mean shift), obtaining the effective one-sided power spectrum. The system identifies the dominant frequency component with the highest power in the power spectrum and calculates the normalized ratio of the power of this dominant frequency component to the total power of the non-DC components across the entire frequency band, obtaining the spectral concentration CR. CR=P_dominant / P_total Wherein, P_dominant is the power of the dominant frequency component, and P_total is the total power of non-DC components. CR is a continuous dimensionless scalar with a value in the range of (0, 1]. When the market is in a sustained unidirectional movement, the energy of the difference sequence is concentrated on a single dominant frequency, and CR approaches 1; when the market is in a random walk or multi-frequency mixed oscillation, the energy is evenly dispersed, and CR approaches the lower limit. The system simultaneously outputs the dominant period corresponding to the dominant frequency as an auxiliary diagnostic quantity. The CR value and the dominant period are jointly used as the output of this step, and transmitted to the next step.
[0030] S3. Anti-oscillation market state determination The system determines the spectrum concentration CR output from S2 by a two-layer nested state machine, and outputs a stable market state label (trend state / oscillation state).
[0031] First layer - continuous confirmation counting: The system maps the current CR value to the raw state raw_state (in this embodiment, the raw state includes a trend state or an oscillation state) with a fixed initial threshold theta (in this embodiment, the default is 0.4). The system maintains a counter that persists across K-lines, and only when the raw_state remains consistent for consecutive state_confirm_count (in this embodiment, the default is 3) sampling periods, the confirmed state confirmed_state is updated to this direction; if the continuous consistency condition is not met, confirmed_state remains the value of the previous round unchanged.
[0032] Second layer - asymmetric dead zone correction: The system takes the current confirmed_state as the condition reference, and imposes direction-asymmetric double threshold constraints on the final effective state. The system sets a trend state entry threshold theta_enter (in this embodiment, the default is 0.45) and a trend state exit threshold theta_exit (in this embodiment, the default is 0.35), and theta_exit < theta_enter, forming a dead zone between the two. When the current state is the oscillation state, the system switches the state to the trend state only when CR>theta_enter; when the current state is the trend state, the system switches the state to the oscillation state only when CR<theta_exit; when CR falls into the dead zone, the state remains unchanged.
[0033] A two-layer mechanism operates in series: the counting layer constrains the temporal continuity of state transitions, while the dead zone layer constrains the amplitude separation of state transitions. This dual constraint suppresses high-frequency oscillations in the critical region. All state variables—confirmed_state, count value, previous round raw_state, CR value, and dominant cycle—are persisted in the independent context of each stock code, ensuring state isolation in concurrent scenarios involving multiple stocks. The market state label output in this step is passed to the next step.
[0034] S4, Dual-channel routing The system uses the status label output in step S3 as the routing key to route the signal generation process to the matching indicator channel. When the status label is in a trending state, the system activates the trend channel, which includes trend-following indicators such as QRS, LLT, EMA, and Kalman. When the status label is in an oscillating state, the system activates the oscillating channel, which includes overbought / oversold / mean-reverting indicators such as KDJ, RSI, and RSRS. When the status label changes, the system automatically routes to the corresponding channel and suppresses the indicator calculation of the other channel, without manual intervention. Specific indicators within the same channel can be replaced or expanded, while the channel structure remains unchanged. The routing result (the activated channel identifier) is passed to the next step.
[0035] S5, modular channel signal generation The system generates trading signals using a multi-layered serial filtering method within the channel activated in step S4. Each layer encapsulates the calculation and judgment logic of an independent indicator, exposing only a binary pass / fail interface to the outside world. Each layer is configured with an independent Boolean switch parameter `use_`. The system reads the switch status of each layer through the strategy configuration file. When a switch is on, the layer performs index calculation and judgment; when a switch is off, the layer degenerates into a constant pass no-operation and does not participate in the calculation. Short-circuit execution semantics are used between layers: if any on layer fails the judgment, the system immediately terminates the current signal flow and skips the calculation of all subsequent layers.
[0036] Trend channels (L1-L4): L1 Main Signal Layer (Required) QRS: The system establishes a linear regression on the highest and lowest price sequences of the most recent N_qrs (18 by default in this embodiment) candlesticks, extracting the slope β and goodness-of-fit R². The system uses the β sequence of 200 historical candlesticks as a benchmark to perform Z-score standardization on the current β, obtaining β_zscore; and normalizes R² using the historical rolling mean, obtaining R²_norm. The system multiplies the two to form the QRS composite quantity = β_zscore × R²_norm, and detects the golden cross / death cross signal generated when the QRS crosses the threshold (+0.8 / -0.8 in this embodiment) as the main signal. If the QRS does not cross the threshold, the system short-circuit and terminates the current channel, without executing subsequent layers.
[0037] L2 Confirmation Layer (enabled by default): The system uses a second-order recursive low-latency trend line and performs linear regression on the nearest llt_slope_window root K-line to obtain the slope. The slope direction must be consistent with the L0 signal direction to pass; otherwise, it will be short-circuited and terminated.
[0038] L3 Confirmation Layer (Disabled by Default) EMA: The system calculates the bullish or bearish status of the fast and slow moving averages to confirm the bullish or bearish trend. It can be enabled by using_ema=True.
[0039] L4 Confirmation Layer (Disabled by Default) Kalman: The system uses short-term moving averages, long-term moving averages, and volume position factors to form a state vector. It calculates the posterior state by estimating the observation matrix with regularization, the diagonal state transition matrix, and the standard Kalman gain. It uses the short-term slope of the posterior price sequence for direction verification. It can be enabled by using_kalman=True.
[0040] Oscillating channel (L1-L3): L1 Main Signal Layer (Required) KDJ: The system detects the golden cross / death cross between the K-line and D-line as the main signal. If no crossover occurs, the system short-circuit and terminates the current channel.
[0041] L2 Resonance Confirmation Layer (enabled by default) RSI: The system calculates the RSI value. A buy signal requires the RSI to be below the oversold threshold (30 by default in this embodiment), and a sell signal requires the RSI to be above the overbought threshold (70 by default in this embodiment). Confirmation is achieved through resonance in extreme regions rather than directional following, limiting the effective signal to the extreme regions of the RSI.
[0042] L3 Confidence Layer (Disabled by Default) RSRS: The system performs long-term historical Z-score standardization on the linear regression slope of the most recent N_rsrs K-lines high and low prices. It is an optional confidence layer and can be enabled by using_rsrs=True.
[0043] To reduce computational complexity, the system maintains an incremental QRS state table in each stock context, with a column set covering the complete intermediate results (β, R², β_zscore, R²_norm, QRS) from the original high and low prices to the final QRS. When a new candlestick arrives, the system only appends a row to the end of the table and recalculates the derived columns of that row, while the historical rows remain unchanged. The computational complexity of a single round is reduced to O(N), decoupling backtesting overhead from the amount of historical data.
[0044] The trading signal (including signal direction) output at the end of the channel is transmitted to the next step.
[0045] S6, Signal Cooling and Persistence The system applies a cooling-off check to the trading signals output by S5 at the end of the channel. The system records the timestamp of the last signal in the same direction and calculates the time interval between the current signal and the last signal in the same direction. If the interval is less than the cooling-off period `signal_cooldown` (5 minutes by default in this embodiment), the system blocks the signal to prevent excessive orders in a short period. Signals that pass the cooling-off check are persistently written to the signal storage layer by the system. The stored content includes the stock code, signal direction, signal time, and batch ID. This step decouples signal generation from order execution in time—this step is completed after the signal is written to the storage layer, and order execution can be performed independently subsequently.
[0046] S7, Delegated Execution and Tick-by-Tick Risk Control The system reads persistent trading signals from the S6 signal storage layer and executes the order using the best bid / ask price on the next tick after the signal's expiration time. After opening a position, the system runs bidirectional risk control monitoring at the tick level. Fixed stop loss: The system uses the opening price as an absolute reference and will force a stop loss and close the position when the loss exceeds stop_loss_rate (2.3% by default in this example).
[0047] Chandelier profit-taking: When holding a long position, the system dynamically maintains the highest price during the holding period. When the price retracement rate from the highest point exceeds chandelier_exit_rate (25% by default in this embodiment) and the net profit after deducting both-sided transaction fees is still positive, the profit-taking and closing of the position is triggered. When holding a short position, the system dynamically maintains the lowest price during the holding period. When the price rebound rate from the lowest point exceeds this threshold and the net profit is positive, the profit-taking and closing of the position is triggered.
[0048] The system prioritizes stop-loss over take-profit to prevent logical competition between the two mechanisms during rapid price drops. For all open positions within the day, the system forcibly closes them at the best available price on the first tick after 14:45:00, ensuring zero overnight positions. In multi-asset concurrent scenarios, the system submits each (stock code, date, strategy ID) triple as an independent task to a thread pool. Each task runs in a completely isolated local state, naturally satisfying thread safety.
[0049] Example 3 The three stages of the intraday quantitative trading adaptive method based on spectrum concentration disclosed in this embodiment are relatively independent and are independent variations of Embodiments 1-2 under the same inventive concept.
[0050] I. Methods for Determining Market Condition A market state determination method based on FFT spectrum concentration for intraday T+0 trading at the minute level in A-shares includes: performing differential preprocessing on the minute-level price series of A-shares, performing Fast Fourier Transform, calculating the ratio of the main frequency power to the total non-DC power to obtain the spectrum concentration; setting asymmetric dead zone dual thresholds (entry threshold is higher than exit threshold), combined with a continuous N-cycle confirmation counting mechanism (the counter is reset to 1 when the state is inconsistent), and outputting a stable state label for trending market or oscillating market to drive subsequent signal routing.
[0051] II. Dual-channel strategy routing method A dual-channel quantitative trading strategy routing method based on market conditions includes: classifying technical indicators into trend-following and oscillating categories according to their functional attributes; establishing a mapping rule between market conditions and indicator categories; and automatically routing the signal generation process to the corresponding category of indicator links based on the determination result of the method described in claim 1.
[0052] III. Modular Signal Generation Device A modular, multi-layered, independently switchable quantitative trading signal generation device for A-share minute-level T0 trading includes: multi-layered serial filtering channels, each layer encapsulating the calculation logic of independent indicators; independent Boolean switch parameters, controlling the activation or deactivation of each layer through configuration files; a short-circuit execution mechanism, terminating the calculation of subsequent layers if any activated layer fails; a signal cooling mechanism to prevent repeated issuance of signals in the same direction within a short period; and a persistent signal storage interface, decoupling the signal generation module from the order execution module, allowing the order execution module to independently implement tick-by-tick dynamic stop-loss, fixed-ratio stop-loss, and forced liquidation at the end of the trading day.
[0053] Example 4 This embodiment is basically the same as embodiment 3, except that: I. Market Status Determination Method Based on FFT Spectral Concentration This technical solution achieves real-time market status determination through the following steps: Data preprocessing: Obtain the price time series (closing price) of the target security, perform first difference on the series to obtain the return series, and eliminate the interference of non-stationary trend terms on the spectrum estimation.
[0054] Frequency domain transformation: Perform a Fast Fourier Transform (FFT) on the differenced return series to calculate the power spectral density of each frequency component (i.e., the square of the modulus of each frequency component).
[0055] Spectrum concentration calculation: After removing the DC component (zero-frequency component), the dominant frequency component with the maximum power is identified, and the ratio of its power value to the total power of the full frequency band is calculated to obtain the Spectrum Concentration Ratio (CR): CR = P_dominant / P_total, where P_dominant is the power of the dominant frequency component, and P_total is the total power of non-DC components. The value range of CR is (0,1]. A higher CR indicates that energy is more concentrated in a single frequency, and the market presents regular periodic movements; a lower CR indicates that energy is dispersed in multiple frequencies, and the market behaves as irregular fluctuations.
[0056] Asymmetric dead-zone dual-threshold judgment: A high threshold theta_enter for entering the trend state (in this embodiment, the high threshold for the trend state is 0.45) and a low threshold theta_exit for exiting the trend state (in this embodiment, the low threshold for the trend state is 0.35) are set, where theta_exit < theta_enter, forming a dead zone with a width of (theta_enter - theta_exit). When the current confirmed state is the fluctuation state, the switching judgment to the trend state is triggered only when CR > theta_enter; when the current confirmed state is the trend state, the switching judgment to the fluctuation state is triggered only when CR < theta_exit; when CR is within the dead zone, the current state remains unchanged, and no switching logic is triggered.
[0057] Continuous confirmation counting mechanism: A state confirmation counter is introduced. The state switching is executed and the confirmed state is updated only when the original judgment results of N consecutive sampling periods (the default value is 3 in this embodiment) are all the same state. If an inconsistent judgment result appears midway, the counter is reset to 1 and the accumulation restarts, so as to avoid false switching caused by a single abnormal sampling point.
[0058] 2. Dual-channel policy routing method based on index function classification This technical solution implements automatic routing of the signal generation process based on the market state judgment of the first technical solution: Index classification registration: An index function classification pool is constructed, and optional technical indices are divided into at least two categories according to their design principles and applicable market environments: trend indices, which include indices that track continuous price movements, such as QRS (Regression Slope Strength Index), LLT (Low-Latency Trend Line), EMA (Exponential Moving Average), Kalman filter trend, etc.; fluctuation indices, which include indices that identify overbought / oversold or mean reversion opportunities, such as KDJ Stochastic Index, RSI Relative Strength Index, RSRS Resistance-Support Relative Strength, etc.
[0059] Routing mapping establishment: Establish fixed mapping rules between market status and indicator categories: Trending market → activate trend-related indicator links; Oscillating market → activate oscillating indicator links.
[0060] State-triggered routing: When the state determination result of technical solution one changes, the system automatically routes the subsequent signal generation process to the corresponding category of indicator link without manual intervention, and at the same time suppresses the indicator calculation of the other link to avoid resource waste.
[0061] Intra-link metric replaceability: Specific metrics within the same category of links can be replaced or expanded as needed, while the category structure remains unchanged. This supports the dynamic access of new metrics without affecting the routing logic.
[0062] III. Modular, multi-layered, independently switchable signal generation device This technical solution provides a configurable multilayer serial signal filtering channel structure: Layered channel abstraction: The signal generation process is abstracted into multiple series filtering channels (in this embodiment, L1, L2, L3, …, Ln). Each layer encapsulates the calculation logic of an independent indicator and the signal judgment rules, and the judgment results are transmitted between layers through a standardized interface.
[0063] Independent Boolean Switch: Each layer is configured with independent Boolean switch parameters (use_ The enabled or disabled status of this layer is controlled by reading the policy configuration file, without the need to modify the code logic.
[0064] Short-circuit execution mechanism: A series short-circuit execution strategy is adopted. If the filtering condition of any enabled layer fails, the current signal generation process is terminated directly, skipping the calculation of all subsequent layers, thus reducing the overhead of invalid calculations.
[0065] In-layer signal cooling mechanism: A signal cooling timer is set at the end of the channel to record the timestamp of the last signal. During the cooling period, the signal output in the same direction is blocked to prevent excessive orders from being generated due to repeated triggering of the same index in a short period of time.
[0066] Dual-channel instantiation: Based on the routing results of technical solution two, a trend channel and an oscillation channel are instantiated separately. The two channels operate independently and do not interfere with each other. The currently active channel is dynamically determined by the market status.
[0067] Example 4-1: Market Status Determination Based on FFT Spectral Concentration Taking minute-level market data of a certain A-share STAR Market stock as an example, the system operates according to the following steps: Collect the closing price sequence of the most recent fft_window root K-line (30 by default in this embodiment), and perform first difference on it to obtain a return sequence of length 29.
[0068] Perform an FFT on the return series to calculate the power spectral density. After removing the zero-frequency component, identify the dominant frequency component with the largest power and calculate the spectral concentration CR.
[0069] Apply asymmetric dead zones: entry threshold theta_enter = 0.45, exit threshold theta_exit = 0.35. If the current confirmed state is an oscillation state and CR > 0.45, then the original state is marked as a trend state; otherwise, the oscillation state is maintained. If the current confirmed state is a trend state and CR < 0.35, then the original state is marked as an oscillation state; otherwise, the trend state is maintained.
[0070] Continuous Confirmation: Compare the original state from step 3 with the previous original state recorded in the confirmation counter. If they are consecutively the same, the counter is incremented; if they are different, the counter is reset to 1, and a new original state is recorded. When the counter reaches state_confirm_count (default 3 in this embodiment), the confirmation state is updated and the routing module is notified.
[0071] Example 4-2: Dual-channel policy routing and modular channel configuration Following the state determination result of Example 4-1, policy routing is executed according to the following steps: When the market is confirmed to be trending, the route is routed to the trend channel, activating the following layered channels (each layer can be configured with an independent switch): L1 (required): The QRS indicator calculates the β_zscore×R²_norm combination value and detects the golden cross / death cross signal at its crossing threshold (±0.8 in this embodiment) as the main signal; L2 (enabled by default in this embodiment): The LLT low-latency trend line calculates the linear regression slope of the most recent llt_slope_window root K-line, and the direction must be consistent with the L1 signal to pass; L3 (disabled by default in this embodiment): The EMA fast and slow lines confirm the bullish / bearish status, and are enabled by configuring use_ema=True; L4 (disabled by default in this embodiment): The Kalman filter trend slope confirms the trend slope, and is enabled by configuring use_kalman=True.
[0072] When the market is confirmed to be in a range-bound state, the routing is directed to the range-bound channel, activating the following layered channels: L1 (required): KDJ indicator K-line and D-line golden cross / death cross signal as the main signal; L2 (enabled by default in this embodiment): RSI indicator resonance confirmation, with buy signals requiring RSI to be below the oversold threshold (30 by default in this embodiment), and sell signals requiring RSI to be above the overbought threshold (70 by default in this embodiment); L3 (disabled by default in this embodiment): RSRS resistance and support relative strength standardized score confirmation, enabled by configuring use_rsrs=True.
[0073] The signal cooling module at the end of the channel checks the time interval since the last signal was sent. If it is less than signal_cooldown (5 minutes by default in this embodiment), the current signal output is blocked; otherwise, the signal is written to the signal storage layer for subsequent processing by the delegate conversion module.
[0074] Example 4-3: Deployment and Verification of A-Share T+0 Live Trading System This embodiment has been deployed and is running in the company's internal A-share T+0 live trading system. The system architecture is as follows: Market data access layer: Receives A-share minute-level real-time market data (including TS timestamp, open, high, low, close, volume, and bid / ask prices) through the market data interface, and distributes it to the corresponding strategy instances according to stock codes.
[0075] Strategy execution layer: Each stock code maintains an independent context to store state information across K-lines (FFT confirmation status, QRS calculation intermediate value, LLT historical value, signal cooldown timestamp, etc.). Multiple targets are processed in parallel through multi-threading without interference.
[0076] Signal storage layer: The buy and sell signals generated by the strategy are persistently written to the database (including stock code, signal direction, signal time, and batch ID), decoupled from the order execution module, and supporting post-event analysis of signals and strategy attribution.
[0077] The order execution layer: The process_signal2trade module runs independently, reads the signal database, and executes simulated orders or live orders using the best bid / ask price on the next tick after the signal time. The total daily authorized volume for a single target is 10,000 shares, the single transaction is 1,000 shares, and the maximum bilateral exposure is 2,000 shares.
[0078] Risk control monitoring layer: Continuously monitor each opening position tick by tick to achieve chandelier-level profit-taking (closing the position when the pullback from the highest / lowest price exceeds chandelier_exit_rate and the net profit is positive) and fixed-ratio stop loss (forced closing the position when the loss exceeds stop_loss_rate). Force all positions to close at 14:45:00 at the end of the trading day to ensure that no positions are held overnight.
[0079] The system has been fully tested and verified on 50 targets over 39 trading days. The dual-channel routing mechanism effectively distinguishes the signal generation logic under trending and oscillating market conditions. The modular switch allows for adjustment of strategy combinations via parameter files without shutting down the system.
[0080] Example 5 See Figure 3 This embodiment of the intraday quantitative trading adaptive system based on spectrum concentration includes the following: State determination module: Extracts spectral concentration from the frequency domain and outputs a stable market state label via an anti-oscillation state machine; and / or State-driven routing and signal generation module: Using state tags as routing keys, it activates matching heterogeneous indicator channels and generates trading signals through modular serial filtering; and / or Signal execution and risk control module: After the trading signal is cooled and persisted, the order layer executes the stop-loss and take-profit orders tick by tick, and forces liquidation at the end of the trading day.
[0081] Comparative Example Explanation of differences from existing technologies: The core differences between this invention and major existing technologies are shown in Table 1 below: Table 1 Key Technical Features of the Invention
[0082] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.
[0083] The contents not described in detail in this specification are existing technologies known to those skilled in the art.
Claims
1. An adaptive intraday quantitative trading method based on spectrum concentration, characterized in that: Includes the following steps: S1. State determination: Extract the spectral concentration from the frequency domain and output a stable market state label through an anti-oscillation state machine; and / or S2. Generate state-driven routing and signals: Using state tags as routing keys, activate matching heterogeneous indicator channels, and generate trading signals through modular serial filtering. and / or S3. Signal Execution and Risk Control: After the trading signal is cooled and persisted, the order layer executes the stop-loss and take-profit orders tick by tick, and forces liquidation at the end of the trading day.
2. The adaptive intraday quantitative trading method based on spectral concentration according to claim 1, characterized in that: The specific process of step S1 is as follows: S11. Market data preprocessing: Receive minute-level market data of the target security, extract the closing price sequence from the market data, pre-smooth the closing price sequence using a moving average window ma_window to obtain a smoothed price sequence, take the nearest fft_window samples of the smoothed price sequence for first-order difference to obtain a difference sequence, and eliminate the influence of non-stationary trend terms on spectrum estimation. S12. Calculation of Spectral Concentration: Perform a Fast Fourier Transform on the difference sequence to obtain a complex sequence in the frequency domain. Utilize the conjugate symmetry of the real sequence to retain only the positive frequency component on one side and remove the zero-frequency DC component to obtain the effective one-sided power spectrum. Identify the dominant frequency component with the largest power in the power spectrum, calculate the normalized ratio of the power of the dominant frequency component to the total power of the non-DC components in the entire frequency band, and obtain the spectral concentration CR. The dominant period corresponding to the dominant frequency is used as an auxiliary diagnostic quantity and output synchronously with the CR value. S13, Anti-oscillation Market State Determination: The spectrum concentration CR is determined by a two-layer nested state machine, and a stable market state label is output.
3. The adaptive intraday quantitative trading method based on spectral concentration according to claim 2, characterized in that: In step S12, the formula for calculating the spectral concentration CR is as follows: CR = P_dominant / P_total Where P_dominant is the power of the main frequency component, P_total is the total power of the non-DC component, and CR is a continuous dimensionless scalar with values in (0,1].
4. The adaptive intraday quantitative trading method based on spectral concentration according to claim 3, characterized in that: In step S13, the market status label includes trending state and oscillating state.
5. The adaptive intraday quantitative trading method based on spectral concentration according to claim 4, characterized in that: The specific process of step S13 is as follows: S131, First-level state machine continuous confirmation count: The current spectral concentration CR value is mapped to the original state raw_state using a fixed initial threshold theta. A counter persisted across K-lines is used as the counting layer. The confirmed state confirmed_state is updated to the direction only when the raw_state of the consecutive state_confirm_count sampling periods is consistent. If the continuous consistency condition is not met, the confirmed_state remains unchanged from the previous round. S132. The second-layer state machine corrects the asymmetric dead zone: taking the current confirmed_state as the condition reference, direction-asymmetric dual-threshold constraints are applied to the final effective state, the trend state entry threshold theta_enter and the trend state exit threshold theta_exit are set, with theta_exit < theta_enter, forming a dead zone between the two; when the current state is the oscillation state, the state switches to the trend state only when CR>theta_enter; when the current state is the trend state, the state switches to the oscillation state only when CR<theta_exit; when CR falls within the dead zone, the state remains unchanged; S133. Two-layer mechanisms operate in series: the counting layer constrains the temporal continuity of state switching, and the dead zone layer constrains the amplitude separability of state switching. The dual constraints suppress high-frequency oscillation in the critical zone. State quantities including confirmed_state, count value, previous round raw_state, CR value, and dominant cycle are all persisted in the independent context of each stock code, ensuring state isolation in the multi-target concurrent scenario and outputting market state labels.
6. The adaptive intraday quantitative trading method based on spectral concentration according to claim 5, characterized in that: The specific process of step S2 is as follows: S21. Dual-channel routing: Using the market state label as the routing key, the signal generation process is routed to the matching indicator channel. When the state label is the trend state, the system activates the trend channel; when the state label is the oscillation state, the system activates the oscillation channel; when the state label switches, the system routes to the corresponding channel and suppresses the indicator calculation of the other channel, and the channel structure remains unchanged when specific indicators in the same channel are replaced or extended; S22. Modular Channel Signal Generation: Activated channels generate trading signals using a multi-layered, serial filtering method. Each layer encapsulates the calculation and judgment logic of an independent indicator, exposing only a binary pass / fail interface. Each layer is configured with an independent Boolean switch parameter `use_`. The system reads the switch status of each layer through the strategy configuration file: when the switch is on, the layer performs indicator calculation and judgment; when the switch is off, the layer degenerates into a constant pass no-operation and does not participate in the calculation; short-circuit execution semantics are used between layers, that is, if any open layer fails the judgment, the current signal flow is immediately terminated and the calculation of all subsequent layers is skipped; at the end of the channel, the trading signal is output based on the final calculation result. S23. Signal cooling and persistence: A cooling check is applied to the trading signal at the end of the channel, the timestamp of the last signal in the same direction is recorded, and the time interval between the current signal and the last signal in the same direction is calculated: if the interval is less than the cooling period signal_cooldown, the system blocks the signal to prevent excessive orders in a short period of time. The signals that pass the cooling check are persistently written into the signal storage layer, with the stored content including stock code, signal direction, signal time, and batch ID, which decouples signal generation and order execution in time.
7. The adaptive intraday quantitative trading method based on spectral concentration according to claim 6, characterized in that: In step S21, the content of the indicator channel is as follows: Trend channel: Main signal layer QRS: A linear regression is established based on the sequence of the highest price and the lowest price of the latest N_qrs K-lines, the slope β and the goodness of fit R² are extracted, Z-score standardization is performed on the current β based on the β sequence of multiple historical K-lines to obtain β_zscore; normalization is performed on R² using the historical rolling mean to obtain R²_norm, and β_zscore is multiplied by R²_norm to form the QRS composite quantity QRS=β_zscore×R²_norm; the golden cross / death cross signal generated by QRS crossing the threshold is detected as the main signal. If QRS does not cross the threshold, the system short-circuits and terminates the current channel, and does not execute subsequent layers; Confirmation layer LLT: Uses a second-order recursive low-delay trend line, performs linear regression on the nearest llt_slope_window root K line to obtain the slope, and the slope direction must be consistent with the direction of the main signal layer QRS signal to pass; otherwise, it will be short-circuited and terminated. Confirmation Layer EMA: Calculates and confirms the bullish or bearish status of the fast and slow moving averages, enabled by use_ema=True; Confirmation layer Kalman: The state vector is constructed using short-term moving averages, long-term moving averages and volume position factors. The posterior state is calculated by estimating the observation matrix with regularization, the diagonal state transition matrix and the standard Kalman gain. The short-term slope of the posterior price sequence is used for direction verification. It is enabled by use_kalman=True. Oscillation Channel: The main signal layer KDJ detects the golden cross / death cross between the K line and the D line as the main signal. If no crossover occurs, the system short-circuit and terminates the current channel. Resonance Confirmation Layer RSI: Calculate the RSI value and determine whether it meets the requirements. A buy signal requires the RSI to be below the oversold threshold, and a sell signal requires the RSI to be above the overbought threshold. Confirmation is made through resonance in extreme areas rather than by following the direction, limiting the effective signal to the extreme areas of RSI. Confidence layer RSRS: The slope of the linear regression of the recent N_rsrs root K-line high and low prices is standardized using long-term historical Z-score. It is an optional confidence layer and can be enabled by using_rsrs=True.
8. The adaptive intraday quantitative trading method based on spectral concentration according to claim 7, characterized in that: In step S22, each stock context maintains an incremental QRS state table to reduce computational complexity. The column set covers the complete intermediate results from the original high and low prices to the final QRS. When each new K-line arrives, a row is appended to the end of the table and the derived columns of that row are recalculated. The historical rows remain unchanged, reducing the computational complexity of a single round and decoupling the backtesting overhead from the amount of historical data.
9. The adaptive intraday quantitative trading method based on spectral concentration according to claim 8, characterized in that: The specific strategy for step S3 is as follows: The system reads persistent trading signals from the signal storage layer and executes orders using the best bid / ask price on the next tick after the signal time. After opening a position, it runs bidirectional risk control monitoring at the tick level, including: Fixed stop loss: The system uses the opening price as an absolute reference and will force a stop loss and close the position when the loss exceeds stop_loss_rate; Chandelier Take Profit: When holding a long position, the highest price during the holding period is dynamically maintained. When the price retracement rate from the highest point exceeds chandelier_exit_rate and the net profit after deducting both sides' transaction fees is still positive, the take profit and close the position is triggered. When holding a short position, the lowest price during the holding period is dynamically maintained. When the price rebound rate from the lowest point exceeds the threshold and the net profit is positive, the take profit and close the position is triggered. The system prioritizes stop-loss over take-profit to prevent logical competition between the two mechanisms during a rapid decline.
10. An adaptive intraday quantitative trading system based on spectral concentration, comprising a computer device having a processor and a memory, wherein the processor processes a computer program stored in the memory, characterized in that: The computer program is capable of executing the intraday quantitative trading adaptive method based on spectral concentration as described in any one of claims 1 to 9.
