Dynamic residual and physical constraint-based power spot price forecasting method and system
By using a two-stage machine learning model that dynamically extracts market price benchmarks and time decay weights, combined with discrete Boolean early warning features and shadow rules, the problem of missed predictions in existing electricity price forecasting methods during extreme peak electricity prices and sudden changes in market rules is solved, achieving higher accuracy in electricity price forecasting.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- YUANYOUZHI NETWORK TECHNOLOGY (CHONGQING) CO LTD
- Filing Date
- 2026-05-06
- Publication Date
- 2026-07-31
AI Technical Summary
Existing electricity price forecasting methods fail to predict extreme peak electricity prices, are unable to adapt to sudden changes in market rules, and suffer from the problem of feature poisoning, which reduces the model's judgment ability.
A method for predicting spot electricity prices using dynamic residuals and physical constraints is proposed. This method dynamically extracts the market price benchmark, uses a two-stage machine learning model with time-decayed sample weights, and combines discrete Boolean warning features and shadow rules for post-processing correction.
It improves the accuracy of electricity price forecasting, enables timely detection of extreme peaks and administrative interventions, and enhances the commercial value of energy storage dispatch.
Smart Images

Figure CN122492295A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of power dispatching, electricity spot market trading and decision support, and more specifically, to a method, system, device and storage medium for predicting electricity spot prices based on dynamic residuals and physical constraints. Background Technology
[0002] With the development and advancement of the electricity spot market, electricity prices are exhibiting characteristics such as high-frequency fluctuations and significant nonlinearity. In order to formulate optimized bidding and energy storage charging and discharging strategies in the day-ahead market, market participants have placed extremely high demands on the forecasting accuracy of day-ahead spot clearing prices.
[0003] Current electricity price forecasting methods mostly employ single deep learning models (such as LSTM and Transformer) or traditional machine learning regression models (such as XGBoost and Random Forest). In practical applications, existing technologies generally suffer from the following fatal flaws: Variance collapse and mean normalization issues: Since continuous regression models tend to output the sample mean, when faced with extreme peak electricity prices caused by "depletion of reserve capacity" in the electricity market, existing models often predict a smooth transition curve and cannot effectively issue high price warnings (i.e., miss extreme peaks).
[0004] Predictive failures caused by sudden market rule changes: China's electricity market is characterized by cross-month long-term contract rollovers and artificially raised price floor levels. When the market experiences sudden rule changes, pure autoregressive models trained on absolute prices exhibit severe amnesia lag, causing prediction curves to collectively hang or bottom out, resulting in a precipitous drop in directional accuracy.
[0005] Feature poisoning problem: Existing technologies often use continuous variables such as the system net load ramp-up rate as global feature inputs, which causes the attention of the tree model to be diluted by noise from a large number of useless cycles, thus impairing the model's ability to make judgments during actual power outages. Summary of the Invention
[0006] To address the problems of "variance collapse," difficulty in adapting to "sudden market changes," and missed predictions of extreme peaks in existing electricity price forecasting, this application provides a method, system, device, and storage medium for electricity spot price forecasting based on dynamic residuals and physical constraints.
[0007] The first aspect of this invention provides a method for predicting spot electricity prices based on dynamic residuals and physical constraints, the method comprising: Step S1: Obtain electricity market supply and demand forecast data for the target area at the target time, as well as the lagged historical data for anti-crossing; Step S2: Based on the lagging historical data, dynamically extract the market price benchmark within the sliding time window, and transform the absolute price prediction target into a price residual target based on the benchmark; Step S3: Based on the supply and demand forecast data and the lagged historical data, a two-stage machine learning model with time decay sample weights is used to predict the price residual target and obtain the prediction residual; Step S4: Extract physical constraint features that reflect extreme power grid conditions, construct early warning triggering conditions, and perform post-processing correction on the prediction residuals based on the early warning triggering conditions and historical shadow rules; Step S5: Add the corrected prediction residual to the market price benchmark to obtain the target prediction price for the target time.
[0008] In this solution, the method for dynamically extracting and converting the market price benchmark in step S2 includes: Extract historical real price data for a preset number of days prior to the target time; Kernel density estimation or high-precision discrete frequency statistics are performed on the historical real price data to remove dirty data below the abnormal threshold, and the most frequent price mode is extracted as the dynamic market price benchmark. The price residual target is obtained by subtracting the dynamic market price benchmark from the actual price at the target time.
[0009] In this scheme, the prediction process of the two-stage machine learning model in step S3 includes: The first stage of classification: Historical electricity prices are divided into valley, flat and peak states according to preset intervals, and a state classifier is trained to predict the price state of the target time. Second-stage regression: For the valley, flat, and peak states, construct independent conditional regressors respectively; based on the price state predicted in the first stage, call the corresponding conditional regressors to predict the price residual target.
[0010] In this scheme, the method with time-decayed sample weights includes: Historical training samples are assigned exponentially decaying weights, with samples closer to the target time having larger weights, in order to force the model to adapt to the latest market conditions; When historical data is missing for an entire day, feature mapping is performed using data from the same period a preset number of days before the target time, and the sample weight of the interpolated date is forcibly set to 0 to block the model from learning the gradient of the interpolated pseudo-label.
[0011] In this scheme, the physical constraint features in step S4 are transformed from continuous variables into discrete Boolean warning feature inputs, and the warning features include: Positive reserve depletion warning feature: When the actual positive reserve rate is lower than the set depletion threshold at the same time the day before the target time, the feature value is 1; otherwise, it is 0. Congestion prediction warning feature: When the standard deviation of the day-ahead node electricity price at the same time on the day before the target time is greater than the set congestion threshold, the feature value is 1, otherwise it is 0.
[0012] In this scheme, the post-processing correction in step S4 includes shadow rule correction: If the target time falls within a pre-set period of high incidence of non-market-based administrative intervention, and the historical real price at the same time the day before the target time is greater than the set peak threshold; Then the shadow rule is triggered: ignoring the output of the machine learning model, the lower limit of the predicted price at the target time is forcibly corrected to a preset proportion of the historical true price at the same time the previous day.
[0013] A second aspect of this invention provides a power spot price forecasting system based on dynamic residuals and physical constraints, comprising a power spot price forecasting method program based on dynamic residuals and physical constraints, wherein the power spot price forecasting method program based on dynamic residuals and physical constraints, when executed by the processor, performs the following steps: Step S1: Obtain electricity market supply and demand forecast data for the target area at the target time, as well as the lagged historical data for anti-crossing; Step S2: Based on the lagging historical data, dynamically extract the market price benchmark within the sliding time window, and transform the absolute price prediction target into a price residual target based on the benchmark; Step S3: Based on the supply and demand forecast data and the lagged historical data, a two-stage machine learning model with time decay sample weights is used to predict the price residual target and obtain the prediction residual; Step S4: Extract physical constraint features that reflect extreme power grid conditions, construct early warning triggering conditions, and perform post-processing correction on the prediction residuals based on the early warning triggering conditions and historical shadow rules; Step S5: Add the corrected prediction residual to the market price benchmark to obtain the target prediction price for the target time.
[0014] A third aspect of the present invention provides a device for predicting spot electricity prices based on dynamic residuals and physical constraints, the device comprising: Data acquisition unit: used to acquire supply and demand forecast data and lagged historical data for anti-crossover; Residual transformation unit: used to dynamically extract market price benchmarks and generate price residual targets; Two-stage prediction unit: used to combine time decay weights to perform state classification and conditional regression prediction of price residual targets; Physical rule correction unit: used to correct and restore the prediction results based on discrete Boolean warning features and shadow rules, and output the final predicted price.
[0015] A fourth aspect of the present invention provides a computer-readable storage medium comprising a program for a method of predicting spot electricity prices based on dynamic residuals and physical constraints. When executed by a processor, the program implements the steps of the method of predicting spot electricity prices based on dynamic residuals and physical constraints as described in any of the preceding claims.
[0016] Compared with the prior art, the present invention has the following beneficial technical effects: (1) Propose a dynamic target residual technique: This invention breaks away from the traditional model's direct prediction of absolute electricity prices. By dynamically extracting the market floor / mode as a baseline within a sliding window, the model only predicts the deviation. This gives the model a strong adaptive capability, enabling it to avoid being bound by old data and quickly align with the latest market state when facing sudden price changes across months (such as a sudden increase from 308 yuan to 383 yuan).
[0017] (2) A unique zero-weight mask and time decay data cleaning strategy: To address the pollution caused by false anchor points due to missing data, this application adopts feature mapping with a preset number of days before the target time, combined with a masking mechanism, to effectively block the pollution of the model gradient by false labels; at the same time, through exponential time decay, the model pays more attention to recent supply and demand patterns.
[0018] (3) Using discrete Boolean features and shadow rules to solve feature poisoning: This invention strips away continuous physical variables such as reserve depletion and grid congestion and transforms them into 0 / 1 Boolean early warning switches; combined with shadow post-processing rules specifically designed to deal with the hoarding behavior of the dispatching side, it perfectly captures the extreme price spikes of the evening peak and the morning peak without compromising the accuracy of the baseline prediction, which greatly enhances the commercial and economic value of real-time trading and energy storage dispatch. Attached Figure Description
[0019] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly described below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope.
[0020] Figure 1 A flowchart of a method for predicting spot electricity prices based on dynamic residuals and physical constraints according to the present invention is shown. Figure 2 This diagram illustrates the numerical flow of residual transformation and shadow post-processing rules provided by an embodiment of the present invention. Figure 3This diagram illustrates a block diagram of an electricity spot price forecasting system based on dynamic residuals and physical constraints according to the present invention. Figure 4 A schematic diagram of a power spot price prediction device based on dynamic residuals and physical constraints according to the present invention is shown. Detailed Implementation
[0021] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0022] Unless otherwise defined, all terms (including technical and scientific terms) used in embodiments of this invention shall have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. It should also be understood that terms such as those defined in a common dictionary shall be interpreted as having a meaning consistent with their meaning in the context of the relevant art, and not as being interpreted in an idealized or highly formalized sense, unless expressly defined in this embodiment of the invention.
[0023] The terms "first," "second," and similar words used in the embodiments of this invention do not indicate any order, quantity, or importance, but are merely used to distinguish different components. Terms such as "an," "a," or "the" do not indicate a quantity limitation, but rather indicate the presence of at least one. Similarly, terms such as "including" or "comprising" mean that the element or object preceding the word encompasses the elements or objects listed after the word and their equivalents, without excluding other elements or objects. Terms such as "connected" or "linked" are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. The steps preceding or following the steps in the method of the embodiments of this invention are not necessarily performed precisely in sequence. Instead, various steps can be processed in reverse order or simultaneously. Furthermore, other operations can be added to these processes, or one or more steps can be removed from these processes.
[0024] In addition, the functional modules in the various embodiments of the present invention can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0025] Figure 1 The flowchart of a method for predicting spot electricity prices based on dynamic residuals and physical constraints according to the present invention is shown.
[0026] like Figure 1As shown, the first aspect of this invention discloses a method for predicting spot electricity prices based on dynamic residuals and physical constraints, the method comprising: Step S1: Obtain electricity market supply and demand forecast data for the target area at the target time, as well as the lagged historical data for anti-crossing; Step S2: Based on the lagging historical data, dynamically extract the market price benchmark within the sliding time window, and transform the absolute price prediction target into a price residual target based on the benchmark; Step S3: Based on the supply and demand forecast data and the lagged historical data, a two-stage machine learning model with time decay sample weights is used to predict the price residual target and obtain the prediction residual; Step S4: Extract physical constraint features that reflect extreme power grid conditions, construct early warning triggering conditions, and perform post-processing correction on the prediction residuals based on the early warning triggering conditions and historical shadow rules; Step S5: Add the corrected prediction residual to the market price benchmark to obtain the target prediction price for the target time.
[0027] It should be noted that in this embodiment, the electricity market supply and demand forecast data for the target region at the target forecast time is first acquired, including system load forecast, new energy output forecast, and tie-line plans. Simultaneously, lagged historical data with strict anti-cross-cutting measures is acquired to ensure that the time point of all historical data is no later than the current forecast benchmark time, thus preventing future information leakage. Subsequently, based on the acquired historical data, a market price benchmark is dynamically extracted within a sliding time window. Specifically, the historical true clearing price sequence for several days prior to the target time is extracted, and abnormally low-priced dirty data is removed using statistical methods. The most frequently occurring price mode is then extracted as the dynamic benchmark under the current market conditions. The traditional absolute price forecasting task is transformed into predicting the price residual target relative to this benchmark, thereby effectively addressing the jump changes in market floor prices caused by cross-month settlements or rule mutations. Based on this, a two-stage machine learning model with time-decayed sample weights is used to predict the price residual target, based on the aforementioned supply and demand forecast data and lagged historical data. The time decay weighting assigns greater weight to historical samples closer to the target time during model training. The two-stage model first classifies price states before calling the corresponding conditional regressor to output the prediction residuals. Then, physical constraint features reflecting extreme grid conditions, such as reserve capacity depletion and excessively high nodal price dispersion, are extracted. These continuous variables are transformed into discrete Boolean warning signals, and the prediction residuals output by the model are post-processed and corrected using historical shadow rules to capture extreme spikes and administrative intervention phenomena that are difficult to learn using data-driven models alone. Finally, the corrected prediction residuals are added to the previously determined dynamic market price benchmark to reconstruct the final absolute prediction price, which is then output for trading decisions.
[0028] According to an embodiment of the present invention, the method for dynamically extracting and converting the market price benchmark in step S2 includes: Extract historical real price data for a preset number of days prior to the target time; Kernel density estimation or high-precision discrete frequency statistics are performed on the historical real price data to remove dirty data below the abnormal threshold, and the most frequent price mode is extracted as the dynamic market price benchmark. The price residual target is obtained by subtracting the dynamic market price benchmark from the actual price at the target time.
[0029] It should be noted that in this embodiment, firstly, a segment of historical real price data for a preset number of days is extracted, with the target time as the endpoint. This preset number of days is set according to market volatility characteristics, such as three to five days, to ensure that the baseline reflects the recent market state without being excessively disturbed by short-term extreme values. Next, kernel density estimation is performed on the extracted historical real price data to construct a probability density distribution curve for prices, or a high-precision discrete frequency statistical method is used to count the frequency of each price value. Simultaneously, dirty data below a preset abnormal threshold, such as price points significantly below the normal market trading floor, is removed during this process. Then, the most frequently occurring price value, i.e., the price mode, is extracted from the processed distribution and determined as the dynamic market price baseline. This baseline represents the current market price bottom or the most concentrated trading area. Finally, during the model training phase, the dynamic market price baseline is subtracted from the real absolute price corresponding to the target time to calculate the price residual target, thereby transforming the regression problem of directly predicting absolute prices into a residual prediction problem of predicting relative deviations.
[0030] Figure 2 This diagram illustrates the numerical flow of residual transformation and shadow post-processing rules provided by an embodiment of the present invention. like Figure 2 As shown in the embodiment of the present invention, the prediction process of the two-stage machine learning model in step S3 includes: The first stage of classification: Historical electricity prices are divided into valley, flat and peak states according to preset intervals, and a state classifier is trained to predict the price state of the target time. Second-stage regression: For the valley, flat, and peak states, construct independent conditional regressors respectively; based on the price state predicted in the first stage, call the corresponding conditional regressors to predict the price residual target.
[0031] It should be noted that in this embodiment, the first stage is the classification stage. Based on the actual distribution range of historical electricity prices, the electricity price level is pre-divided into several discrete state intervals, specifically including the valley state representing the low electricity price area, the flat state representing the medium electricity price area, and the peak state representing the high electricity price area. A state classifier is trained using historical feature data. This classifier can determine the price state category of the target time based on the input prediction features. The output of the classifier is a probability or definite label of one of the three states: valley, flat, or peak. The second stage is the regression stage. Three independent conditional regressors are constructed for the valley, flat, and peak states, respectively. Each conditional regressor is trained using only historical samples corresponding to its state category, thereby avoiding mutual interference between different price distribution characteristics. When it is necessary to predict the target time, the state classifier trained in the first stage is first called, the current feature data is input to obtain the predicted price state, and then the corresponding conditional regressor is automatically selected and called based on the state. The output of the regressor is used as the final predicted price residual value.
[0032] According to an embodiment of the present invention, the method with time-decayed sample weights includes: Historical training samples are assigned exponentially decaying weights, with samples closer to the target time having larger weights, in order to force the model to adapt to the latest market conditions; When historical data is missing for an entire day, feature mapping is performed using data from the same period a preset number of days before the target time, and the sample weight of the interpolated date is forcibly set to 0 to block the model from learning the gradient of the interpolated pseudo-label.
[0033] It should be noted that in this embodiment, firstly, each sample in the historical training sample set is assigned a weight coefficient that decays exponentially over time. Specifically, samples closer to the target prediction time are assigned larger weights, while the weights of samples further away decrease exponentially. This weight allocation strategy allows the machine learning model to pay more attention to recent market supply and demand patterns and price behavior during training, thus enabling it to quickly adapt to dynamic changes in market conditions. Simultaneously, special handling is provided for situations where all trading sessions for a given historical date are missing: when all trading sessions for a given historical date are detected to be missing, data from the same period a fixed number of days prior to the target time (e.g., the same day last week) is used for imputation through feature mapping to maintain the continuity of temporal features. Furthermore, during training, the weights of all samples corresponding to the imputation date are forcibly set to zero, so that these imputation-generated samples are completely ignored when calculating the loss function, effectively blocking the model's gradient learning of imputation pseudo-labels and preventing pseudo-data from polluting the model parameters.
[0034] According to an embodiment of the present invention, the physical constraint features in step S4 are transformed from continuous variables into discrete Boolean warning feature inputs, and the warning features include: Positive reserve depletion warning feature: When the actual positive reserve rate is lower than the set depletion threshold at the same time the day before the target time, the feature value is 1; otherwise, it is 0. Congestion prediction warning feature: When the standard deviation of the day-ahead node electricity price at the same time on the day before the target time is greater than the set congestion threshold, the feature value is 1, otherwise it is 0.
[0035] It should be noted that in this embodiment, firstly, the actual positive reserve ratio at the same time the day before the target time is acquired in real time, and this value is compared with a pre-set depletion threshold. If the actual positive reserve ratio is lower than the depletion threshold, a positive reserve depletion warning feature is generated and its value is set to 1; otherwise, it is set to 0. This feature is used to identify whether the system has an extreme operating condition of severely insufficient reserve capacity. Simultaneously, electricity price data for each day-ahead node is collected at the same time the day before the target time, and the standard deviation of electricity prices for all nodes is calculated. The standard deviation is compared with a preset congestion threshold. If the standard deviation is greater than the congestion threshold, a congestion expectation warning feature is generated and its value is set to 1; otherwise, it is set to 0. This feature is used to identify whether there is significant price dispersion between nodes in the power grid, i.e., congestion expectation exists. After generating a summed feature matrix from the above two Boolean features and other continuous features, it is input into the machine learning model, enabling the model to accurately focus on scarce moments where physical constraint gaps truly exist during global training, avoiding the dilution of the model's attention by continuous variables throughout the entire cycle.
[0036] According to an embodiment of the present invention, the post-processing correction in step S4 includes shadow rule correction: If the target time falls within a pre-set period of high incidence of non-market-based administrative intervention, and the historical real price at the same time the day before the target time is greater than the set peak threshold; Then the shadow rule is triggered: ignoring the output of the machine learning model, the lower limit of the predicted price at the target time is forcibly corrected to a preset proportion of the historical true price at the same time the previous day.
[0037] It should be noted that in this embodiment, firstly, it is determined whether the current target time falls within a pre-defined period of high incidence of non-market-based administrative intervention; for example, during a specific period of the morning rush hour, when the government or dispatching agencies may issue price limits or supply guarantee orders. If the current time falls within this period, the historical real price at the same time the previous day is extracted and examined to determine whether the price is greater than a pre-set peak threshold. When both of the above conditions are met simultaneously, shadow rule correction is triggered. Ignoring the predicted price of the machine learning model, the lower limit of the predicted price is forcibly corrected. Specifically, the lower limit of the predicted price is adjusted to a preset proportion of the historical real price at the same time the previous day, thereby ensuring that during periods of frequent administrative intervention, the predicted price will not underestimate the support effect of policy-driven high prices due to the model's reliance on conventional supply and demand characteristics.
[0038] It is worth mentioning that the method for dynamically extracting the market price benchmark in step S2 also includes: The timeline of a day is divided into multiple sub-periods, including the morning peak climbing period, the midday valley period, and the evening peak period. For each sub-period, historical real price data for a preset number of days prior to the target time is extracted independently, and the local price mode corresponding to each sub-period is extracted as the dynamic market price benchmark for each sub-period. When the target prediction time spans adjacent sub-periods, a baseline at the time-period boundary is used for smooth transition processing to obtain a continuous market price baseline.
[0039] It should be noted that in this embodiment, the complete daily timeline is first divided into multiple sub-periods according to the typical fluctuation patterns of the electricity market. Specifically, these include the morning peak climbing period reflecting the rapid increase in load in the early morning, the midday valley period reflecting stable daytime electricity consumption, and the evening peak period reflecting the surge in evening electricity consumption. For each sub-period, historical real price data for a preset number of days prior to the target time is independently extracted. Kernel density estimation or frequency statistics are performed on the price data within each sub-period. After removing abnormal and dirty data, the local price mode corresponding to each sub-period is extracted as the dynamic market price benchmark for the sub-period. When the target prediction time crosses the boundary between two adjacent sub-periods, for example, from the midday valley period to the evening peak period, a baseline smoothing transition mechanism is adopted. Using the benchmarks of the two adjacent periods as endpoints, a gradual fusion is performed within a preset time period before and after the period switching point, thereby obtaining a continuous and smooth all-weather dynamic market price benchmark.
[0040] It is worth mentioning that the two-stage machine learning model operation process in step S3 further includes: After the prediction is executed, the deviation between the predicted state of the state classifier and the subsequently obtained real price state is monitored in real time. When the cumulative deviation of multiple consecutive target times exceeds the preset tolerance threshold, the adaptive incremental update of the model is triggered. The incremental update process is as follows: the bottom feature extraction layer of the frozen state classifier is fine-tuned based on the weighted samples within the most recent preset number of days; if it is a misjudged state, the corresponding conditional regressor is locally retrained based on the latest residual samples in the misjudged state, while the conditional regressors in other states remain unchanged.
[0041] It should be noted that in this embodiment, after each prediction execution, subsequent real price data for the target time is continuously acquired. The real price state is compared with the predicted state output by the first-stage state classifier of the model, and the deviation between the two is calculated. When the cumulative deviation of multiple consecutive target times exceeds a preset tolerance threshold, it is determined that the current model can no longer accurately capture changes in market state, thereby triggering an adaptive incremental update process. During the incremental update process, the network layer responsible for low-level feature extraction in the state classifier is first frozen, keeping its original parameters unchanged. Only samples that have undergone time decay weighting within the most recent preset number of days are used to fine-tune the top-level decision layer of the classifier. At the same time, the specific price state that has been misjudged is identified, and only the conditional regressor corresponding to the misjudged state is locally retrained using the latest residual samples of the misjudged state, while the conditional regressors corresponding to other states that have not been misjudged remain unchanged, thereby quickly restoring the model's prediction accuracy while minimizing computational overhead.
[0042] It is worth mentioning that the physical constraint features in step S4 also include: Extract early warning signals for power shortage, such as power reserve depletion, expected blockage, and sudden drop in new energy output, and generate composite early warning features for power shortage. The power flow over-limit warning signal and the unit minimum start-up and shutdown time constraint warning signal are logically ORed to generate the power grid emergency condition characteristics. The composite early warning features and emergency condition features are added as discrete input variables and input together with the Boolean early warning signal into the post-processing correction module to trigger a higher priority shadow correction rule.
[0043] It should be noted that in this embodiment, the following steps are taken: First, the reserve depletion warning signal, the congestion expectation warning signal, and the new energy output plunge warning signal are extracted, and then a logical AND operation is performed on these three signals. That is, a power shortage composite warning feature is generated only when all three conditions are met simultaneously. This feature indicates that the system is facing a severe power shortage composite condition, with insufficient reserves, transmission congestion, and a precipitous drop in new energy output. Simultaneously, the line power flow exceeding limit warning signal and the unit minimum start-up and shutdown time constraint warning signal are performed a logical OR operation. That is, when either of the above two conditions is met, a grid emergency condition feature is generated. This feature indicates that the grid has entered a physical limit operating state. The above composite warning feature and emergency condition feature are used as new discrete input variables, and together with the original Boolean warning signals, are sent to the post-processing correction module. The above features are then used to trigger a preset, more stringent shadow correction rule, such as forcibly raising the predicted price to a historical extreme level.
[0044] Figure 3 The diagram shows a block diagram of a spot electricity price prediction system based on dynamic residuals and physical constraints according to the present invention.
[0045] like Figure 3 As shown, the second aspect of the present invention discloses a power spot price prediction system 3 based on dynamic residuals and physical constraints, including a memory 31 and a processor 32. The memory includes a program for predicting power spot prices based on dynamic residuals and physical constraints. When the program for predicting power spot prices based on dynamic residuals and physical constraints is executed by the processor, it performs the following steps: Step S1: Obtain electricity market supply and demand forecast data for the target area at the target time, as well as the lagged historical data for anti-crossing; Step S2: Based on the lagging historical data, dynamically extract the market price benchmark within the sliding time window, and transform the absolute price prediction target into a price residual target based on the benchmark; Step S3: Based on the supply and demand forecast data and the lagged historical data, a two-stage machine learning model with time decay sample weights is used to predict the price residual target and obtain the prediction residual; Step S4: Extract physical constraint features that reflect extreme power grid conditions, construct early warning triggering conditions, and perform post-processing correction on the prediction residuals based on the early warning triggering conditions and historical shadow rules; Step S5: Add the corrected prediction residual to the market price benchmark to obtain the target prediction price for the target time.
[0046] It should be noted that in this embodiment, the electricity market supply and demand forecast data for the target region at the target forecast time is first acquired, including system load forecast, new energy output forecast, and tie-line plans. Simultaneously, lagged historical data with strict anti-cross-cutting measures is acquired to ensure that the time point of all historical data is no later than the current forecast benchmark time, thus preventing future information leakage. Subsequently, based on the acquired historical data, a market price benchmark is dynamically extracted within a sliding time window. Specifically, the historical true clearing price sequence for several days prior to the target time is extracted, and abnormally low-priced dirty data is removed using statistical methods. The most frequently occurring price mode is then extracted as the dynamic benchmark under the current market conditions. The traditional absolute price forecasting task is transformed into predicting the price residual target relative to this benchmark, thereby effectively addressing the jump changes in market floor prices caused by cross-month settlements or rule mutations. Based on this, a two-stage machine learning model with time-decayed sample weights is used to predict the price residual target, based on the aforementioned supply and demand forecast data and lagged historical data. The time decay weighting assigns greater weight to historical samples closer to the target time during model training. The two-stage model first classifies price states before calling the corresponding conditional regressor to output the prediction residuals. Then, physical constraint features reflecting extreme grid conditions, such as reserve capacity depletion and excessively high nodal price dispersion, are extracted. These continuous variables are transformed into discrete Boolean warning signals, and the prediction residuals output by the model are post-processed and corrected using historical shadow rules to capture extreme spikes and administrative intervention phenomena that are difficult to learn using data-driven models alone. Finally, the corrected prediction residuals are added to the previously determined dynamic market price benchmark to reconstruct the final absolute prediction price, which is then output for trading decisions.
[0047] According to an embodiment of the present invention, the method for dynamically extracting and converting the market price benchmark in step S2 includes: Extract historical real price data for a preset number of days prior to the target time; Kernel density estimation or high-precision discrete frequency statistics are performed on the historical real price data to remove dirty data below the abnormal threshold, and the most frequent price mode is extracted as the dynamic market price benchmark. The price residual target is obtained by subtracting the dynamic market price benchmark from the actual price at the target time.
[0048] It should be noted that in this embodiment, firstly, a segment of historical real price data for a preset number of days is extracted, with the target time as the endpoint. This preset number of days is set according to market volatility characteristics, such as three to five days, to ensure that the baseline reflects the recent market state without being excessively disturbed by short-term extreme values. Next, kernel density estimation is performed on the extracted historical real price data to construct a probability density distribution curve for prices, or a high-precision discrete frequency statistical method is used to count the frequency of each price value. Simultaneously, dirty data below a preset abnormal threshold, such as price points significantly below the normal market trading floor, is removed during this process. Then, the most frequently occurring price value, i.e., the price mode, is extracted from the processed distribution and determined as the dynamic market price baseline. This baseline represents the current market price bottom or the most concentrated trading area. Finally, during the model training phase, the dynamic market price baseline is subtracted from the real absolute price corresponding to the target time to calculate the price residual target, thereby transforming the regression problem of directly predicting absolute prices into a residual prediction problem of predicting relative deviations.
[0049] According to an embodiment of the present invention, the prediction process of the two-stage machine learning model in step S3 includes: The first stage of classification: Historical electricity prices are divided into valley, flat and peak states according to preset intervals, and a state classifier is trained to predict the price state of the target time. Second-stage regression: For the valley, flat, and peak states, construct independent conditional regressors respectively; based on the price state predicted in the first stage, call the corresponding conditional regressors to predict the price residual target.
[0050] It should be noted that in this embodiment, the first stage is the classification stage. Based on the actual distribution range of historical electricity prices, the electricity price level is pre-divided into several discrete state intervals, specifically including the valley state representing the low electricity price area, the flat state representing the medium electricity price area, and the peak state representing the high electricity price area. A state classifier is trained using historical feature data. This classifier can determine the price state category of the target time based on the input prediction features. The output of the classifier is a probability or definite label of one of the three states: valley, flat, or peak. The second stage is the regression stage. Three independent conditional regressors are constructed for the valley, flat, and peak states, respectively. Each conditional regressor is trained using only historical samples corresponding to its state category, thereby avoiding mutual interference between different price distribution characteristics. When it is necessary to predict the target time, the state classifier trained in the first stage is first called, the current feature data is input to obtain the predicted price state, and then the corresponding conditional regressor is automatically selected and called based on the state. The output of the regressor is used as the final predicted price residual value.
[0051] According to an embodiment of the present invention, the method with time-decayed sample weights includes: Historical training samples are assigned exponentially decaying weights, with samples closer to the target time having larger weights, in order to force the model to adapt to the latest market conditions; When historical data is missing for an entire day, feature mapping is performed using data from the same period a preset number of days before the target time, and the sample weight of the interpolated date is forcibly set to 0 to block the model from learning the gradient of the interpolated pseudo-label.
[0052] It should be noted that in this embodiment, firstly, each sample in the historical training sample set is assigned a weight coefficient that decays exponentially over time. Specifically, samples closer to the target prediction time are assigned larger weights, while the weights of samples farther away decrease exponentially. This weight allocation strategy allows the machine learning model to pay more attention to recent market supply and demand patterns and price behavior during training, thus enabling it to quickly adapt to dynamic changes in market conditions. Simultaneously, special handling is provided for situations where all trading sessions for a given historical date are missing: when all trading sessions for a given historical date are detected to be missing, data from the same period last week (e.g., the same day) before the target time is used for imputation through feature mapping to maintain the continuity of temporal features. Furthermore, during training, the weights of all samples corresponding to the imputation date are forcibly set to zero, so that these imputation samples are completely ignored when calculating the loss function, effectively preventing the model from learning gradients from imputation pseudo-labels and avoiding pseudo-data contamination of model parameters.
[0053] According to an embodiment of the present invention, the physical constraint features in step S4 are transformed from continuous variables into discrete Boolean warning feature inputs, and the warning features include: Positive reserve depletion warning feature: When the actual positive reserve rate is lower than the set depletion threshold at the same time the day before the target time, the feature value is 1; otherwise, it is 0. Congestion prediction warning feature: When the standard deviation of the day-ahead node electricity price at the same time on the day before the target time is greater than the set congestion threshold, the feature value is 1, otherwise it is 0.
[0054] It should be noted that in this embodiment, firstly, the actual positive reserve ratio at the same time the day before the target time is acquired in real time, and this value is compared with a pre-set depletion threshold. If the actual positive reserve ratio is lower than the depletion threshold, a positive reserve depletion warning feature is generated and its value is set to 1; otherwise, it is set to 0. This feature is used to identify whether the system has an extreme operating condition of severely insufficient reserve capacity. Simultaneously, electricity price data for each day-ahead node at the same time the day before the target time is collected, and the standard deviation of electricity prices for all nodes is calculated. The standard deviation is compared with a preset congestion threshold. If the standard deviation is greater than the congestion threshold, a congestion expectation warning feature is generated and its value is set to 1; otherwise, it is set to 0. This feature is used to identify whether there is significant price dispersion between nodes in the power grid, i.e., congestion expectation. After generating a summed feature matrix from the above two Boolean features and other continuous features, it is input into the machine learning model, enabling the model to accurately focus on scarce moments where physical constraint gaps truly exist during global training, avoiding the dilution of the model's attention by continuous variables throughout the entire cycle.
[0055] According to an embodiment of the present invention, the post-processing correction in step S4 includes shadow rule correction: If the target time falls within a pre-set period of high incidence of non-market-based administrative intervention, and the historical real price at the same time the day before the target time is greater than the set peak threshold; Then the shadow rule is triggered: ignoring the output of the machine learning model, the lower limit of the predicted price at the target time is forcibly corrected to a preset proportion of the historical true price at the same time the previous day.
[0056] It should be noted that in this embodiment, firstly, it is determined whether the current target time falls within a pre-defined period of high incidence of non-market-based administrative intervention; for example, during a specific period of the morning rush hour, when the government or dispatching agencies may issue price limits or supply guarantee orders. If the current time falls within this period, the historical real price at the same time the previous day is extracted and examined to determine whether the price is greater than a pre-set peak threshold. When both of the above conditions are met simultaneously, shadow rule correction is triggered. Ignoring the predicted price of the machine learning model, the lower limit of the predicted price is forcibly corrected. Specifically, the lower limit of the predicted price is adjusted to a preset proportion of the historical real price at the same time the previous day, thereby ensuring that during periods of frequent administrative intervention, the predicted price will not underestimate the support effect of policy-driven high prices due to the model's reliance on conventional supply and demand characteristics.
[0057] It is worth mentioning that the method for dynamically extracting the market price benchmark in step S2 also includes: The timeline of a day is divided into multiple sub-periods, including the morning peak climbing period, the midday valley period, and the evening peak period. For each sub-period, historical real price data for a preset number of days prior to the target time is extracted independently, and the local price mode corresponding to each sub-period is extracted as the dynamic market price benchmark for each sub-period. When the target prediction time spans adjacent sub-periods, a baseline at the time-period boundary is used for smooth transition processing to obtain a continuous market price baseline.
[0058] It should be noted that in this embodiment, the complete daily timeline is first divided into multiple sub-periods according to the typical fluctuation patterns of the electricity market. Specifically, these include the morning peak climbing period reflecting the rapid increase in load in the early morning, the midday valley period reflecting stable daytime electricity consumption, and the evening peak period reflecting the surge in evening electricity consumption. For each sub-period, historical real price data for a preset number of days prior to the target time is independently extracted. Kernel density estimation or frequency statistics are performed on the price data within each sub-period. After removing abnormal and dirty data, the local price mode corresponding to each sub-period is extracted as the dynamic market price benchmark for the sub-period. When the target prediction time crosses the boundary between two adjacent sub-periods, for example, from the midday valley period to the evening peak period, a baseline smoothing transition mechanism is adopted. Using the benchmarks of the two adjacent periods as endpoints, a gradual fusion is performed within a preset time period before and after the period switching point, thereby obtaining a continuous and smooth all-weather dynamic market price benchmark.
[0059] It is worth mentioning that the two-stage machine learning model operation process in step S3 further includes: After the prediction is executed, the deviation between the predicted state of the state classifier and the subsequently obtained real price state is monitored in real time. When the cumulative deviation of multiple consecutive target times exceeds the preset tolerance threshold, the adaptive incremental update of the model is triggered. The incremental update process is as follows: the bottom feature extraction layer of the frozen state classifier is fine-tuned based on the weighted samples within the most recent preset number of days; if it is a misjudged state, the corresponding conditional regressor is locally retrained based on the latest residual samples in the misjudged state, while the conditional regressors in other states remain unchanged.
[0060] It should be noted that in this embodiment, after each prediction execution, subsequent real price data for the target time is continuously acquired. The real price state is compared with the predicted state output by the first-stage state classifier of the model, and the deviation between the two is calculated. When the cumulative deviation of multiple consecutive target times exceeds a preset tolerance threshold, it is determined that the current model can no longer accurately capture changes in market state, thereby triggering an adaptive incremental update process. During the incremental update process, the network layer responsible for low-level feature extraction in the state classifier is first frozen, keeping its original parameters unchanged. Only samples that have undergone time decay weighting within the most recent preset number of days are used to fine-tune the top-level decision layer of the classifier. At the same time, the specific price state that has been misjudged is identified, and only the conditional regressor corresponding to the misjudged state is locally retrained using the latest residual samples of the misjudged state, while the conditional regressors corresponding to other states that have not been misjudged remain unchanged, thereby quickly restoring the model's prediction accuracy while minimizing computational overhead.
[0061] It is worth mentioning that the physical constraint features in step S4 also include: Extract early warning signals for power shortage, such as power reserve depletion, expected blockage, and sudden drop in new energy output, and generate composite early warning features for power shortage. The power flow over-limit warning signal and the unit minimum start-up and shutdown time constraint warning signal are logically ORed to generate the power grid emergency condition characteristics. The composite early warning features and emergency condition features are added as discrete input variables and input together with the Boolean early warning signal into the post-processing correction module to trigger a higher priority shadow correction rule.
[0062] It should be noted that in this embodiment, the following steps are taken: First, the reserve depletion warning signal, the congestion expectation warning signal, and the new energy output plunge warning signal are extracted, and then a logical AND operation is performed on these three signals. That is, a power shortage composite warning feature is generated only when all three conditions are met simultaneously. This feature indicates that the system is facing a severe power shortage composite condition, with insufficient reserves, transmission congestion, and a precipitous drop in new energy output. Simultaneously, the line power flow exceeding limit warning signal and the unit minimum start-up and shutdown time constraint warning signal are performed a logical OR operation. That is, when either of the above two conditions is met, a grid emergency condition feature is generated. This feature indicates that the grid has entered a physical limit operating state. The above composite warning feature and emergency condition feature are used as new discrete input variables, and together with the original Boolean warning signals, are sent to the post-processing correction module. The above features are then used to trigger a preset, more stringent shadow correction rule, such as forcibly raising the predicted price to a historical extreme level.
[0063] Figure 4 A schematic diagram of a power spot price prediction device based on dynamic residuals and physical constraints according to the present invention is shown.
[0064] like Figure 4 As shown, a third aspect of the present invention discloses a device for predicting spot electricity prices based on dynamic residuals and physical constraints, the device comprising: Data acquisition unit: used to acquire supply and demand forecast data and lagged historical data for anti-crossover; Residual transformation unit: used to dynamically extract market price benchmarks and generate price residual targets; Two-stage prediction unit: used to combine time decay weights to perform state classification and conditional regression prediction of price residual targets; Physical rule correction unit: used to correct and restore the prediction results based on discrete Boolean warning features and shadow rules, and output the final predicted price.
[0065] It should be noted that: The data acquisition unit uses the target forecast time as a benchmark and accesses real-time power market supply and demand forecast data for the target area from external data sources, including system load forecast, renewable energy output forecast, and tie-line plans. At the same time, it strictly filters and extracts lagging historical data whose timestamps are all earlier than the current forecast time, including historical clearing prices, reserve capacity records, and nodal price sequences, to ensure that the time order of the data is compliant and to avoid future information leakage. The residual conversion unit receives historical data output by the data acquisition unit and dynamically extracts the market price benchmark within the sliding time window. Specifically, it extracts the historical real price sequence from several days before the target time, removes abnormal dirty data through kernel density estimation, extracts the price mode as the benchmark, and transforms the absolute price prediction target into a price residual target relative to the benchmark, thereby giving the device the ability to adapt to sudden changes in market rules. The two-stage prediction unit, based on supply and demand forecast data and lagged historical data, uses a two-stage machine learning model with time-decayed sample weights to predict the price residual target: the first stage uses a state classifier to determine whether the target time belongs to a valley, flat, or peak state; the second stage calls the conditional regressor corresponding to the predicted state to output the specific predicted residual value; thereby preventing pseudo-labels from contaminating the model gradient. The physical rule correction unit extracts continuous physical constraint variables reflecting extreme power grid conditions, transforms them into discrete Boolean early warning features such as reserve depletion early warning and congestion expectation early warning, and combines them with historical shadow rules to perform post-processing correction on the prediction residuals output by the two-stage prediction unit. After correction, the corrected residuals are added to the dynamic market price benchmark determined by the residual conversion unit to restore the final absolute prediction price and output it, which is used for the bidding decisions of power market trading entities and the optimization of energy storage charging and discharging strategies.
[0066] A fourth aspect of the present invention provides a computer-readable storage medium comprising a program for a method of predicting spot electricity prices based on dynamic residuals and physical constraints. When executed by a processor, the program implements the steps of the method of predicting spot electricity prices based on dynamic residuals and physical constraints as described in any of the preceding claims.
[0067] In summary, this invention provides a method, system, device, and storage medium for predicting electricity spot prices based on dynamic residuals and physical constraints. This effectively addresses the problems of price prediction variance collapse and missed peaks caused by sudden rule changes and extreme physical constraints in the spot market. The prediction process includes: acquiring electricity market supply and demand and day-ahead test data for the target region at the target time; dynamically extracting the recent market price benchmark from the time series, transforming the absolute price prediction target into a residual prediction target based on the benchmark; using a multi-stage machine learning model, combined with exponentially time-decaying sample weights, classifying and conditionally regressing the residual prediction target; performing post-processing correction on the prediction results according to the set Boolean warning signal for power grid physical constraints and shadow processing rules; and finally restoring and obtaining the predicted price for the target date. This method is suitable for electricity spot trading price prediction scenarios with frequent rule changes and nonlinear peaks.
[0068] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0069] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for forecasting spot electricity prices based on dynamic residuals and physical constraints, characterized in that, The method includes: Step S1: Obtain electricity market supply and demand forecast data for the target area at the target time, as well as the lagged historical data for anti-crossing; Step S2: Based on the lagging historical data, dynamically extract the market price benchmark within the sliding time window, and transform the absolute price prediction target into a price residual target based on the benchmark; Step S3: Based on the supply and demand forecast data and the lagged historical data, a two-stage machine learning model with time decay sample weights is used to predict the price residual target and obtain the prediction residual; Step S4: Extract physical constraint features that reflect extreme power grid conditions, construct early warning triggering conditions, and perform post-processing correction on the prediction residuals based on the early warning triggering conditions and historical shadow rules; Step S5: Add the corrected prediction residual to the market price benchmark to obtain the target prediction price for the target time.
2. The method according to claim 1, wherein, The method for dynamically extracting and converting the market price benchmark in step S2 includes: Extract historical real price data for a preset number of days prior to the target time; Kernel density estimation or high-precision discrete frequency statistics are performed on the historical real price data to remove dirty data below the abnormal threshold, and the most frequent price mode is extracted as the dynamic market price benchmark. The price residual target is obtained by subtracting the dynamic market price benchmark from the actual price at the target time.
3. The method according to claim 1, wherein, The prediction process of the two-stage machine learning model in step S3 includes: The first stage of classification: Historical electricity prices are divided into valley, flat and peak states according to preset intervals, and a state classifier is trained to predict the price state of the target time. Second-stage regression: For the valley, flat, and peak states, construct independent conditional regressors respectively; based on the price state predicted in the first stage, call the corresponding conditional regressors to predict the price residual target.
4. The method according to claim 1, wherein, The method with time-decayed sample weights includes: Historical training samples are assigned exponentially decaying weights, with samples closer to the target time having larger weights, in order to force the model to adapt to the latest market conditions; When historical data is missing for an entire day, feature mapping is performed using data from the same period a preset number of days before the target time, and the sample weight of the interpolated date is forcibly set to 0 to block the model from learning the gradient of the interpolated pseudo-label.
5. The method according to claim 1, wherein, In step S4, the physical constraint features are transformed from continuous variables into discrete Boolean warning feature inputs, and the warning features include: Positive reserve depletion warning feature: When the actual positive reserve rate is lower than the set depletion threshold at the same time the day before the target time, the feature value is 1; otherwise, it is 0. Congestion prediction warning feature: When the standard deviation of the day-ahead node electricity price at the same time on the day before the target time is greater than the set congestion threshold, the feature value is 1, otherwise it is 0.
6. The method according to claim 1 or 5, wherein, The post-processing correction in step S4 includes shadow rule correction: If the target time falls within a pre-set period of high incidence of non-market-based administrative intervention, and the historical real price at the same time the day before the target time is greater than the set peak threshold; Then the shadow rule is triggered: ignoring the output of the machine learning model, the lower limit of the predicted price at the target time is forcibly corrected to a preset proportion of the historical true price at the same time the previous day.
7. A dynamic residual and physical constraints based power spot price forecasting system, characterized in that, The system includes a memory and a processor. The memory includes a program for predicting electricity spot prices based on dynamic residuals and physical constraints. When the processor executes the program for predicting electricity spot prices based on dynamic residuals and physical constraints, it performs the following steps: Step S1: Obtain electricity market supply and demand forecast data for the target area at the target time, as well as the lagged historical data for anti-crossing; Step S2: Based on the lagging historical data, dynamically extract the market price benchmark within the sliding time window, and transform the absolute price prediction target into a price residual target based on the benchmark; Step S3: Based on the supply and demand forecast data and the lagged historical data, a two-stage machine learning model with time decay sample weights is used to predict the price residual target and obtain the prediction residual; Step S4: Extract physical constraint features that reflect extreme power grid conditions, construct early warning triggering conditions, and perform post-processing correction on the prediction residuals based on the early warning triggering conditions and historical shadow rules; Step S5: Add the corrected prediction residual to the market price benchmark to obtain the target prediction price for the target time.
8. A low power positioning system according to claim 7, wherein, The method for dynamically extracting and converting the market price benchmark in step S2 includes: Extract historical real price data for a preset number of days prior to the target time; Kernel density estimation or high-precision discrete frequency statistics are performed on the historical real price data to remove dirty data below the abnormal threshold, and the most frequent price mode is extracted as the dynamic market price benchmark. The price residual target is obtained by subtracting the dynamic market price benchmark from the actual price at the target time.
9. A device for predicting spot power prices based on dynamic residuals and physical constraints, characterized by, The device includes: Data acquisition unit: used to acquire supply and demand forecast data and lagged historical data for anti-crossover; Residual transformation unit: used to dynamically extract market price benchmarks and generate price residual targets; Two-stage prediction unit: used to combine time decay weights to perform state classification and conditional regression prediction of price residual targets; Physical rule correction unit: used to correct and restore the prediction results based on discrete Boolean warning features and shadow rules, and output the final predicted price.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, The computer-readable storage medium includes a program for predicting electricity spot prices based on dynamic residuals and physical constraints. When the program is executed by a processor, it implements the steps of the electricity spot price prediction method based on dynamic residuals and physical constraints as described in any one of claims 1 to 6.