Skip to content

Commit

Permalink
Merge pull request #169 from p-reuber/allocations
Browse files Browse the repository at this point in the history
Added query for explicit/implicit allocations
  • Loading branch information
fboerman authored Mar 13, 2022
2 parents 4616853 + ad4fe4c commit c5ed993
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ country_code = 'BE' # Belgium
country_code_from = 'FR' # France
country_code_to = 'DE_LU' # Germany-Luxembourg
type_marketagreement_type = 'A01'
contract_marketagreement_type = 'A01'

# methods that return XML
client.query_day_ahead_prices(country_code, start, end)
Expand All @@ -42,6 +43,7 @@ client.query_net_transfer_capacity_weekahead(country_code_from, country_code_to,
client.query_net_transfer_capacity_monthahead(country_code_from, country_code_to, start, end)
client.query_net_transfer_capacity_yearahead(country_code_from, country_code_to, start, end)
client.query_intraday_offered_capacity(country_code_from, country_code_to, start, end, implicit=True)
client.query_offered_capacity(country_code_from, country_code_to, start, end, contract_marketagreement_type, implicit=True)
client.query_contracted_reserve_prices(country_code, start, end, type_marketagreement_type, psr_type=None)
client.query_contracted_reserve_amount(country_code, start, end, type_marketagreement_type, psr_type=None)
client.query_procured_balancing_capacity(country_code, start, end, process_type, type_marketagreement_type=None)
Expand Down Expand Up @@ -94,6 +96,7 @@ country_code = 'BE' # Belgium
country_code_from = 'FR' # France
country_code_to = 'DE_LU' # Germany-Luxembourg
type_marketagreement_type = 'A01'
contract_marketagreement_type = "A01"

# methods that return Pandas Series
client.query_day_ahead_prices(country_code, start=start,end=end)
Expand All @@ -105,6 +108,7 @@ client.query_net_transfer_capacity_weekahead(country_code_from, country_code_to,
client.query_net_transfer_capacity_monthahead(country_code_from, country_code_to, start, end)
client.query_net_transfer_capacity_yearahead(country_code_from, country_code_to, start, end)
client.query_intraday_offered_capacity(country_code_from, country_code_to, start, end,implicit=True)
client.query_offered_capacity(country_code_from, country_code_to, start, end, contract_marketagreement_type, implicit=True)

# methods that return Pandas DataFrames
client.query_load(country_code, start=start,end=end)
Expand Down
76 changes: 75 additions & 1 deletion entsoe/entsoe.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,13 +565,46 @@ def query_intraday_offered_capacity(
doctype="A31", contract_marketagreement_type="A07",
auction_type=("A01" if implicit==True else "A02"))

def query_offered_capacity(
self, country_code_from: Union[Area, str],
country_code_to: Union[Area, str], start: pd.Timestamp,
end: pd.Timestamp, contract_marketagreement_type: str,
implicit:bool = True,**kwargs) -> str:
"""
Allocated result documents, for OC evolution see query_intraday_offered_capacity
Parameters
----------
country_code_from : Area|str
country_code_to : Area|str
start : pd.Timestamp
end : pd.Timestamp
contract_marketagreement_type : str
type of contract (see mappings.MARKETAGREEMENTTYPE)
implicit: bool (True = implicit - default for most borders. False = explicit - for instance BE-GB)
Returns
-------
str
"""
if implicit:
business_type = None
else:
business_type = "B05"
return self._query_crossborder(
country_code_from=country_code_from,
country_code_to=country_code_to, start=start, end=end,
doctype=("A31" if implicit else "A25"),
contract_marketagreement_type=contract_marketagreement_type,
auction_type=("A01" if implicit else "A02"),
business_type=business_type)

def _query_crossborder(
self, country_code_from: Union[Area, str],
country_code_to: Union[Area, str], start: pd.Timestamp,
end: pd.Timestamp, doctype: str,
contract_marketagreement_type: Optional[str] = None,
auction_type: Optional[str] = None) -> str:
auction_type: Optional[str] = None, business_type: Optional[str] = None) -> str:
"""
Generic function called by query_crossborder_flows,
query_scheduled_exchanges, query_net_transfer_capacity_DA/WA/MA/YA and query_.
Expand All @@ -584,6 +617,7 @@ def _query_crossborder(
end : pd.Timestamp
doctype: str
contract_marketagreement_type: str
business_type: str
Returns
-------
Expand All @@ -603,6 +637,9 @@ def _query_crossborder(
if auction_type is not None:
params[
'Auction.Type'] = auction_type
if business_type is not None:
params[
'businessType'] = business_type

response = self._base_request(params=params, start=start, end=end)
return response.text
Expand Down Expand Up @@ -1404,6 +1441,43 @@ def query_intraday_offered_capacity(
ts = ts.tz_convert(area_from.tz)
ts = ts.truncate(before=start, after=end)
return ts

@year_limited
def query_offered_capacity(
self, country_code_from: Union[Area, str],
country_code_to: Union[Area, str], start: pd.Timestamp,
end: pd.Timestamp, contract_marketagreement_type: str,
implicit:bool = True,**kwargs) -> pd.Series:
"""
Allocated result documents, for OC evolution see query_intraday_offered_capacity
Note: Result will be in the timezone of the origin country --> to check
Parameters
----------
country_code_from : Area|str
country_code_to : Area|str
start : pd.Timestamp
end : pd.Timestamp
contract_marketagreement_type : str
type of contract (see mappings.MARKETAGREEMENTTYPE)
implicit: bool (True = implicit - default for most borders. False = explicit - for instance BE-GB)
Returns
-------
pd.Series
"""
area_to = lookup_area(country_code_to)
area_from = lookup_area(country_code_from)
text = super(EntsoePandasClient, self).query_offered_capacity(
country_code_from=area_from,
country_code_to=area_to,
start=start,
end=end,
contract_marketagreement_type=contract_marketagreement_type,
implicit=implicit)
ts = parse_crossborder_flows(text)
ts = ts.tz_convert(area_from.tz)
ts = ts.truncate(before=start, after=end)
return ts

@year_limited
def query_imbalance_prices(
Expand Down

0 comments on commit c5ed993

Please sign in to comment.