Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EntsoePandasClient: query_procured_balancing_capacity does not return the right time span #341

Open
danshaman05 opened this issue Sep 5, 2024 · 2 comments

Comments

@danshaman05
Copy link

danshaman05 commented Sep 5, 2024

import pandas as pd
from entsoe import EntsoePandasClient

api_key = 'your-api-key'

start_date = pd.Timestamp("2024-08-20T0000", tz='Europe/Prague')
end_date = start_date + pd.Timedelta(hours=23)

country_code = 'CZ'
type_marketagreement_type = 'A01'
contract_marketagreement_type = 'A01'
process_type = 'A47'  # mFRR

client = EntsoePandasClient(api_key)

df = client.query_procured_balancing_capacity(
            country_code,
            process_type=process_type,
            start=start_date,
            end=end_date,
            type_marketagreement_type=type_marketagreement_type)

print("number of rows:", len(df))
print(df.index)

output:

number of rows: 21
DatetimeIndex(['2024-08-20 03:00:00+02:00', '2024-08-20 04:00:00+02:00',
               '2024-08-20 05:00:00+02:00', '2024-08-20 06:00:00+02:00',
               '2024-08-20 07:00:00+02:00', '2024-08-20 08:00:00+02:00',
               '2024-08-20 09:00:00+02:00', '2024-08-20 10:00:00+02:00',
               '2024-08-20 11:00:00+02:00', '2024-08-20 12:00:00+02:00',
               '2024-08-20 13:00:00+02:00', '2024-08-20 14:00:00+02:00',
               '2024-08-20 15:00:00+02:00', '2024-08-20 16:00:00+02:00',
               '2024-08-20 17:00:00+02:00', '2024-08-20 18:00:00+02:00',
               '2024-08-20 19:00:00+02:00', '2024-08-20 20:00:00+02:00',
               '2024-08-20 21:00:00+02:00', '2024-08-20 22:00:00+02:00',
               '2024-08-20 23:00:00+02:00'],
              dtype='datetime64[ns, Europe/Prague]', freq='60min')

Note, that first three hours are missing. It should return 24 rows instead of 21.
Probably similar to issue #187.

@danshaman05
Copy link
Author

danshaman05 commented Sep 5, 2024

I noticed that this is making a lot more API requests, than is needed. The query requested for 135 xml elements (maximum is 100 per request), so ideally it should make only 2 requests.

Maybe the problem is that API expects start and end timestamps in local timezone, but ours is 'UTC'.
When I get rid of conversions of start and end timestamps in EntsoeRawClient._base_request method (conversion is in _datetime_to_str), it works like a charm. I have less requests and right time span.

output:

number of rows: 24
DatetimeIndex(['2024-08-20 00:00:00+02:00', '2024-08-20 01:00:00+02:00',
               '2024-08-20 02:00:00+02:00', '2024-08-20 03:00:00+02:00',
               '2024-08-20 04:00:00+02:00', '2024-08-20 05:00:00+02:00',
               '2024-08-20 06:00:00+02:00', '2024-08-20 07:00:00+02:00',
               '2024-08-20 08:00:00+02:00', '2024-08-20 09:00:00+02:00',
               '2024-08-20 10:00:00+02:00', '2024-08-20 11:00:00+02:00',
               '2024-08-20 12:00:00+02:00', '2024-08-20 13:00:00+02:00',
               '2024-08-20 14:00:00+02:00', '2024-08-20 15:00:00+02:00',
               '2024-08-20 16:00:00+02:00', '2024-08-20 17:00:00+02:00',
               '2024-08-20 18:00:00+02:00', '2024-08-20 19:00:00+02:00',
               '2024-08-20 20:00:00+02:00', '2024-08-20 21:00:00+02:00',
               '2024-08-20 22:00:00+02:00', '2024-08-20 23:00:00+02:00'],
              dtype='datetime64[ns, Europe/Prague]', freq='60min')

I haven't tested yet if this will affect other functions, but this could be also a solution for #187.

@fboerman fboerman changed the title EntsoePandasClient: query_day_ahead_prices does not return the right time span EntsoePandasClient: query_procured_balancing_capacity does not return the right time span Sep 18, 2024
@fboerman
Copy link
Collaborator

hi! this is very strange since all other endpoints do expect (and work with) UTC. Thus removing the conversions in the base_request will probably break a lot of things. Do you have ideas for other fixes which are more specific to this method? I dont use this endpoint myself so kinda hard to test it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants