Add two-day amplitude window to amp-stats.

For each settlement day, also compute H-L over start minus one day through 16:00 (e.g. 25 16:00 to 27 16:00).

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-28 15:05:38 +08:00
parent c81ba147cc
commit 26bc19f047
5 changed files with 147 additions and 25 deletions
+8
View File
@@ -34,6 +34,14 @@ class AmpStatsLibTests(unittest.TestCase):
self.assertEqual(start.strftime("%Y-%m-%d %H:%M"), "2026-07-22 08:00")
self.assertEqual(end.strftime("%Y-%m-%d %H:%M"), "2026-07-22 16:00")
def test_window_two_day_16_to_16(self):
# 结算 27 日 → 两日窗 25日16:00 → 27日16:00
start, end = window_bounds_for_settlement(date(2026, 7, 27), 16, span_days=2)
self.assertEqual(start.strftime("%Y-%m-%d %H:%M"), "2026-07-25 16:00")
self.assertEqual(end.strftime("%Y-%m-%d %H:%M"), "2026-07-27 16:00")
one_start, _ = window_bounds_for_settlement(date(2026, 7, 27), 16, span_days=1)
self.assertEqual(one_start.strftime("%Y-%m-%d %H:%M"), "2026-07-26 16:00")
def test_settlement_excludes_incomplete_today(self):
now = datetime(2026, 7, 22, 10, 0, tzinfo=TZ)
days = list_settlement_dates(sample_days=3, now=now)