|
| 1 | +# License: MIT |
| 2 | +# Copyright © 2024 Frequenz Energy-as-a-Service GmbH |
| 3 | + |
| 4 | +"""Delivery area information for the energy market.""" |
| 5 | + |
| 6 | +import enum |
| 7 | +from dataclasses import dataclass |
| 8 | + |
| 9 | + |
| 10 | +@enum.unique |
| 11 | +class EnergyMarketCodeType(enum.Enum): |
| 12 | + """The identification code types used in the energy market. |
| 13 | +
|
| 14 | + CodeType specifies the type of identification code used for uniquely |
| 15 | + identifying various entities such as delivery areas, market participants, |
| 16 | + and grid components within the energy market. |
| 17 | +
|
| 18 | + This enumeration aims to |
| 19 | + offer compatibility across different jurisdictional standards. |
| 20 | +
|
| 21 | + Note: Understanding Code Types |
| 22 | + Different regions or countries may have their own standards for uniquely |
| 23 | + identifying various entities within the energy market. For example, in |
| 24 | + Europe, the Energy Identification Code (EIC) is commonly used for this |
| 25 | + purpose. |
| 26 | +
|
| 27 | + Note: Extensibility |
| 28 | + New code types can be added to this enum to accommodate additional regional |
| 29 | + standards, enhancing the API's adaptability. |
| 30 | +
|
| 31 | + Danger: Validation Required |
| 32 | + The chosen code type should correspond correctly with the `code` field in |
| 33 | + the relevant message objects, such as `DeliveryArea` or `Counterparty`. |
| 34 | + Failure to match the code type with the correct code could lead to |
| 35 | + processing errors. |
| 36 | + """ |
| 37 | + |
| 38 | + UNSPECIFIED = 0 |
| 39 | + """Unspecified type. This value is a placeholder and should not be used.""" |
| 40 | + |
| 41 | + EUROPE_EIC = 1 |
| 42 | + """European Energy Identification Code Standard.""" |
| 43 | + |
| 44 | + US_NERC = 2 |
| 45 | + """North American Electric Reliability Corporation identifiers.""" |
| 46 | + |
| 47 | + |
| 48 | +@dataclass(frozen=True, kw_only=True) |
| 49 | +class DeliveryArea: |
| 50 | + """A geographical or administrative region where electricity deliveries occur. |
| 51 | +
|
| 52 | + DeliveryArea represents the geographical or administrative region, usually defined |
| 53 | + and maintained by a Transmission System Operator (TSO), where electricity deliveries |
| 54 | + for a contract occur. |
| 55 | +
|
| 56 | + The concept is important to energy trading as it delineates the agreed-upon delivery |
| 57 | + location. Delivery areas can have different codes based on the jurisdiction in |
| 58 | + which they operate. |
| 59 | +
|
| 60 | + Note: Jurisdictional Differences |
| 61 | + This is typically represented by specific codes according to local jurisdiction. |
| 62 | +
|
| 63 | + In Europe, this is represented by an |
| 64 | + [EIC](https://en.wikipedia.org/wiki/Energy_Identification_Code) (Energy |
| 65 | + Identification Code). [List of |
| 66 | + EICs](https://www.entsoe.eu/data/energy-identification-codes-eic/eic-approved-codes/). |
| 67 | + """ |
| 68 | + |
| 69 | + code: str | None |
| 70 | + """The code representing the unique identifier for the delivery area.""" |
| 71 | + |
| 72 | + code_type: EnergyMarketCodeType | int |
| 73 | + """Type of code used for identifying the delivery area itself. |
| 74 | +
|
| 75 | + This code could be extended in the future, in case an unknown code type is |
| 76 | + encountered, a plain integer value is used to represent it. |
| 77 | + """ |
| 78 | + |
| 79 | + def __str__(self) -> str: |
| 80 | + """Return a human-readable string representation of this instance.""" |
| 81 | + code = self.code or "<NO CODE>" |
| 82 | + code_type = ( |
| 83 | + f"type={self.code_type}" |
| 84 | + if isinstance(self.code_type, int) |
| 85 | + else self.code_type.name |
| 86 | + ) |
| 87 | + return f"{code}[{code_type}]" |
0 commit comments