We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 040379f commit 6edf6e5Copy full SHA for 6edf6e5
financial/exponential_moving_average.py
@@ -43,13 +43,13 @@ def exponential_moving_average(
43
t = 0
44
45
# Exponential average at timestamp t
46
- st = None
+ st = 0.0
47
48
for xt in series_generator:
49
if t <= window_size:
50
# Assigning simple moving average till the window_size for the first time
51
# is reached
52
- st = float(xt) if st is None else (st + xt) * 0.5
+ st = float(xt) if t == 0 else (st + xt) * 0.5
53
else:
54
# Calculating exponential moving average based on current timestamp data
55
# point and previous exponential average value
0 commit comments