Skip to content

Commit 81867a4

Browse files
committed
add support for intraday prices for the zones that support it, fixes #446
1 parent d478af8 commit 81867a4

File tree

1 file changed

+91
-2
lines changed

1 file changed

+91
-2
lines changed

entsoe/entsoe.py

Lines changed: 91 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
warnings.filterwarnings('ignore', category=XMLParsedAsHTMLWarning)
2727

2828
__title__ = "entsoe-py"
29-
__version__ = "0.7.4"
29+
__version__ = "0.7.5"
3030
__author__ = "EnergieID.be, Frank Boerman"
3131
__license__ = "MIT"
3232

@@ -184,13 +184,44 @@ def query_day_ahead_prices(self, country_code: Union[Area, str],
184184
'documentType': 'A44',
185185
'in_Domain': area.code,
186186
'out_Domain': area.code,
187-
'offset': offset
187+
'offset': offset,
188+
'contract_MarketAgreement.type': 'A01'
188189
}
189190
if sequence is not None:
190191
params['classificationSequence_AttributeInstanceComponent.position'] = sequence
191192
response = self._base_request(params=params, start=start, end=end)
192193
return response.text
193194

195+
196+
197+
def query_intraday_prices(self, country_code: Union[Area, str],
198+
start: pd.Timestamp, end: pd.Timestamp,
199+
sequence: int, offset: int = 0) -> str:
200+
"""
201+
Parameters
202+
----------
203+
country_code : Area|str
204+
start : pd.Timestamp
205+
end : pd.Timestamp
206+
207+
Returns
208+
-------
209+
str
210+
"""
211+
area = lookup_area(country_code)
212+
params = {
213+
'documentType': 'A44',
214+
'in_Domain': area.code,
215+
'out_Domain': area.code,
216+
'offset': offset,
217+
'contract_MarketAgreement.type': 'A07'
218+
}
219+
if sequence is not None:
220+
params['classificationSequence_AttributeInstanceComponent.position'] = sequence
221+
response = self._base_request(params=params, start=start, end=end)
222+
return response.text
223+
224+
194225
def query_aggregated_bids(self, country_code: Union[Area, str],
195226
process_type: str,
196227
start: pd.Timestamp, end: pd.Timestamp) -> str:
@@ -1347,6 +1378,64 @@ def _query_day_ahead_prices(
13471378
raise NoMatchingDataError
13481379
return series
13491380

1381+
# we need to do offset, but we also want to pad the days so wrap it in an internal call
1382+
def query_intraday_prices(
1383+
self, country_code: Union[Area, str],
1384+
start: pd.Timestamp,
1385+
end: pd.Timestamp,
1386+
sequence: int) -> pd.Series:
1387+
"""
1388+
Parameters
1389+
----------
1390+
this will return the IDA prices, forced to the correct resolution
1391+
country_code : Area|str
1392+
start : pd.Timestamp
1393+
end : pd.Timestamp
1394+
sequence: int, 1, 2 or 3 corresponding to IDA 1, 2, 3. only some zones publish this on entsoe
1395+
1396+
Returns
1397+
-------
1398+
pd.Series
1399+
"""
1400+
1401+
area = lookup_area(country_code)
1402+
# we do here extra days at start and end to fix issue 187
1403+
series = self._query_intraday_prices(
1404+
area,
1405+
start=start-pd.Timedelta(days=1),
1406+
end=end+pd.Timedelta(days=1),
1407+
sequence=sequence
1408+
)
1409+
series = series.tz_convert(area.tz).sort_index()
1410+
series = series.truncate(before=start, after=end)
1411+
# because of the above fix we need to check again if any valid data exists after truncating
1412+
if len(series) == 0:
1413+
raise NoMatchingDataError
1414+
return series
1415+
1416+
@year_limited
1417+
@documents_limited(100)
1418+
def _query_intraday_prices(
1419+
self, area: Area,
1420+
start: pd.Timestamp,
1421+
end: pd.Timestamp,
1422+
sequence: int,
1423+
offset: int = 0) -> pd.Series:
1424+
text = super(EntsoePandasClient, self).query_intraday_prices(
1425+
area,
1426+
start=start,
1427+
end=end,
1428+
offset=offset,
1429+
sequence=sequence
1430+
)
1431+
series = parse_prices(text)['15min']
1432+
series = series.tz_convert(area.tz).sort_index()
1433+
series = series.truncate(before=start, after=end)
1434+
# because of the above fix we need to check again if any valid data exists after truncating
1435+
if len(series) == 0:
1436+
raise NoMatchingDataError
1437+
return series
1438+
13501439
# we need to do offset, but we also want to pad the days so wrap it in an internal call
13511440
def query_day_ahead_prices_local(
13521441
self, country_code: Union[Area, str],

0 commit comments

Comments
 (0)