Skip to content

Commit fbed1cf

Browse files
authored
Update simple_moving_average.py
Add ValueError: Ensure window size is smaller than the total length of the time series
1 parent 4841828 commit fbed1cf

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

financial/simple_moving_average.py

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ def simple_moving_average(
3434
if window_size < 1:
3535
raise ValueError("Window size must be a positive integer")
3636

37+
if window_size > len(data):
38+
raise ValueError("Window size must be smaller than the total length of the time series")
39+
3740
sma: list[float | None] = []
3841

3942
for i in range(len(data)):

0 commit comments

Comments
 (0)