Skip to content

Instantly share code, notes, and snippets.

View deephavendatalabs's full-sized avatar

Deephaven Data Labs deephavendatalabs

View GitHub Profile
@deephavendatalabs
deephavendatalabs / OMS2.py
Last active September 10, 2020 10:27
OMS Project
from deephaven import InputTable, TableInputHandler
namespace = 'OMSExample'
tradeTableName = 'Trades'
# Create the input table if it doesn’t exist
if not db.hasTable(namespace, tradeTableName):
InputTable.newInputTable(db, namespace, tradeTableName,
TableInputHandler.c("Symbol", "java.lang.String"),
TableInputHandler.cKey("Timestamp", "com.illumon.iris.db.tables.utils.DBDateTime"),
@deephavendatalabs
deephavendatalabs / OMS.py
Created August 27, 2020 13:49
OMS Project
orders = (
db.i('FeedOS', 'EquityQuoteL1').where("Date = currentDateNy()")
.update("rand = Math.random()", "Buy = rand > 0.9999", "Sell = rand < 0.0001")
.where("Buy = true || Sell = true")
.update("Shares = Buy ? (int) Math.round(Math.random() * 100) : (int) Math.round(Math.random() * -100)")
.view("Date", "Timestamp", "Symbol = LocalCodeStr", "Bid", "Ask", "Shares")
)
def unifrac(samp1, samp2, classes):
t1 = origTable.where(f"!({samp1}==0 && {samp2}==0)")\
.view(samp1, samp2, "Taxonomy=Silva_Taxonomy+`;`+Name")\
.update("Taxonomy = (String)fixTaxonomy.call(Taxonomy)",\
"TaxArr = (String[])getTaxArr.call(Taxonomy)",\
"Len = TaxArr.length")
for i, c in enumerate(classes):
t1 = t1.update(f"{c} = Len<{i+1} ? null : TaxArr[{i}]")
def jsd(samp1, samp2, pseudo):
t1 = pseudo.update(f"m = ({samp1} + {samp2}) / 2",\
f"kld1 = {samp1} * log({samp1} / m)",\
f"kld2 = {samp2} * log({samp2} / m)")\
.by(AggCombo(AggSum("kld1", "kld2")))\
.update("divergence = (0.5*kld1) + (0.5*kld2)")
return t1.getColumn("divergence").get(0)
from deephaven import *
client = PersistentQueryTableHelper.getClientForPersistentQuery(3*60*1000, owner="noormalik", name="EarningsCallSentimentAnalysis")
callPredictions = PersistentQueryTableHelper.getPreemptiveTableFromPersistentQuery("callPredictionsPre", helper=client)
# Run the following to get java details: R CMD javareconf
Sys.setenv(JAVA_HOME =
'/Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk/Contents/Home/')
source(sprintf("%s/iris/.programfiles/%s/integrations/r/irisdb.R",home,system))
idb.init(devroot = sprintf("%s/iris/.programfiles/%s/",home,system),
workspace = sprintf("%s/iris/workspaces/%s/workspaces/r/",home,system),
propfile = "iris-common.prop",
userHome = home,
keyfile = keyfile,
home <- "/Users/username"
system <- "Deephaven New"
keyfile <- sprintf("%s/priv.dh-demo.base64.txt",home)
workerHeapGB <- 4
jvmHeapGB <- 2
workerHost <- "dh-demo-query1.int.illumon.com"
---
title: "StudentsPerformance"
output: html_document
---
# Introduction
This project uses a public, synthesized exam scores dataset from Kaggle to analyze
the average scores in each subject relative to the student's parents' level of
education and whether the student took a preparation course before the exam.
@deephavendatalabs
deephavendatalabs / manning9.py
Created August 7, 2020 20:22
Peyton Manning Seasonal Dataset
# To see where the trend changes, we can add changepoints
add_changepoints_to_plot(fig1.gca(), m, forecast)
@deephavendatalabs
deephavendatalabs / manning8.py
Created August 7, 2020 20:22
Peyton Manning Seasonal Dataset
def prophet_plot(df):
m = Prophet()
m.fit(df)
# Make a forecast dataframe 1 year ahead
future = m.make_future_dataframe(periods=365)
forecast = m.predict(future)
# Return forecasted data, & component breakdown of forecasts