From 92c491a548f8eb2506396c985861dcba87c54dcf Mon Sep 17 00:00:00 2001 From: Floke Date: Mon, 9 Mar 2026 10:45:57 +0000 Subject: [PATCH] [31988f42] Feat: Added lunch break (12:00-12:30) and 2026 Bavarian holidays to slot finding logic --- lead-engine/trading_twins/manager.py | 29 ++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/lead-engine/trading_twins/manager.py b/lead-engine/trading_twins/manager.py index e63a7f67..559f6156 100644 --- a/lead-engine/trading_twins/manager.py +++ b/lead-engine/trading_twins/manager.py @@ -102,8 +102,25 @@ def find_slots(start, view, interval): """ Parses availability string: '0'=Free, '2'=Busy. Returns 2 free slots (start times) within business hours (09:00 - 16:30), - excluding weekends (Sat/Sun), with approx. 3 hours distance between them. + excluding weekends (Sat/Sun), lunch breaks, and holidays. """ + # Hardcoded Bavarian Holidays for 2026 (Common in Munich) + HOLIDAYS_2026 = { + (1, 1), # Neujahr + (1, 6), # Heilige Drei Könige + (4, 3), # Karfreitag + (4, 6), # Ostermontag + (5, 1), # Maifeiertag + (5, 14), # Christi Himmelfahrt + (5, 25), # Pfingstmontag + (6, 4), # Fronleichnam + (8, 15), # Mariä Himmelfahrt + (10, 3), # Tag der Deutschen Einheit + (11, 1), # Allerheiligen + (12, 25), # 1. Weihnachtstag + (12, 26) # 2. Weihnachtstag + } + slots = [] first_slot = None @@ -116,7 +133,15 @@ def find_slots(start, view, interval): # 1. Mon-Fri only # 2. Business hours (09:00 - 16:30) # 3. Future only - if slot_time.weekday() < 5 and (9 <= slot_time.hour < 17) and slot_time > datetime.now(TZ_BERLIN): + # 4. No Holidays (Bavaria) + # 5. Lunch break (12:00 - 12:30) + + is_holiday = (slot_time.month, slot_time.day) in HOLIDAYS_2026 + is_weekend = slot_time.weekday() >= 5 + is_lunch = 12 == slot_time.hour and slot_time.minute < 30 + is_business_hours = 9 <= slot_time.hour < 17 + + if not is_weekend and not is_holiday and not is_lunch and is_business_hours and slot_time > datetime.now(TZ_BERLIN): # Max start time 16:30 if slot_time.hour == 16 and slot_time.minute > 30: continue