-
-
Notifications
You must be signed in to change notification settings - Fork 49.2k
Adds exponential moving average algorithm #10273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
a33bc05
acdc0a2
1ce781f
7b09aeb
040379f
6edf6e5
68c4bb8
ce8ecce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,72 @@ | ||||||||||||
| """ | ||||||||||||
| Calculates exponential moving average (EMA) on the series of numbers | ||||||||||||
| Wikipedia Reference: https://en.wikipedia.org/wiki/Exponential_smoothing | ||||||||||||
| Reference: https://www.investopedia.com/terms/e/ema.asp#toc-what-is-an-exponential-moving-average-ema | ||||||||||||
|
||||||||||||
| Reference: https://www.investopedia.com/terms/e/ema.asp#toc-what-is-an-exponential-moving-average-ema | |
| https://www.investopedia.com/terms/e/ema.asp#toc-what-is-an-exponential-moving-average-ema |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just plain series is fine.
| series_generator: Iterator[float], window_size: int | |
| series: Iterator[float], window_size: int |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just easier to read...
| >>> list(exponential_moving_average((ele for ele in [2, 5, 3, 8.2, 6, 9, 10]), 3)) | |
| >>> list(exponential_moving_average(iter([2, 5, 3, 8.2, 6, 9, 10]), 3)) |
cclauss marked this conversation as resolved.
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| t = 0 | |
| timestamp = 0 |
Or maybe even better, ticks.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| st = None | |
| st = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
cclauss marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
cclauss marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| test_generator = (ele for ele in test_series) | |
| test_window_size = 3 | |
| result = exponential_moving_average(test_generator, test_window_size) | |
| test_window_size = 3 | |
| result = exponential_moving_average(series=iter(test_series), window_size=test_window_size) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Active tense