preprocessing.exog_providers.EntsoeDayAheadPriceProvider(
data_home= None ,
max_gap= 0 ,
max_tail_gap= 0 ,
provider_window= None ,
)
ENTSO-E day-ahead spot price (DE/LU) as an exogenous input.
Reads interim/day_ahead_price.csv via spotforecast2_safe.data.fetch_data.load_day_ahead_price. The day-ahead auction price is published on D-1 and is leakage-clean at forecast time; the realised price must never be used.
Parameters
data_home
DataHome
Root data directory forwarded to the loader.
None
max_gap
int
Maximum contiguous missing-value run healed by _align_to_index. See _align_to_index for full semantics. Defaults to 0.
0
max_tail_gap
int
Extended healing budget for the trailing-edge NaN run. See _align_to_index. Defaults to 0.
0
provider_window
Optional [pd .DatetimeIndex ]
Validation index passed to _align_to_index as validate_index . See _align_to_index. Defaults to None.
None
Examples
import os
import shutil
import tempfile
import pandas as pd
from spotforecast2_safe.preprocessing.exog_providers import (
EntsoeDayAheadPriceProvider,
)
tmp = tempfile.mkdtemp()
os.environ["SPOTFORECAST2_DATA" ] = tmp
os.makedirs(os.path.join(tmp, "interim" ), exist_ok= True )
idx = pd.date_range("2023-06-01" , periods= 24 , freq= "h" , tz= "UTC" )
pd.DataFrame(
{"Day-ahead Price" : 95.0 }, index= idx
).rename_axis("Time (UTC)" ).to_csv(
os.path.join(tmp, "interim" , "day_ahead_price.csv" )
)
provider = EntsoeDayAheadPriceProvider()
out = provider.build(idx)
print (out.columns.tolist(), out.shape, out.dtypes.iloc[0 ].name)
assert out.shape == (24 , 1 )
assert not out.isna().any ().any ()
shutil.rmtree(tmp)
del os.environ["SPOTFORECAST2_DATA" ]
['entsoe_day_ahead_price'] (24, 1) float32
Methods
build
Return the day-ahead price series aligned to index .
build
preprocessing.exog_providers.EntsoeDayAheadPriceProvider.build(index)
Return the day-ahead price series aligned to index .
Parameters
index
pd .DatetimeIndex
Hourly DatetimeIndex (tz-aware UTC) for the forecast window.
required
Returns
pd .DataFrame
pd.DataFrame: Single column entsoe_day_ahead_price, float32.
Raises
ExogProviderError
If interim/day_ahead_price.csv is missing or the Day-ahead Price column is absent.
Examples
import os
import shutil
import tempfile
import pandas as pd
from spotforecast2_safe.preprocessing.exog_providers import (
EntsoeDayAheadPriceProvider,
)
tmp = tempfile.mkdtemp()
os.environ["SPOTFORECAST2_DATA" ] = tmp
os.makedirs(os.path.join(tmp, "interim" ), exist_ok= True )
idx = pd.date_range("2023-06-01" , periods= 12 , freq= "h" , tz= "UTC" )
pd.DataFrame(
{"Day-ahead Price" : 88.5 }, index= idx
).rename_axis("Time (UTC)" ).to_csv(
os.path.join(tmp, "interim" , "day_ahead_price.csv" )
)
out = EntsoeDayAheadPriceProvider().build(idx)
print (out.columns.tolist(), out.shape, float (out.iloc[0 , 0 ]))
assert out.shape == (12 , 1 )
shutil.rmtree(tmp)
del os.environ["SPOTFORECAST2_DATA" ]
['entsoe_day_ahead_price'] (12, 1) 88.5