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

Wrap the moving averages in deephaven v2 #2386

Closed
jmao-denver opened this issue May 13, 2022 · 3 comments · Fixed by #2502
Closed

Wrap the moving averages in deephaven v2 #2386

jmao-denver opened this issue May 13, 2022 · 3 comments · Fixed by #2502
Assignees
Labels
feature request New feature or request
Milestone

Comments

@jmao-denver
Copy link
Contributor

jmao-denver commented May 13, 2022

The MovingAverages is supported in legacy and documented. It needs to be migrated to the new API.

from deephaven_legacy.MovingAverages import ByEmaSimple
from deephaven import time_table
import random

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

result = time_table('00:00:01').update(formulas=["Sym = (char)(int)random.randint(65, 70)", "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"])

It seems to me that during formula evaluation this will lead to a round-trip from Java to Python then back just to call 'ema1sec.update' if we wrap the result of 'ByEmaSimple' call in Python. What we want is to unwrap 'ema1sec' during formula parsing and generate evaluation code with the wrapped Java object.

The more generalized solution for minimizing Python/Java boundary crossing is to be addressed by #2363

@jmao-denver jmao-denver added the feature request New feature or request label May 13, 2022
@jmao-denver jmao-denver added this to the May 2022 milestone May 13, 2022
@jmao-denver jmao-denver self-assigned this May 13, 2022
@jmao-denver jmao-denver modified the milestones: May 2022, Backlog May 18, 2022
@jmao-denver
Copy link
Contributor Author

Per Pete, the design and implementation of MAs are to be reworked soon, we should definitely wait for that to be done first before take up this ticket.

@jmao-denver jmao-denver modified the milestones: Backlog, Jun 2022 Jun 8, 2022
@jmao-denver
Copy link
Contributor Author

this ticket has been converted to a minimal port of the MA implementation in legacy to V2.

@jmao-denver
Copy link
Contributor Author

jmao-denver commented Jun 8, 2022

Almost a one to one port, the 1st line in the code block is the only change required.

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"])

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant