from deephaven import time_table
from deephaven.plot.figure import Figure
from deephaven.plot import PlotStyle
from deephaven.plot import Color, Colors
from deephaven.plot import font_family_names, Font, FontStyle, Shape
data = time_table('PT00:00:01')
.update(["Open = 10*sin(0.2*ii) + 2*random()","High = Open + 1", "Low = Open - 1", "Close = Open + 0.5"])
points = data
.where("i%5 = 0")
.view(["Timestamp", "Type= i%3==0 ? `Sell` : `Buy`", "Point = i%3==0 ? High+1 : Low-1"])
plot = Figure()
.figure_title("OHLC + Points")
.plot_xy(series_name="OHLC", t=data, x="Timestamp", y_high="High", y_low="Low", y="Close")
.twin()
.axes(plot_style=PlotStyle.SCATTER)
.plot_xy(series_name="Buy", t=points.where("Type=`Buy`"), x="Timestamp", y="Point")
.plot_xy(series_name="Sell", t=points.where("Type=`Sell`"), x="Timestamp", y="Point")
.show()
Source link
lol