dalsi pokusy
Some checks failed
CI and deploy / migration-check (push) Failing after 11s
CI and deploy / deploy (push) Has been skipped

This commit is contained in:
Dusan Vojacek
2026-05-23 00:06:30 +02:00
parent 8845350c0b
commit a52be1b792
5 changed files with 119 additions and 12 deletions

View File

@@ -2198,6 +2198,44 @@ class SitePowerCapTests(unittest.TestCase):
class PlannerArbitrageImprovementsTests(unittest.TestCase):
"""Regrese: záporný buy, peak sell před sell<0, večerní export cap."""
def test_pre_neg_peak_ignores_earlier_day_in_horizon(self) -> None:
"""Horizont přes půlnoc: peak je na dni záporného sell, ne včerejší večer."""
base = datetime(2026, 5, 22, 18, 0, tzinfo=timezone.utc)
slots = [
PlanningSlot(
interval_start=base,
buy_price=4.0,
sell_price=4.6,
pv_a_forecast_w=0,
pv_b_forecast_w=0,
load_baseline_w=1000,
ev1_connected=False,
ev2_connected=False,
),
PlanningSlot(
interval_start=base + timedelta(hours=12),
buy_price=4.0,
sell_price=3.06,
pv_a_forecast_w=3000,
pv_b_forecast_w=0,
load_baseline_w=1000,
ev1_connected=False,
ev2_connected=False,
),
PlanningSlot(
interval_start=base + timedelta(hours=12, minutes=45),
buy_price=0.5,
sell_price=-0.1,
pv_a_forecast_w=5000,
pv_b_forecast_w=0,
load_baseline_w=1000,
ev1_connected=False,
ev2_connected=False,
),
]
first_neg = 2
self.assertEqual(_pre_neg_peak_sell_idx(slots, first_neg), 1)
def test_pre_neg_peak_idx_is_highest_positive_sell(self) -> None:
base = datetime(2026, 5, 23, 4, 0, tzinfo=timezone.utc)
slots = [