from deephaven import Plot # See print(sorted(dir())) or help('deephaven') for full namespace contents. # note that we are constraining the data to NYSE business time import deephaven.Calendars as Calendars cal = Calendars.calendar("USNYSE") trades = trades.where("cal.isBusinessTime(ExchangeTimestamp)") # ************* HISTOGRAM PLOTTING ************* tHist = db.t("LearnDeephaven", "StockTrades")\ .where("Date=`2017-08-25`")\ .view("Sym", "Last", "Size", "ExchangeTimestamp") plotPriceIntervals = Plot.histPlot("AAPL", tHist.where("Sym=`AAPL`"), "Last", 10)\ .chartTitle("Price Intervals")\ .show() # ************* CATEGORY HISTOGRAM PLOTTING ************* tHist = db.t("LearnDeephaven", "StockTrades")\ .where("Date=`2017-08-25`")\ .view("Sym", "Last", "Size", "ExchangeTimestamp") catHistTradesBySym = Plot.catHistPlot("Number of Trades", tHist, "Sym")\ .chartTitle("Trades per Symbol")\ .show() # ************* PIE PLOTTING ************* tPie = db.t("LearnDeephaven", "StockTrades")\
"S1", t, "X", "Y").plotStyle("scatter").pointColor("black").pointSize(2).show() cp4 = plt.catPlot("S1", t, "X", "Y").plotStyle("area").seriesColor("red").show() cp = plt.catPlot3d("S1", t, "X", "X", "Y").show() cpBy = plt.catPlotBy("S1", t, "X", "Y", "USym").show() cpBy = plt.catPlot3dBy("S1", t, "X", "X", "Y", "USym").show() pp = plt.piePlot("S1", t, "X", "Y") chp = plt.catHistPlot("S1", t, "X").show() hp = plt.histPlot("S1", t, "X", 5).show() hp = plt.histPlot("S1", t, "X", 0, 10, 5).show() ep = plt.errorBarXY("S1", t, "X", "XLow", "XHigh", "Y", "YLow", "YHigh").show() epBy = plt.errorBarXYBy("S1", t, "X", "XLow", "XHigh", "Y", "YLow", "YHigh", "USym").show() ep2 = plt.errorBarX("S1", t, "X", "XLow", "XHigh", "Y").show() epBy2 = plt.errorBarXBy("S1", t, "X", "XLow", "XHigh", "Y", "USym").show() ep3 = plt.errorBarY("S1", t, "X", "Y", "YLow", "YHigh").show() epBy3 = plt.errorBarYBy("S1", t, "X", "Y", "YLow", "YHigh", "USym").show() doubles = [3, 4, 3, 5, 4, 5] time = 1491946585000000000 t = tt.newTable(tt.col("USym", ["A", "B", "A", "B", "A", "B"]), tt.doubleCol("Open", doubles), tt.doubleCol("High", doubles), tt.doubleCol("Low", doubles), tt.doubleCol("Close", doubles))
.chartTitle("Price Over Time")\ .show() # Category categoryPlot = Plot.catPlot("Shares Traded", totalShares, "Sym", "SharesTraded")\ .chartTitle("Total Shares")\ .show() # Pie pieChart = Plot.piePlot("Shares Traded", totalShares, "Sym", "SharesTraded")\ .chartTitle("Total Shares")\ .show() # Histogram histogram = Plot.histPlot("MSFT", trades.where("Sym=`MSFT`"), "Last", 3)\ .chartTitle("Price Intervals")\ .show() # Category Histogram catHist = Plot.catHistPlot("Number of Trades", trades, "Sym")\ .chartTitle("Trades per Symbol")\ .show() # Open, High, Low and Close ohlcPlot = Plot.ohlcPlot("MSFT", summaries.where("Ticker=`MSFT`"), "EODTimestamp", "Open", "High", "Low", "Close")\ .chartTitle("Microsoft Activity")\ .show() # Grouping Multiple Plots in the Same Figure multipleCharts = Plot.figure(2, 3)\ .figureTitle("Trade Plots")\