Time series public market auction price forecasting. Comparing different prediction horizon scenarios (hourly and daily), prediction models and contribution of feature engineering.
git clone ...
cd price_forecasting
poetry install
poetry shell
(venv) python prophet_forecasting.py # evaluates Prophet model
(venv) python tree_forecasting.py -m catboost -l 24 -z 24 # evaluates tree based models
(venv) python optimization.py # evaluates optimization strategy
Hourly electicity prices from public european energy market over a 6 month period time window.
Data sources:
- https://www.smard.de (Bundesnetzagentur)
- https://transparency.entsoe.eu
Download as .csv file in various time resolutions.
Available dataset columns names.
- MTU (CET/CEST)
$\rightarrow$ Time intervals [FROM, TO] in UTC+1 timezone - Day-ahead Price [EUR/MWh]
$\rightarrow$ Target price column to be predicted - Currency
$\rightarrow$ Price unit Euro (irrelevant for modeling) - BZN|DE-LU
$\rightarrow$ Bidding zone Germany/Luxembourg
Electricity price of the public auction market.
Observations
- Noisy short term variability, next to long term repetitive cyclic patterns
- External factors seems to cause unusual large outlier in early March
ds: Time | y: Price
(Log) Price samples per day historgram
Gap localization over time.
Samples count per day
Data cleansing by interpolation over small time step gaps.
Two situations with regards to the feature dimensions have been compared for the XGBoost. Raw time series only as feature input, in constrast to extracting additional common metrics from the price.
POC parametrization
- Initial window size in days (120)
$\rightarrow$ training window (the bigger the better) - Horizon in hours
$\rightarrow$ prediction step size (how far to predict into the future) - Period in hours
$\rightarrow$ number of prediction stepsY [Price in €/MWh] over time
Legend:
- Historical observations (black dots)
- Confidence interval (light blue band)
- Predictions (blue dense line)
- Upper threshold limit (dashed black line)
Time series cross validation is used to measure the forecast error using historical data. This is done by selecting cutoff points in the history, and for each of them fitting the model using data only up to that cutoff point. The forecasted values (yhat) are compared to the actual (y) values.
Prediction & observations over time for daily forecast horizon [Price in €/MWh]
Metrics are below the pricings standard deviation of 90.656821, which means they are reasonable, but error metrics are still at quite high level. Hence the model did derive valuable information from the data, but it can be assumed that there is quite some potential left with dataset preprocessing and model selection. And most importantly the models parameters (e.g. sampling strategy) are just chosen for quick experimentation but not for optimal results and need more adjustment.
Prophet model for time series forecasting is exhausting its capability to handle high frequency, volatile from external unkown factors in the data and struggles to model irregular patterns.
Boosting (unbalanced) tree based regression model for time series forecasting.
Test set size of 696 June samples (deducting samples from gap between cross validation splits). Two scenarios of hourly and one day ahead forecast horizons.
Prediction & observations for daily forecast horizon, no artifical features [Price in €/MWh]
Prediction & observations for hourly forecast horizon, no artifical features [Price in €/MWh]
XGBoost with extended input feature dimensions
Prediction & observations for daily forecast horizon, artifical features added [Price in €/MWh]
Prediction & observations for hourly forecast horizon, artifical features added [Price in €/MWh]
The XGBoost model achieves significantly smaller error metrics on the evaluation sets for the short term prediction scenario and handles non saisonale spiky patterns better. While the tree based model outperforms the prohpet model on long term predictions on a smaller distance. Data set extension adding artifical feature dimensions, does only contribute benefitial to the prediction accuracy in the short horizon scenario.
CatBoost is known to excel even without extensive hyperparameter optimization building symmetric trees.
Test set size of 696 June samples (deducting samples from gap between cross validation splits). Two scenarios of hourly and one day ahead forecast horizons.
Prediction & observations for daily forecast horizon, no artifical features [Price in €/MWh]
Prediction & observations for hourly forecast horizon, no artifical features [Price in €/MWh]
CatBoost with extended input feature dimensions
Prediction & observations for daily forecast horizon, artifical features added [Price in €/MWh]
Prediction & observations for hourly forecast horizon, artifical features added [Price in €/MWh]
Catboost outperforms XGBoost slightly and Prophet forecasting scenario. In contrast to XGboost it benefits from extended feature dimension even in small dataset challenges.
Overall it can be observed that the fitting effort for tree based models are multiple magnitudes smaller, than for non tree-based additive regression models like Prohpet. While both tree model approaches also achieved better results on the test set for energy price forecasting.
Task: Buy energy at cheap prices and store in batteries, to sell at future higher prices.
Charging speed at time t:
Battery constraints
Total capacity:
Charging speed:
Trading actions
State update
Optimizable cost function