A portfolio line describes volumes and prices for a certain commodity (gas, power, heat) in a certain market. This determines many things, and with this class these properties are bundled.
The class should be an optional parameter in the PfLine creation, and can be used in various ways outlined below. If it's not provided, the code should (mostly) work as it does currently.
Branche commodity
First tackle this issue after considering this one and learning about pint and its UnitRegistry.
@dataclass(
class Commodity:
name : str
_: dataclasses.KW_ONLY
tz : str = None # timezone. If not provided, assume tz-agnostic.
spotfreq : str # frequency of the spot market. In pfstate, suppress the warnings related to changing the unsourced volume if the pfline frequency is equal to this frequency, and make the warning stronger-worded if it's unequal.
start_of_day: dt.time = None # if not provided, assume midnight. Used at initialisation; the start-of-day of the passed data is checked against this value.
peak_fn: tools.peakperiod.PeakFunction = None # is used for `.po()` and `.hedge_with()` methods (these methods probably need to be rewritten). If no commodity is specified or if the `.is_peak` property of the class is not specified, calling the `.po()` method should raise an error, and the `po` argument of the `.hedge_with()` method should be ignored (and hedging should always be done with uniform power).
w : str | pint.Unit # unit for power.
q: str | ... # for energy.
p: str | ... # for price.
r : str | ... # for revenue.
Concerning the units:
The units are used: (a) when printing the object, (b) when initialising the object (if no explicit unit is present, this unit is assumed; if a unit is present, it's converted to this unit). These units should be compatible - the dimensionality of the w should be energy per time, etc. This should be checked when the Commodity is initialised. It is not necessary that the units used for currency and energy are the same, e.g. the units are still compatible if e.g. .q = MWh, .r = Eur, .p = ctEur/kWh. However, it is necessary they can be converted into one another, so the units are not compatible if e.g. .q = MWh, .r = Eur, .p = USD/MWh.
It might be necessary to create a pint.UnitRegistry for each Commodity. This has the advantage that 2 commodities can have distinct currency units. However, it also means that 2 PfLines cannot be added/combined unless they are from the same commodity. So, a volume-only PfLine with commodity germanpower cannot be added to a volume-only PfLine with commodity germangas, even if all of their units are the same.
A portfolio line describes volumes and prices for a certain commodity (gas, power, heat) in a certain market. This determines many things, and with this class these properties are bundled.
The class should be an optional parameter in the
PfLine
creation, and can be used in various ways outlined below. If it's not provided, the code should (mostly) work as it does currently.Branche
commodity
First tackle this issue after considering this one and learning about
pint
and itsUnitRegistry
.Concerning the units:
The units are used: (a) when printing the object, (b) when initialising the object (if no explicit unit is present, this unit is assumed; if a unit is present, it's converted to this unit). These units should be compatible - the dimensionality of the
w
should beenergy per time
, etc. This should be checked when the Commodity is initialised. It is not necessary that the units used for currency and energy are the same, e.g. the units are still compatible if e.g..q = MWh
,.r = Eur
,.p = ctEur/kWh
. However, it is necessary they can be converted into one another, so the units are not compatible if e.g..q = MWh
,.r = Eur
,.p = USD/MWh
.It might be necessary to create a
pint.UnitRegistry
for each Commodity. This has the advantage that 2 commodities can have distinct currency units. However, it also means that 2 PfLines cannot be added/combined unless they are from the same commodity. So, a volume-only PfLine with commoditygermanpower
cannot be added to a volume-only PfLine with commoditygermangas
, even if all of their units are the same.Tackle this after doing https://github.com/rwijtvliet/portfolyo/issues/88