Skip to content
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

Port MovingAverage as-is from legacy to v2 #2502

Merged
merged 1 commit into from
Jun 10, 2022

Conversation

jmao-denver
Copy link
Contributor

@jmao-denver jmao-denver commented Jun 8, 2022

Skipped creating a unit test for it but tested with the example in the docs.

from deephaven.experimental.ema import ByEmaSimple
from deephaven import time_table
import random

def random_char():
    return random.choice(['A', 'B', 'C', 'D', 'E', 'F'])

ema1sec = ByEmaSimple('BD_SKIP','BD_SKIP','TIME',10,'SECONDS', type='LEVEL')

result = time_table('00:00:01').update(formulas=["Sym = (String)random_char()", "Numbers = (int)random.randint(0, 100)"])

ema_data = result.view(formulas=["EMA_data = ema1sec.update(Timestamp, Numbers)"]).last_by()
ema_data_grouped = result.view(formulas=["Sym", "EMA_data = ema1sec.update(Timestamp, Numbers, Sym)"]).last_by(by=["Sym"]).sort(order_by=["Sym"])

Fixes #2386

py/server/deephaven/experimental/ema.py Show resolved Hide resolved


def ByEmaSimple(nullBehavior, nanBehavior, mode, timeScale, timeUnit, type=None):
"""Constructor for an engine aware Exponential Moving Average (EMA) which performs a `groupBy` ema calculation without
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""Constructor for an engine aware Exponential Moving Average (EMA) which performs a `groupBy` ema calculation without
"""Constructor for an engine aware Exponential Moving Average (EMA) which performs a `group_by` ema calculation without

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think groupBy is OK because we are talking about the operation on the server.

@jmao-denver jmao-denver merged commit 6e78c49 into deephaven:main Jun 10, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jun 10, 2022
@jmao-denver jmao-denver deleted the 2386-wrap-moving-averages branch February 8, 2023 18:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrap the moving averages in deephaven v2
3 participants