Skip to content

Commit

Permalink
fixed parsing of activated balancing energy by adding reserve type co…
Browse files Browse the repository at this point in the history
…lumn

addresses #284
  • Loading branch information
fboerman committed Jan 26, 2024
1 parent 4b6ffe6 commit 3a0e33b
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions entsoe/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,26 +525,37 @@ def _parse_activated_balancing_energy_prices_timeseries(soup) -> pd.DataFrame:
-------
pd.DataFrame
"""
direction = {
direction_options = {
'A01': 'Up',
'A02': 'Down'
}

flow_direction = direction[soup.find('flowdirection.direction').text]
reserve_type_options = {
'A95': 'FCR',
'A96': 'aFRR',
'A97': 'mFRR',
'A98': 'RR'
}


flow_direction = direction_options[soup.find('flowdirection.direction').text]
reserve_type = reserve_type_options[soup.find('businesstype').text]
period = soup.find('period')
start = pd.to_datetime(period.find('timeinterval').find('start').text)
end = pd.to_datetime(period.find('timeinterval').find('end').text)
resolution = _resolution_to_timedelta(period.find('resolution').text)
tx = pd.date_range(start=start, end=end, freq=resolution, inclusive='left')

df = pd.DataFrame(index=tx, columns=['Price', 'Direction'])
df = pd.DataFrame(index=tx, columns=['Price', 'Direction', 'ReserveType'])

for point in period.find_all('point'):
idx = int(point.find('position').text)
df.loc[tx[idx-1], 'Price'] = float(point.find('activation_price.amount').text)
df.loc[tx[idx-1], 'Direction'] = flow_direction
df.loc[tx[idx - 1], 'ReserveType'] = reserve_type

df.fillna(method='ffill', inplace=True)
#df.fillna(method='ffill', inplace=True)
df = df.infer_objects(copy=False).ffill()
return df

def _parse_imbalance_prices_timeseries(soup) -> pd.DataFrame:
Expand Down

0 comments on commit 3a0e33b

Please sign in to comment.