Skip to content

fix: oscillation filter incorrectly removes charge blocks with 15-min…#29

Merged
bvweerd merged 1 commit intodevfrom
fix-quarter-data-loading
Mar 22, 2026
Merged

fix: oscillation filter incorrectly removes charge blocks with 15-min…#29
bvweerd merged 1 commit intodevfrom
fix-quarter-data-loading

Conversation

@bvweerd
Copy link
Copy Markdown
Owner

@bvweerd bvweerd commented Mar 22, 2026

Two bugs in _filter_oscillations caused isolated single-slot charge/discharge with quarter-hour price data while hourly data worked correctly:

  1. ref_step_h used step_durations_hours[0] (the partial first step) instead of the full interval step. When the optimizer runs 1-2 min before a price boundary, this inflated lookahead_steps from 8 to ~120, covering the entire 36-h horizon instead of the intended 2-h window.

  2. The filter broke on the nearest discharge found in the window. An intermediate discharge with a low spread caused the preceding charge to be removed, even when a profitable discharge existed slightly further in the same window.

Fix 1: use step_durations_hours[1] as ref_step_h (the representative full interval), keeping lookahead_steps at 8 steps for 15-min data.

Fix 2: scan all discharges (charges) within the window; only suppress a charge (discharge) step if no profitable pairing exists anywhere in the window. True rapid oscillations with no profitable match are still correctly removed.

Adds three regression tests covering both scenarios.

https://claude.ai/code/session_01FCR1z6MBtoa5AdEtEi352T

Description

Type of change

  • fix: Bug fix (patch version bump)
  • feat: New feature (minor version bump)
  • feat!: / BREAKING CHANGE: Breaking change (major version bump)
  • chore: / docs: / ci: Maintenance or documentation (no version bump)

Checklist

  • Commit title follows Conventional Commits (feat:, fix:, chore:, etc.)
  • Tests added or updated where applicable
  • Documentation updated if needed
  • CI is green
  • PR targets the dev branch (not main, unless this is a hotfix)

Screenshots / Logs (optional)

… price data

Two bugs in _filter_oscillations caused isolated single-slot charge/discharge
with quarter-hour price data while hourly data worked correctly:

1. ref_step_h used step_durations_hours[0] (the partial first step) instead
   of the full interval step. When the optimizer runs 1-2 min before a price
   boundary, this inflated lookahead_steps from 8 to ~120, covering the entire
   36-h horizon instead of the intended 2-h window.

2. The filter broke on the *nearest* discharge found in the window. An
   intermediate discharge with a low spread caused the preceding charge to be
   removed, even when a profitable discharge existed slightly further in the
   same window.

Fix 1: use step_durations_hours[1] as ref_step_h (the representative full
interval), keeping lookahead_steps at 8 steps for 15-min data.

Fix 2: scan all discharges (charges) within the window; only suppress a
charge (discharge) step if no profitable pairing exists anywhere in the window.
True rapid oscillations with no profitable match are still correctly removed.

Adds three regression tests covering both scenarios.

https://claude.ai/code/session_01FCR1z6MBtoa5AdEtEi352T
@github-actions github-actions Bot added enhancement New feature or improvement bug Something isn't working as expected labels Mar 22, 2026
@bvweerd bvweerd merged commit efa462b into dev Mar 22, 2026
5 checks passed
@bvweerd bvweerd deleted the fix-quarter-data-loading branch March 22, 2026 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working as expected enhancement New feature or improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants