Electric power spot market price prediction and transaction optimization method
By combining a hybrid neural network architecture of LSTM and ARIMA models, the method for predicting and trading electricity spot market prices is optimized. This solves the adaptability problem of traditional models in the face of sudden events and complex nonlinear dynamics, achieving higher prediction accuracy and dynamic adjustment of trading strategies, thereby improving the returns and risk management capabilities of market participants.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-19
- Publication Date
- 2026-03-10
AI Technical Summary
Existing methods for predicting and trading electricity spot market prices are poorly adapted to sudden events and complex nonlinear dynamics. Traditional models struggle to capture nonlinear characteristics and long-term time dependencies, leading to decreased prediction performance and an inability to quickly adjust prediction logic.
We employ a hybrid neural network architecture combining Long Short-Term Memory (LSTM) and Autoregressive Integral Moving Average (ARIMA) models, along with an attention mechanism. Through multi-source data processing and feature engineering, we optimize the prediction model, integrate risk constraints and market state detection, and use the NSGA-II multi-objective evolutionary algorithm to optimize trading parameters, thereby constructing a multi-level risk control system.
It significantly improves the robustness and prediction accuracy of price forecasting models in the face of market complexity and sudden events, enabling them to keenly identify price trends at critical moments, achieve dynamic adjustment of trading strategies and risk management, and improve the returns and stability of market participants.
Smart Images

Figure CN121638538A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of electricity market trading technology, and in particular to a method for predicting and optimizing electricity spot market prices. Background Technology
[0002] With the deepening of electricity market reform, the electricity spot market has become an important part of electricity trading. In the spot market, accurate prediction of electricity prices and the formulation of reasonable trading strategies are crucial for market participants.
[0003] The shortcomings of existing electricity spot market price forecasting and trading methods lie in the fact that price forecasting models are generally poorly adapted to sudden events and complex nonlinear dynamics in the market. Traditional models mainly rely on single linear statistical methods or basic machine learning algorithms, which are less effective when dealing with stable or regular market data. Once they encounter violent market fluctuations caused by events such as extreme weather, equipment failure, or a sharp reversal in supply and demand, their predictive performance will drop significantly. Existing models are unable to effectively capture and learn the nonlinear characteristics and long-term time dependencies in historical data. They often treat the price series as a relatively stable process, ignoring the possibility of non-stationarity and structural changes. When the market state changes abruptly, such models cannot quickly adjust their internal prediction logic.
[0004] To address the aforementioned issues, this solution significantly improves the robustness and prediction accuracy of price forecasting models in the face of market complexity and unexpected events. The Long Short-Term Memory (LSTM) network component, with its gating mechanism, effectively captures and memorizes nonlinear dependencies from historical price sequences and related multi-dimensional features, enabling the model to understand more abstract market dynamics. The Autoregressive Integral Moving Average (AIMA) model component captures the inherent linear trends and short-term patterns in time series. By setting an attention mechanism, the model can dynamically assign different weights to input information from different time steps in the past for each prediction, thus enabling it to more keenly identify key moments that are more indicative of future price trends, rather than treating all historical information equally. This allows the overall model to not only adapt to regular market fluctuations but also respond more sensitively and accurately to unconventional and drastic price changes. Summary of the Invention
[0005] To overcome the shortcomings of existing electricity spot market price forecasting and trading methods, which are generally poorly adapted to sudden events and complex nonlinear dynamics in the market, traditional models mainly rely on single linear statistical methods or basic machine learning algorithms. They perform poorly when dealing with stable or regular market data. Once they encounter violent market fluctuations caused by events such as extreme weather, equipment failure, or a sharp reversal in supply and demand, their predictive performance will drop significantly. Existing models are unable to effectively capture and learn the nonlinear characteristics and long-term time dependencies in historical data. They often treat the price series as a relatively stable process and ignore the possibility of non-stationarity and structural changes. When the market state changes abruptly, such models cannot quickly adjust their internal predictive logic.
[0006] The technical solution of this invention is: a method for predicting and optimizing electricity spot market prices, comprising the following steps: S11: Integrate multi-source electricity market data and perform systematic cleaning, alignment, and enhancement to construct a standardized time-series dataset; S12: A multi-dimensional feature space is constructed through technical indicator extraction, temporal coding, and dimensionality reduction to optimize the input quality of the prediction model; S13: Design a hybrid neural network architecture that integrates LSTM and ARIMA, and incorporate an attention mechanism to handle multivariate time series prediction; S14: Optimize hyperparameters using cross-validation and early stopping strategies; S15: Establish a multi-dimensional trading rule system based on predictive signals, integrating risk constraints and market state detection mechanisms; S16: The NSGA-II multi-objective evolutionary algorithm is used to solve the Pareto front of the trading parameters to achieve the optimal balance between risk and return; S17: Deploy streaming data processing pipelines and model services, and establish dynamic parameter adjustment and anomaly early warning mechanisms; S18: Construct a multi-layered risk prevention and control system through VaR calculation, stress testing, and hedging strategies; S19: Analyze the effectiveness of strategies based on comprehensive indicators and continuously optimize the model architecture and workflow components.
[0007] Preferably, the data collection and preprocessing process includes the following steps: S21: Download historical spot price data from the API interface of the electricity market operator. The data granularity includes hourly and 15-minute intervals, covering a time range of at least five years, including weekdays, weekends, and holidays. Use Python's requests library to write an automated script to regularly update the data and store it in a MySQL database. S22: Integrate external data sources, including obtaining weather data from the NOAA API, extracting power generation data from power plant reports, obtaining load data from grid operators, downloading fuel prices from the Energy Information Administration, and integrating public calendar holiday information; S23: Clean the data for missing values. Use pandas library functions to identify missing points. For consecutive missing values, use forward imputation. For random missing values, apply linear interpolation. At the same time, detect outliers based on the 3σ principle. Replace data points that exceed three standard deviations with the moving average of adjacent time points. S24: Standardized numerical features are scaled to the 0-1 range using Min-Max standardization, implemented using Scikit-learn's MinMaxScaler. Categorical features are one-hot encoded and converted into binary vectors. S25: Align the time series data, use pandas' resample function to resample all data to a uniform hourly frequency, use forward padding to handle missing data for weather data, and apply linear interpolation to price data; S26: Divide the dataset into training, validation, and test sets, and split them in chronological order. Use the first 70% of the data as the training set, the middle 15% as the validation set, and the last 15% as the test set. Use time-series splitting to prevent data leakage. S27: Perform data augmentation by adding Gaussian noise to the price data, with the noise standard deviation set to 5% of the price standard deviation, generating additional training samples, and applying a time window sliding technique to create multiple 24-hour subsequences.
[0008] Preferably, feature engineering includes the following steps: S31: Calculate price technical indicators, including 5-day, 10-day, and 20-day moving averages, using pandas' rolling function. Calculate the 14-day Relative Strength Index (RSI) and construct Bollinger Bands based on the 20-day moving average and twice the standard deviation. S32: Extract time-related features, parse the hour, day, month, quarter, and whether it is a weekend from the timestamp, and apply sine and cosine coding to process periodic features; S33: Create lag features to generate lagged variables for price data, with lag times ranging from 1 hour to 24 hours. Simultaneously, calculate first and second-order differences to handle non-stationarity and capture price change trends. S34: Construct interactive features by multiplying weather data and price data, using the product of temperature and price as a new feature, and calculating the ratio of load to power generation; S35: Principal component analysis (PCA) is applied for dimensionality reduction. For high-dimensional weather variables, the PCA algorithm is used to retain 95% of the variance components, reducing the number of features. PCA is then used in Scikit-learn for transformation. S36: Select important features, train the random forest model to calculate feature importance on the training set, select the top 20 key features, and adjust the selection threshold based on the performance on the validation set; S37: To handle multicollinearity, calculate the Pearson correlation coefficient matrix between features, remove features with a correlation coefficient greater than 0.9, and use variance inflation factor (VIF) detection to ensure that the VIF value is below 10.
[0009] Preferably, the following steps are included when constructing a price prediction model: S41: Design a hybrid model architecture that combines an LSTM neural network and an ARIMA time series model. The LSTM layer handles long-term dependencies, while the ARIMA model captures short-term linear trends, outputting a price prediction sequence for the next 24 hours. S42: Configure the LSTM network parameters, set two LSTM layers with 50 neurons per layer, use the tanh activation function, add a Dropout layer with a dropout rate of 0.2, and use a linear activation function for the output layer; S43: Integrating the ARIMA model, fitting the ARIMA(p,d,q) model to historical price data, selecting the p, d, and q parameters through an automatic order determination method, minimizing it using the AIC criterion, and passing the ARIMA residuals as input features to the LSTM; S44: Add an attention mechanism by introducing an attention layer after the LSTM layer. Calculate the attention weights of the hidden states, sum them by weight, and output the result, allowing the model to focus on key time steps. S45: Handles multivariate inputs by using feature-engineered data as input, with the input dimension equal to the number of features and a fixed time step of 24 hours; S46: Define the loss function, using the mean squared error (MSE) as the main loss, add an L2 regularization term with a coefficient of 0.01, and compile the model using the TensorFlow framework; S47: Initialize model weights. Set the weights for the LSTM layer using the He initialization method. Initialize the biases to zero. Initialize the ARIMA model parameters using maximum likelihood estimation.
[0010] Preferably, the model training and validation process includes the following steps: S51: Set training hyperparameters, select the Adam optimizer, set the learning rate to 0.001, batch size to 32, number of training epochs to 100, apply the early stopping strategy, and set the patience parameter to 10; S52: Perform the model training process, iteratively train the hybrid model on the training set, calculate the training loss after each epoch, monitor the performance using the validation set, and save the model weights with the minimum validation loss; S53: Apply time series cross-validation, divide the data into 5 folds, with each fold serving as the validation set, and calculate the average validation error; S54: Adjust model parameters, optimize the number of LSTM layers or neurons based on validation set results, and use grid search to fine-tune the p, d, and q parameters of ARIMA, with a search range of p[1,5], d[0,2], and q[1,5]. S55: To address overfitting, if the validation loss increases, increase the Dropout rate to 0.3 or add L1 regularization, and retrain the model using the augmented data. S56: Evaluate model performance by calculating the mean absolute error (MAE), root mean square error (RMSE), and mean absolute percentage error (MAPE) on the test set, and compare the distribution of predicted and actual values. S57: Perform model interpretability analysis, use the SHAP library to calculate feature contribution values, visualize the impact of key features, and analyze attention weights to identify important time points.
[0011] Preferably, the following steps are included when designing a trading strategy: S61: Define the trading objective, with maximizing cumulative profit as the primary goal and controlling maximum drawdown as a secondary objective. Set the trading execution frequency to once per hour, triggered by real-time predicted prices. S62: Establish basic trading rules. When the predicted price is higher than the current price by more than a threshold, a buy signal is generated; when it is lower, a sell signal is generated. The threshold is determined through historical backtesting. S63: Integrated risk constraints, setting the position size for a single trade to no more than 10% of the total capital, and applying a stop-loss mechanism to automatically close the position when the loss exceeds 5%; S64: Design a multi-timeframe strategy that combines short-term and long-term forecasts. Short-term forecasts are used for intraday trading signals, while long-term forecasts are used for position adjustments. S65: Add market status detection, calculate the Average True Range (ATR) indicator to divide high-volatility and low-volatility markets, and dynamically adjust trading thresholds under different conditions; S66: Construct signal generation logic to convert predicted prices into trading signals. The signal strength is proportional to the prediction confidence level, and quantile regression is used to output an 80% confidence interval. S67: Backtest strategy performance, using historical data to simulate the trading process and calculate Sharpe ratio, maximum drawdown, and win rate.
[0012] Preferably, the following steps are included when applying the optimization algorithm: S71: Select a multi-objective optimization algorithm, using the NSGA-II algorithm to optimize the trading strategy. The objective functions include maximizing annualized return and minimizing return variance. S72: Define decision variables, including trading thresholds, position sizes, and stop-loss points. Variables are represented by real numbers. S73: Set optimization parameters: population size 100, number of iterations 50, crossover probability 0.9, mutation probability 0.1; S74: Perform the optimization process, initialize the random population, calculate the fitness of each individual, and perform selection, simulate binary crossover, and polynomial mutation operations; S75: Handle constraints by adding a constraint that the total position does not exceed 100%, and use the penalty function method to integrate the constraint into the objective function, with the penalty coefficient set to 1000; S76: Obtain the Pareto frontier, run NSGA-II, and output the non-dominated solution set, representing the strategy combinations with different risk-reward trade-offs; S77: Select the optimal strategy by choosing the strategy with the highest Sharpe ratio from the Pareto front and verify its performance on the test set.
[0013] Preferably, when performing real-time monitoring and adjustments, the following steps are included: S81: Deploy a real-time data pipeline to stream the latest prices and external data from the market API, process the data stream using Apache Kafka, and periodically update the feature database; S82: Performs online predictions, loads a pre-trained hybrid model, and generates price predictions for real-time data every 15 minutes; S83: Monitor prediction bias, calculate the error between real-time prediction and actual price. If MAPE exceeds 10% for 5 consecutive time points, trigger the model retraining process. S84: Adjust trading strategy parameters, dynamically modify trading thresholds based on real-time volatility, and fine-tune parameters using a PID controller; S85: Handles data latency issues by setting a 5-minute timeout mechanism. If the data is not updated, it is replaced with the last available value or the predicted value, and the latency event is logged. S86: Implements logging and alerting, uses the ELK stack to store trading decisions and prediction data, and sets alert rules to notify when price fluctuations exceed 20%; S87: Regular model updates, retraining the model weekly with the latest data, and using incremental learning to update the LSTM weights.
[0014] As a preferred approach, risk assessment and management should include the following steps: S91: Calculate Value at Risk (VaR), using historical simulation to calculate the daily VaR at a 95% confidence level, and assess the maximum potential loss based on data from the past year; S92: Perform stress tests to simulate extreme market scenarios, evaluate the profit and loss of the strategy under these scenarios, and generate test data using the Monte Carlo method; S93: Diversify investment risk by trading in multiple regional electricity markets, calculating the inter-market correlation matrix, and optimizing asset allocation weights; S94: Set a risk limit, defining the maximum daily loss as 2% of total capital. When the limit is approached, the position size will be automatically reduced or trading will be suspended. S95: Monitor liquidity risk and analyze market bid-ask spreads and trading volume data; S96: Apply hedging strategies, using electricity futures contracts to hedge spot price risk, and calculate the hedging ratio based on historical price correlation; S97: Generate risk reports, outputting daily VaR, CVaR, and drawdown metrics, and use Tableau visualization tools to show risk trends and distribution.
[0015] Preferably, the following steps are included when conducting performance evaluation and iterative improvement: S101: Calculate comprehensive performance indicators, including annualized return, Sharpe ratio, maximum drawdown, and Calmar ratio during the testing period, and compare them with the benchmark strategy; S102: Analyze transaction log details, examine the profit and loss of each transaction, identify common error patterns, and calculate the average win rate and profit / loss ratio; S103: Conduct sensitivity analysis, change model parameters or market conditions, and observe changes in strategy performance; S104: Collect user feedback, discuss practical application issues of strategies with traders, and adjust signal generation logic or risk constraints based on feedback; S105: Iterative model improvement; feature engineering is performed again based on the evaluation results; the new algorithm is then tested. S106: Update workflow components.
[0016] The beneficial effects of this invention are: The shortcomings of existing electricity spot market price forecasting and trading methods lie in the poor adaptability of price forecasting models to sudden market events and complex nonlinear dynamics. Traditional models mainly rely on single linear statistical methods or basic machine learning algorithms, which perform poorly when dealing with stable or regular market data. Once faced with sharp market fluctuations caused by events such as extreme weather, equipment failure, or drastic reversals in supply and demand, their predictive performance will significantly decline. Existing models struggle to effectively capture and learn the nonlinear characteristics and long-term time dependencies in historical data, often treating price series as a relatively stable process while ignoring the possibility of non-stationarity and structural changes. When market conditions change abruptly, such models cannot quickly adjust their internal predictive logic. This solution significantly improves the price forecasting model's adaptability to market conditions. In terms of robustness and predictive accuracy in the face of market complexity and sudden events, the Long Short-Term Memory (LSTM) network component, with its gating mechanism, can effectively capture and remember nonlinear dependencies from historical price series and related multi-dimensional features, enabling the model to understand more abstract market dynamics. The Autoregressive Integral Moving Average (AMI) model component is used to capture the inherent linear trends and short-term patterns in time series. By setting an attention mechanism, the model can dynamically assign different weights to input information from different time steps in the past when making predictions. This allows it to more sensitively identify key moments that are more indicative of future price trends, rather than treating all historical information equally. As a result, the overall model can not only adapt to the normal fluctuations of the market, but also respond more sensitively and accurately to unconventional and drastic price changes. Attached Figure Description
[0017] Figure 1 The diagram shown is a flowchart illustrating the framework of a method for predicting and optimizing electricity spot market prices according to the present invention. Figure 2 The diagram shown illustrates the data collection and preprocessing flow of a method for predicting and optimizing electricity spot market prices according to the present invention. Figure 3 The diagram shown is a schematic representation of the feature engineering process of a method for predicting and optimizing electricity spot market prices according to the present invention. Figure 4 The diagram shown illustrates the price prediction model construction process of a method for predicting and optimizing electricity spot market prices according to the present invention. Detailed Implementation
[0018] The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0019] Please see Figure 1-4 This invention provides an embodiment: a method for predicting and optimizing electricity spot market prices, comprising the following steps: S11: Integrate multi-source electricity market data and perform systematic cleaning, alignment, and enhancement to construct a standardized time-series dataset; S12: A multi-dimensional feature space is constructed through technical indicator extraction, temporal coding, and dimensionality reduction to optimize the input quality of the prediction model; S13: Design a hybrid neural network architecture that integrates LSTM and ARIMA, and incorporate an attention mechanism to handle multivariate time series prediction; S14: Optimize hyperparameters using cross-validation and early stopping strategies; S15: Establish a multi-dimensional trading rule system based on predictive signals, integrating risk constraints and market state detection mechanisms; S16: The NSGA-II multi-objective evolutionary algorithm is used to solve the Pareto front of the trading parameters to achieve the optimal balance between risk and return; S17: Deploy streaming data processing pipelines and model services, and establish dynamic parameter adjustment and anomaly early warning mechanisms; S18: Construct a multi-layered risk prevention and control system through VaR calculation, stress testing, and hedging strategies; S19: Analyze the effectiveness of strategies based on comprehensive indicators and continuously optimize the model architecture and workflow components.
[0020] Preferably, the data collection and preprocessing process includes the following steps: S21: Download historical spot price data from the API interface of the electricity market operator. The data granularity includes hourly and 15-minute intervals, covering a time range of at least five years, including weekdays, weekends, and holidays. Use Python's requests library to write an automated script to regularly update the data and store it in a MySQL database. S22: Integrate external data sources, including obtaining weather data from the NOAA API, extracting power generation data from power plant reports, obtaining load data from grid operators, downloading fuel prices from the Energy Information Administration, and integrating public calendar holiday information; S23: Clean the data for missing values. Use pandas library functions to identify missing points. For consecutive missing values, use forward imputation. For random missing values, apply linear interpolation. At the same time, detect outliers based on the 3σ principle. Replace data points that exceed three standard deviations with the moving average of adjacent time points. S24: Standardized numerical features are scaled to the 0-1 range using Min-Max standardization, implemented using Scikit-learn's MinMaxScaler. Categorical features are one-hot encoded and converted into binary vectors. S25: Align the time series data, use pandas' resample function to resample all data to a uniform hourly frequency, use forward padding to handle missing data for weather data, and apply linear interpolation to price data; S26: Divide the dataset into training, validation, and test sets, and split them in chronological order. Use the first 70% of the data as the training set, the middle 15% as the validation set, and the last 15% as the test set. Use time-series splitting to prevent data leakage. S27: Perform data augmentation by adding Gaussian noise to the price data, with the noise standard deviation set to 5% of the price standard deviation, generating additional training samples, and applying a time window sliding technique to create multiple 24-hour subsequences.
[0021] Preferably, feature engineering includes the following steps: S31: Calculate price technical indicators, including 5-day, 10-day, and 20-day moving averages, using pandas' rolling function. Calculate the 14-day Relative Strength Index (RSI) and construct Bollinger Bands based on the 20-day moving average and twice the standard deviation. S32: Extract time-related features, parse the hour, day, month, quarter, and whether it is a weekend from the timestamp, and apply sine and cosine coding to process periodic features; S33: Create lag features to generate lagged variables for price data, with lag times ranging from 1 hour to 24 hours. Simultaneously, calculate first and second-order differences to handle non-stationarity and capture price change trends. S34: Construct interactive features by multiplying weather data and price data, using the product of temperature and price as a new feature, and calculating the ratio of load to power generation; S35: Principal component analysis (PCA) is applied for dimensionality reduction. For high-dimensional weather variables, the PCA algorithm is used to retain 95% of the variance components, reducing the number of features. PCA is then used in Scikit-learn for transformation. S36: Select important features, train the random forest model to calculate feature importance on the training set, select the top 20 key features, and adjust the selection threshold based on the performance on the validation set; S37: To handle multicollinearity, calculate the Pearson correlation coefficient matrix between features, remove features with a correlation coefficient greater than 0.9, and use variance inflation factor (VIF) detection to ensure that the VIF value is below 10.
[0022] Preferably, the following steps are included when constructing a price prediction model: S41: Design a hybrid model architecture that combines an LSTM neural network and an ARIMA time series model. The LSTM layer handles long-term dependencies, while the ARIMA model captures short-term linear trends, outputting a price prediction sequence for the next 24 hours. S42: Configure the LSTM network parameters, set two LSTM layers with 50 neurons per layer, use the tanh activation function, add a Dropout layer with a dropout rate of 0.2, and use a linear activation function for the output layer; S43: Integrating the ARIMA model, fitting the ARIMA(p,d,q) model to historical price data, selecting the p, d, and q parameters through an automatic order determination method, minimizing it using the AIC criterion, and passing the ARIMA residuals as input features to the LSTM; S44: Add an attention mechanism by introducing an attention layer after the LSTM layer. Calculate the attention weights of the hidden states, sum them by weight, and output the result, allowing the model to focus on key time steps. S45: Handles multivariate inputs by using feature-engineered data as input, with the input dimension equal to the number of features and a fixed time step of 24 hours; S46: Define the loss function, using the mean squared error (MSE) as the main loss, add an L2 regularization term with a coefficient of 0.01, and compile the model using the TensorFlow framework; S47: Initialize model weights. Set the weights for the LSTM layer using the He initialization method. Initialize the biases to zero. Initialize the ARIMA model parameters using maximum likelihood estimation.
[0023] Preferably, the model training and validation process includes the following steps: S51: Set training hyperparameters, select the Adam optimizer, set the learning rate to 0.001, batch size to 32, number of training epochs to 100, apply the early stopping strategy, and set the patience parameter to 10; S52: Perform the model training process, iteratively train the hybrid model on the training set, calculate the training loss after each epoch, monitor the performance using the validation set, and save the model weights with the minimum validation loss; S53: Apply time series cross-validation, divide the data into 5 folds, with each fold serving as the validation set, and calculate the average validation error; S54: Adjust model parameters, optimize the number of LSTM layers or neurons based on validation set results, and use grid search to fine-tune the p, d, and q parameters of ARIMA, with a search range of p[1,5], d[0,2], and q[1,5]. S55: To address overfitting, if the validation loss increases, increase the Dropout rate to 0.3 or add L1 regularization, and retrain the model using the augmented data. S56: Evaluate model performance by calculating the mean absolute error (MAE), root mean square error (RMSE), and mean absolute percentage error (MAPE) on the test set, and compare the distribution of predicted and actual values. S57: Perform model interpretability analysis, use the SHAP library to calculate feature contribution values, visualize the impact of key features, and analyze attention weights to identify important time points.
[0024] Preferably, the following steps are included when designing a trading strategy: S61: Define the trading objective, with maximizing cumulative profit as the primary goal and controlling maximum drawdown as a secondary objective. Set the trading execution frequency to once per hour, triggered by real-time predicted prices. S62: Establish basic trading rules. When the predicted price is higher than the current price by more than a threshold, a buy signal is generated; when it is lower, a sell signal is generated. The threshold is determined through historical backtesting. S63: Integrated risk constraints, setting the position size for a single trade to no more than 10% of the total capital, and applying a stop-loss mechanism to automatically close the position when the loss exceeds 5%; S64: Design a multi-timeframe strategy that combines short-term and long-term forecasts. Short-term forecasts are used for intraday trading signals, while long-term forecasts are used for position adjustments. S65: Add market status detection, calculate the Average True Range (ATR) indicator to divide high-volatility and low-volatility markets, and dynamically adjust trading thresholds under different conditions; S66: Construct signal generation logic to convert predicted prices into trading signals. The signal strength is proportional to the prediction confidence level, and quantile regression is used to output an 80% confidence interval. S67: Backtest strategy performance, using historical data to simulate the trading process and calculate Sharpe ratio, maximum drawdown, and win rate.
[0025] Preferably, the following steps are included when applying the optimization algorithm: S71: Select a multi-objective optimization algorithm, using the NSGA-II algorithm to optimize the trading strategy. The objective functions include maximizing annualized return and minimizing return variance. S72: Define decision variables, including trading thresholds, position sizes, and stop-loss points. Variables are represented by real numbers. S73: Set optimization parameters: population size 100, number of iterations 50, crossover probability 0.9, mutation probability 0.1; S74: Perform the optimization process, initialize the random population, calculate the fitness of each individual, and perform selection, simulate binary crossover, and polynomial mutation operations; S75: Handle constraints by adding a constraint that the total position does not exceed 100%, and use the penalty function method to integrate the constraint into the objective function, with the penalty coefficient set to 1000; S76: Obtain the Pareto frontier, run NSGA-II, and output the non-dominated solution set, representing the strategy combinations with different risk-reward trade-offs; S77: Select the optimal strategy by choosing the strategy with the highest Sharpe ratio from the Pareto front and verify its performance on the test set.
[0026] Preferably, when performing real-time monitoring and adjustments, the following steps are included: S81: Deploy a real-time data pipeline to stream the latest prices and external data from the market API, process the data stream using Apache Kafka, and periodically update the feature database; S82: Performs online predictions, loads a pre-trained hybrid model, and generates price predictions for real-time data every 15 minutes; S83: Monitor prediction bias, calculate the error between real-time prediction and actual price. If MAPE exceeds 10% for 5 consecutive time points, trigger the model retraining process. S84: Adjust trading strategy parameters, dynamically modify trading thresholds based on real-time volatility, and fine-tune parameters using a PID controller; S85: Handles data latency issues by setting a 5-minute timeout mechanism. If the data is not updated, it is replaced with the last available value or the predicted value, and the latency event is logged. S86: Implements logging and alerting, uses the ELK stack to store trading decisions and prediction data, and sets alert rules to notify when price fluctuations exceed 20%; S87: Regular model updates, retraining the model weekly with the latest data, and using incremental learning to update the LSTM weights.
[0027] As a preferred approach, risk assessment and management should include the following steps: S91: Calculate Value at Risk (VaR), using historical simulation to calculate the daily VaR at a 95% confidence level, and assess the maximum potential loss based on data from the past year; S92: Perform stress tests to simulate extreme market scenarios, evaluate the profit and loss of the strategy under these scenarios, and generate test data using the Monte Carlo method; S93: Diversify investment risk by trading in multiple regional electricity markets, calculating the inter-market correlation matrix, and optimizing asset allocation weights; S94: Set a risk limit, defining the maximum daily loss as 2% of total capital. When the limit is approached, the position size will be automatically reduced or trading will be suspended. S95: Monitor liquidity risk and analyze market bid-ask spreads and trading volume data; S96: Apply hedging strategies, using electricity futures contracts to hedge spot price risk, and calculate the hedging ratio based on historical price correlation; S97: Generate risk reports, outputting daily VaR, CVaR, and drawdown metrics, and use Tableau visualization tools to show risk trends and distribution.
[0028] Preferably, the following steps are included when conducting performance evaluation and iterative improvement: S101: Calculate comprehensive performance indicators, including annualized return, Sharpe ratio, maximum drawdown, and Calmar ratio during the testing period, and compare them with the benchmark strategy; S102: Analyze transaction log details, examine the profit and loss of each transaction, identify common error patterns, and calculate the average win rate and profit / loss ratio; S103: Conduct sensitivity analysis, change model parameters or market conditions, and observe changes in strategy performance; S104: Collect user feedback, discuss practical application issues of strategies with traders, and adjust signal generation logic or risk constraints based on feedback; S105: Iterative model improvement; feature engineering is performed again based on the evaluation results; the new algorithm is then tested. S106: Update workflow components.
[0029] Example 1 Background: In recent years, the regional electricity spot market has faced the challenge of increased price volatility, especially during periods of high renewable energy generation and peak load, when price spikes and troughs frequently occur. Traditional forecasting methods based on single time series models struggle to accurately capture the characteristics of sudden price changes. Trading systems employing fixed-parameter trading strategies often exhibit insufficient adaptability when market conditions change, resulting in limited trading profits during periods of price stability and significant risk of losses during periods of sharp price fluctuations. Furthermore, existing trading systems lack effective multi-objective optimization mechanisms, making it difficult to achieve a dynamic balance between returns and risks. To address these issues, this embodiment applies the aforementioned electricity spot market price forecasting and trading optimization method.
[0030] Implementation steps: First, a data acquisition and processing platform is deployed. It acquires 15-minute granular price data from the spot market over the past five years via the power trading center's API interface. Simultaneously, it accesses meteorological data such as temperature, humidity, and wind speed provided by the meteorological department, as well as unit output plans and actual load data released by the power grid dispatching agency. A data quality monitoring mechanism is established to perform integrity checks and outlier detection on the collected data. A time series alignment algorithm is used to unify the timestamps of various data sources. Based on this, a feature engineering pipeline is constructed to calculate the moving average and volatility index of the price data, extract date and time features and perform periodic encoding, generating lag features and interaction features. Finally, the processed data is stored in a time series database, providing a high-quality data foundation for subsequent modeling.
[0031] Based on the preprocessed data, a hybrid prediction model is constructed. First, the ARIMA model and the LSTM neural network are trained separately: the optimal parameter combination of the ARIMA model is determined using an automatic order determination method, a two-layer LSTM network structure is configured, and a random inactivation ratio is set to prevent overfitting. Then, a model fusion mechanism is designed, using the residual sequence of the ARIMA model as an additional input feature of the LSTM model. During the model training phase, the hyperparameters are adjusted using time series cross-validation, and an early stopping mechanism is used to control the number of training rounds. After the model training is completed, the prediction performance is evaluated on the test set, the distribution characteristics of the prediction error are analyzed, and the attention weight visualization is used to verify whether the model's attention to key time points conforms to the actual operating rules of the market.
[0032] Based on price prediction results, a multi-dimensional trading strategy is designed. First, the basic framework of the trading rules is defined, including signal generation conditions, position control rules, and stop-loss mechanisms. Then, a multi-objective optimization algorithm is used to optimize the strategy parameters, with the optimization objectives being to maximize the annualized return and minimize the maximum drawdown. The Pareto optimal solution set is obtained through an evolutionary algorithm. Based on the optimization results, the parameter combination with the highest Sharpe ratio is selected as the basic trading strategy. At the same time, a market state recognition module is established to monitor changes in market volatility in real time. When a market state transition is detected, the corresponding strategy parameters are automatically switched. Finally, the strategy is encapsulated into an executable module and deployed to a live trading environment.
[0033] A streaming data processing platform is built to receive market data and predictive model outputs in real time. The trading engine executes decision logic every 15 minutes: first, it verifies the timeliness and completeness of the data; then, it calls the predictive model to generate price forecasts for future periods; and finally, it generates trading signals based on the current market conditions. Before executing trading instructions, the risk control module performs multi-level checks, including position limit checks, loss warning checks, and liquidity assessments. For trading signals that pass the risk control checks, they are sent to the power trading platform through the trading interface. At the same time, the monitoring system continuously tracks trading performance, calculates risk value indicators in real time, and performs stress tests regularly to ensure that trading activities are always conducted within the preset risk boundaries.
[0034] A systematic evaluation mechanism is established, generating daily trading performance reports and conducting weekly strategy review and analysis. By comparing actual and expected returns, the performance characteristics of strategies under different market conditions are identified. Traders' practical feedback is collected regularly, and the model and strategy are iteratively optimized based on quantitative analysis results. When the model's prediction accuracy continues to decline, the model retraining process is initiated. When new market characteristics emerge, the feature engineering scheme is adjusted in a timely manner. Through this continuous improvement mechanism, the system is ensured to adapt to changes in the market environment and maintain optimal performance at all times.
[0035] The embodiments of the present invention have been described in detail above with reference to the accompanying drawings. However, the present invention is not limited to the above embodiments. Within the scope of knowledge possessed by those skilled in the art, various changes can be made without departing from the spirit of the present invention.
Claims
1. A method for power spot market price forecasting and trading optimization; characterized in that: Comprising the following steps: S11: Integrate multi-source power market data and perform systematic cleaning, alignment, and enhancement to build standardized time series datasets; S12: Construct a multi-dimensional feature space by extracting technical indicators, time series encoding, and dimensionality reduction processing to optimize the input quality of the prediction model; S13: Design a hybrid neural network architecture that combines LSTM and ARIMA, integrating an attention mechanism to handle multi-variable time series prediction; S14: Optimize hyperparameters using cross-validation and early stopping strategies; S15: Establish a multi-dimensional trading rule system based on prediction signals, incorporating risk constraints and market state detection mechanisms; S16: Solve the trading parameter Pareto frontier using the NSGA-II multi-objective evolutionary algorithm to achieve an optimal balance between risk and return; S17: Deploy a streaming data processing pipeline and model service, establishing dynamic parameter adjustment and anomaly early warning mechanisms; S18: Build a multi-layered risk prevention and control system through VaR calculation, stress testing, and hedging strategies; S19: Analyze strategy effectiveness based on comprehensive indicators to continuously optimize model architecture and workflow components.
2. The method of claim 1, wherein: During data collection and preprocessing, the following steps are included: S21: Download historical spot price data from the API interface of the power market operator, with data granularity including hourly and 15-minute intervals, covering at least a five-year time range, including weekdays, weekends, and holidays. Use Python's requests library to write automated scripts for regular data updates and storage in a MySQL database; S22: Integrate external data sources, including obtaining weather data from NOAA API, extracting power generation data from power plant reports, obtaining load data from grid operators, downloading fuel prices from the Energy Information Administration, and integrating public calendar holiday information; S23: Clean missing values, use pandas library functions to identify missing points, apply forward filling for continuous missing, linear interpolation for random missing, and detect outliers based on the 3σ principle, replace data points exceeding three standard deviations with the moving average of adjacent time points; S24: Standardize numerical features, apply Min-Max standardization to scale each feature to the 0-1 range using Scikit-learn's MinMaxScaler, and one-hot encode categorical features into binary vectors; S25: Align time series data, use pandas' resample function to resample all data to a uniform hourly frequency, apply forward filling to handle missing weather data, and apply linear interpolation to price data; S26: Divide the dataset into training, validation, and test sets, split by time order, with the first 70% as the training set, the middle 15% as the validation set, and the last 15% as the test set, using time series segmentation methods to prevent data leakage; S27: Perform data augmentation by adding Gaussian noise to price data with a noise standard deviation of 5% of the price standard deviation, generate additional training samples, and apply time window sliding techniques to create multiple 24-hour sub-sequences.
3. The method of claim 1, wherein: During feature engineering, the following steps are included: S31: Calculate price technical indicators, including 5-day, 10-day, and 20-day moving averages using the rolling function from pandas, calculate the 14-day RSI (Relative Strength Index), and construct Bollinger Bands based on the 20-day moving average and 2 times the standard deviation; S32: Extract time-related features, parse the hour, day, month, quarter, and whether it is a weekend from the timestamp, and apply sine-cosine encoding to handle periodic features; S33: Create lag features, generate lag variables for price data with lag times ranging from 1 hour to 24 hours, and calculate first and second differences to handle non-stationarity and capture price change trends; S34: Build interaction features, multiply weather data with price data, and use the product of temperature and price as a new feature, calculate the ratio of load to generation; S35: Apply principal component analysis for dimensionality reduction, use the PCA algorithm for high-dimensional weather variables, retain components that account for 95% of the variance, and reduce the number of features, use Scikit-learn's PCA for conversion; S36: Select important features, train a random forest model to calculate feature importance on the training set, select the top 20 key features, and adjust the selection threshold based on validation set performance; S37: Handle multicollinearity, calculate the Pearson correlation coefficient matrix between features, remove features with correlation coefficients exceeding 0.9, and use the variance inflation factor (VIF) to ensure that the VIF value is less than 10.
4. The method of claim 1, wherein: When building the price prediction model, the following steps are included: S41: Design a hybrid model architecture combining LSTM neural networks and ARIMA time series models, with LSTM layers handling long-term dependencies and ARIMA models capturing short-term linear trends, outputting a 24-hour price prediction sequence; S42: Configure LSTM network parameters, set two LSTM layers with 50 neurons each, use the tanh activation function, add a Dropout layer with a dropout rate of 0.2, and use a linear activation function for the output layer; S43: Integrate an ARIMA model, fit an ARIMA(p, d, q) model to historical price data, select p, d, and q parameters through automatic order determination, and minimize the AIC criterion, use ARIMA residuals as input features for the LSTM; S44: Add an attention mechanism, introduce an attention layer after the LSTM layer, calculate attention weights for hidden states, and output the weighted sum to make the model focus on key time steps; S45: Handle multivariate input, use the feature-engineered data as input, with input dimensions equal to the number of features, and a fixed time step of 24 hours; S46: Define the loss function, use mean squared error (MSE) as the main loss, add an L2 regularization term with a coefficient of 0.01, and use the TensorFlow framework to implement model compilation; S47: Initialize model weights, use the He initialization method to set weights for LSTM layers, and initialize biases to zero, initialize ARIMA model parameters through maximum likelihood estimation.
5. The method of claim 1, wherein: When training and validating the model, the following steps are included: S51: Set training hyperparameters, choose Adam optimizer with learning rate 0.001, batch size 32, number of training epochs 100, apply early stopping with patience 10; S52: Execute model training process, iterate over training dataset, calculate training loss after each epoch, monitor performance using validation set, save model weights with minimum validation loss; S53: Apply time series cross-validation, divide data into 5 folds, use each fold as validation set in turn, calculate average validation error; S54: Adjust model parameters, optimize LSTM layer number or neuron count based on validation set results, use grid search to tune ARIMA p, d, q parameters, search range p[1,5], d[0,2], q[1,5]; S55: Handle overfitting, if validation loss increases, increase Dropout rate to 0.3 or add L1 regularization, retrain model using augmented data; S56: Evaluate model performance, calculate mean absolute error (MAE), root mean square error (RMSE), and mean absolute percentage error (MAPE) on test set, compare predicted and actual values distribution; S57: Perform model interpretability analysis, use SHAP library to calculate feature contribution values, visualize key feature influences, analyze attention weights to identify important time points.
6. The method of claim 1, wherein: When designing a trading strategy, include the following steps: S61: Define trading objectives, aim to maximize cumulative returns, control maximum drawdown, set trading frequency to once per hour based on real-time predicted prices; S62: Develop basic trading rules, generate buy signals when predicted price is above current price by a threshold, generate sell signals when it is below, determine threshold through historical backtesting; S63: Integrate risk constraints, set single trade position not exceeding 10% of total capital, apply stop loss mechanism, automatically close position when loss exceeds 5%; S64: Design multi-time frame strategy, combine short-term and long-term predictions, use short-term for intraday trading signals, long-term for position sizing; S65: Add market state detection, calculate average true range (ATR) to classify high and low volatility markets, dynamically adjust trading thresholds in different states; S66: Build signal generation logic, convert predicted prices into trading signals, signal strength proportional to prediction confidence, use quantile regression to output 80% confidence interval; S67: Backtest strategy performance, simulate trading process using historical data, calculate Sharpe ratio, maximum drawdown, and win rate.
7. The method of claim 1, wherein: When applying optimization algorithms, include the following steps: S71: Choose multi-objective optimization algorithm, use NSGA-II to optimize trading strategy, target functions include maximizing annualized returns and minimizing return variance; S72: Define decision variables, including trading thresholds, position sizes, and stop loss points, variables represented as real numbers; S73: Set optimization parameters, population size 100, number of iterations 50, crossover probability 0.9, mutation probability 0.1; S74: Perform optimization process, initialize random population, calculate fitness of each individual, perform selection, binary crossover and polynomial mutation operations; S75: Handle constraints, add constraint that total position cannot exceed 100%, incorporate constraint into objective function using penalty function method, set penalty coefficient to 1000; S76: Obtain Pareto front, output non-dominated solution set after running NSGA-II, represent strategy combinations that trade off risk and return; S77: Select optimal strategy, choose strategy with highest Sharpe ratio from Pareto front, verify its performance on test set.
8. The method of claim 1, wherein: When performing real-time monitoring and adjustment, include the following steps: S81: Deploy real-time data pipeline, stream latest prices and external data from market APIs, use Apache Kafka to handle data streams, update to feature database regularly; S82: Perform online prediction, load trained hybrid model, generate price predictions every 15 minutes on real-time data; S83: Monitor prediction bias, calculate error between real-time prediction and actual price, if MAPE exceeds 10% for 5 consecutive time points, trigger model retraining process; S84: Adjust trading strategy parameters, dynamically modify trading thresholds based on real-time volatility, apply PID controller for fine-tuning parameters; S85: Handle data latency issues, set 5-minute timeout mechanism, if data is not updated, use last available value or prediction value as substitute, log latency event; S86: Implement logging and alerting, use ELK stack to store trading decisions and prediction data, set alerting rules to notify when price moves more than 20%; S87: Regularly update models, retrain models with latest data every week, use incremental learning to update LSTM weights.
9. The method of claim 1, wherein: When performing risk assessment and management, include the following steps: S91: Calculate value at risk (VaR), use historical simulation method to calculate daily VaR at 95% confidence level, assess maximum potential loss based on past year data; S92: Perform stress testing, simulate extreme market scenarios, evaluate strategy's gains and losses in these scenarios, use Monte Carlo method to generate test data; S93: Diversify investment risk, trade multiple regional electricity markets, calculate correlation matrix between markets, optimize asset allocation weights; S94: Set risk limits, define maximum daily loss as 2% of total capital, automatically reduce position or suspend trading when approaching limit; S95: Monitor liquidity risk, analyze market bid-ask spread and trading volume data; S96: Apply hedging strategies, use electricity futures contracts to hedge spot price risk, calculate hedging ratio based on historical price correlation; S97: Generate risk reports, output VaR, CVaR and drawdown metrics daily, use Tableau visualization tools to display risk trends and distribution.
10. The method of claim 1, wherein: When performing performance evaluation and iterative improvement, include the following steps: S101: Calculate comprehensive performance indicators, calculate annualized return, Sharpe ratio, maximum drawdown and Calmar ratio during test period, compare with benchmark strategy; S102: Analyze transaction record details, check the profit and loss of each transaction, identify common error patterns, calculate average winning rate and profit and loss ratio; S103: Sensitivity analysis, change model parameters or market conditions, observe the change of strategy performance; S104: Collect user feedback, discuss strategy practical application problems with traders, adjust signal generation logic or risk constraint conditions based on feedback; S105: Iterative model improvement, re-feature engineering according to evaluation results, test new algorithms; S106: Update workflow components.