Package: bdew-datetimes
bdew_datetimesA collection of utils to work with datetimes and holidays in the German energy
market and is based on thepython-holidaypackage.The implementation considers the publications of theBDEW(Bundesverband der Energie- und Wasserwirtschaft e. V.) andEDI@Energy, which provide boundaries and guidance for the data exchange on the german energy market.Current highlights:BDEW-holiday calendarallows dict like evaluation of dates and datetimes and contains all holidays considered by the BDEWStatutory Periods ("Gesetzliche Fristen")calculate dates of the kind "x Werktage ab Stichtag"calculate dates of the kind "nter Werktag des Fristen- bzw. Liefermonats"Gas-Day / Market Day evaluationFuture Scope:providing subdivision holiday calendars to allow granular load profilesQuick Start and ExamplesInstall the package frompypi:pipinstallbdew-datetimesCheck if a date is aspecificBDEW HolidaysTheHolidaySumreturned bycreate_bdew_calendarcontains the BDEW specific holidays.
This means it contains those holidays which aredefinedby BDEW which includes Heiligabend and Silvester as well as special days without Marktkommunikation butnotthe local or nationwide holidays in Germany and its states.fromdatetimeimportdatefrombdew_datetimesimportcreate_bdew_calendarbdew_holidays=create_bdew_calendar()# this behaves like a dictassertdate(2022,12,31)inbdew_holidays# Silvester is a BDEW holidayassertdate(2022,8,8)inbdew_holidaysisFalse# Augsburger Friedensfest is _not_ a BDEW holiday (but a holiday in Augsburg only)assertdate(2022,12,2)inbdew_holidaysisFalse# The 12th of February is not a BDEW holidayprint(bdew_holidays.get('2022-01-01'))# prints "Neujahr"Theunion(typeHolidaySum) of both nation and state wide holidaysandthe BDEW holidays (only the latter is returned bycreate_bdew_calendar) is the relevant calendar for German utilities.Check if a given Date is a BDEW Working DayBDEW working days are those days taken into account for the "Fristenberechnung".
The functionis_bdew_working_dayconsiders both national and state wide holidays as well as BDEW holidays:fromdatetimeimportdatefrombdew_datetimes.periodsimportis_bdew_working_dayassertis_bdew_working_day(date(2023,1,1))isFalse# Neujahr (national holiday)assertis_bdew_working_day(date(2023,1,2))isTrue# regular weekdayassertis_bdew_working_day(date(2023,1,6))isFalse# Heilige Drei Könige (local holiday in parts of Germany)assertis_bdew_working_day(date(2023,4,7))isFalse# Karfreitag (national holiday, but based on an astronomical calendar)assertis_bdew_working_day(date(2023,12,24))isFalse# Heiligabend (BDEW holiday)You can also get the next or previous working day for any date:fromdatetimeimportdatefrombdew_datetimes.periodsimportget_next_working_day,get_previous_working_dayassertget_next_working_day(date(2023,1,1))==date(2023,1,2)# the next working day after Neujahrassertget_previous_working_day(date(2023,1,1))==date(2022,12,30)# the last working day of 2022assertget_next_working_day(date(2023,1,20))==date(2023,1,23)# the next working day after a friday is the next mondayCalculate Statutory PeriodsStatutory periods define the maximum time between e.g. the EDIFACT message for the "Anmeldung" and the actual start of supply ("Lieferbeginn").fromdatetimeimportdatefrombdew_datetimes.periodsimportDayType,EndDateType,Period,add_frist# Eingang der Anmeldung des LFN erfolgt am 04.07.2016. Der Mindestzeitraum von zehn WT# beginnt am 05.07.2016 und endet am 18.07.2016. Frühestes zulässiges Anmeldedatum# ist damit der 19.07.2016, sodass die Marktlokation dem LFN frühestens zum Beginn# des vorgenannten Tages zugeordnet wird.eingang_der_anmeldung=date(2016,7,4)gesetzliche_frist=Period(10,DayType.WORKING_DAY,end_date_type=EndDateType.EXCLUSIVE# lieferbeginn is the exclusive end of the previous supply contract)fruehest_moeglicher_lieferbeginn=add_frist(eingang_der_anmeldung,gesetzliche_frist)assertfruehest_moeglicher_lieferbeginn==date(2016,7,19)Calculate "Liefer- and Fristenmonate"Liefer- and Fristenmonat are concepts used in MaBiS and GPKE:fromdatetimeimportdatefrombdew_datetimes.periodsimportget_nth_working_day_of_month,MonthType# returns the 18th working day of the current month in Germanyget_nth_working_day_of_month(18)# the 18th working day of November 2023assertget_nth_working_day_of_month(18,start=date(2023,11,1))==date(2023,11,28)# the 42th working day of Fristenmonat July 2023assertget_nth_working_day_of_month(42,month_type=MonthType.FRISTENMONAT,start=date(2023,7,1))==date(2023,9,29)NotesThe BDEW considers all days as holidays, which are nationwide holidays and days, which are a holiday in at least one state.
Furthermore, the 24. and the 31. December are holidays as well.
Therefore, this package utilizes the composition of all available german holiday calendars and adds the two additional days.Shifting holidays to the next weekday if they fall on a weekend is currently not considered.LicenseThis library is licensed under theMITlicense, see theLICENSE file.UsersThis library is used by the following projects:Hochfrequenz Fristenkalender