Skip to content

Conversation

@linssendane
Copy link
Contributor

@linssendane linssendane commented Aug 29, 2025

  • Add xmltodict dependency for robust XML parsing
  • Add convert_balancing_state_data_to_dataframe() function with proper timezone handling
  • Add helper functions for XML document validation and extraction of more metadata
  • Update query_current_balancing_state() to use dedicated parser instead of parse_imbalance_volumes
  • Handle 1-minute resolution data correctly with proper timestamp calculation

- Add xmltodict dependency for robust XML parsing
- Add parse_balancing_state_xml() function following market-data-platform pattern
- Add convert_balancing_state_data_to_dataframe() function with proper timezone handling
- Add helper functions for XML document validation and metadata extraction
- Update query_current_balancing_state() to use dedicated parser instead of parse_imbalance_volumes
- Remove incorrect -1 multiplication that treated balancing state as imbalance data
- Improve docstring with detailed parameter descriptions and notes
- Handle 1-minute resolution data correctly with proper timestamp calculation
- Add comprehensive error handling for missing XML elements

This implements the Current Balancing State functionality following the same
pattern as the market-data-platform implementation, using xmltodict for parsing
and proper timezone handling with tz_localize('UTC') and tz_convert().
@linssendane linssendane marked this pull request as ready for review August 29, 2025 14:27
@linssendane linssendane marked this pull request as draft August 29, 2025 14:47
@linssendane
Copy link
Contributor Author

from entsoe import EntsoePandasClient
import pandas as pd

client = EntsoePandasClient(api_key="xxx")

df = client.query_current_balancing_state(
    country_code="BE", 
    start=pd.Timestamp("2025-01-01", tz="Europe/Brussels"),  
    end=pd.Timestamp("2025-01-02", tz="Europe/Brussels"),
)

print(df)

Result:

                           quantity                              mrid flow_direction quantity_unit curve_type cancelled_ts revision_number      created_datetime
timestamp                                                                                                                                                       
2025-01-01 00:00:00+01:00   -130.52  fa3d63616ef74ec693c7b033e8440efb            A02           MAW        A03         None               1  2025-09-02T12:02:24Z
2025-01-01 00:01:00+01:00    -41.17  fa3d63616ef74ec693c7b033e8440efb            A02           MAW        A03         None               1  2025-09-02T12:02:24Z
2025-01-01 00:02:00+01:00     29.45  fa3d63616ef74ec693c7b033e8440efb            A01           MAW        A03         None               1  2025-09-02T12:02:24Z
2025-01-01 00:03:00+01:00     15.50  fa3d63616ef74ec693c7b033e8440efb            A01           MAW        A03         None               1  2025-09-02T12:02:24Z
2025-01-01 00:04:00+01:00    -20.44  fa3d63616ef74ec693c7b033e8440efb            A02           MAW        A03         None               1  2025-09-02T12:02:24Z
...                             ...                               ...            ...           ...        ...          ...             ...                   ...
2025-01-01 23:55:00+01:00   -131.75  fa3d63616ef74ec693c7b033e8440efb            A02           MAW        A03         None               1  2025-09-02T12:02:24Z
2025-01-01 23:56:00+01:00    -81.06  fa3d63616ef74ec693c7b033e8440efb            A02           MAW        A03         None               1  2025-09-02T12:02:24Z
2025-01-01 23:57:00+01:00     14.13  fa3d63616ef74ec693c7b033e8440efb            A01           MAW        A03         None               1  2025-09-02T12:02:24Z
2025-01-01 23:58:00+01:00     99.02  fa3d63616ef74ec693c7b033e8440efb            A01           MAW        A03         None               1  2025-09-02T12:02:24Z
2025-01-01 23:59:00+01:00    176.19  fa3d63616ef74ec693c7b033e8440efb            A01           MAW        A03         None               1  2025-09-02T12:02:24Z

[1439 rows x 8 columns]

@linssendane linssendane marked this pull request as ready for review September 2, 2025 12:05
@fboerman
Copy link
Collaborator

fboerman commented Oct 3, 2025

Hi I am sorry but what problem does this exactly solve? what is wrong with the current implementation? it seems this just reverses the sign?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants