ohlcPlot
The ohlcPlot
method creates open, high, low, close (OHLC) plots using data from tables.
Syntax
ohlcPlot(seriesName, t, time, open, high, low, close)
ohlcPlot(seriesName, time, open high, low, close)
ohlcPlot(seriesName, sds, time, open, high, low, close)
ohlcPlot(seriesName, t, time, open, high, low, close)
Parameters
Parameter | Type | Description |
---|---|---|
seriesName | String | The name you want to use to identify the series on the plot itself. |
t | table | The table that holds the data to be plotted. |
sds | SelectableDataSet | A selectable data set (e.g., OneClick filterable table). |
time | String | Column in |
time | IndexableNumericData | Time data. |
time | DateTime | Time data. |
time | Date | Time data. |
open | String | The column in |
open | IndexableNumericData | Open data. |
open | double[] | Open data. |
open | float[] | Open data. |
open | int[] | Open data. |
open | long[] | Open data. |
open | short[] | Open data. |
open | List<T> | Open data. |
open | <T>[] | Open data. |
high | String | The column in |
high | IndexableNumericData | High data. |
high | double[] | High data. |
high | float[] | High data. |
high | int[] | High data. |
high | long[] | High data. |
high | short[] | High data. |
high | List<T> | High data. |
high | <T>[] | High data. |
low | String | The column in |
low | IndexableNumericData | Low data. |
low | double[] | Low data. |
low | float[] | Low data. |
low | int[] | Low data. |
low | long[] | Low data. |
low | short[] | Low data. |
low | List<T> | Low data. |
low | <T>[] | Low data. |
close | String | The column in |
close | IndexableNumericData | Close data. |
close | double[] | Close data. |
close | float[] | Close data. |
close | int[] | Close data. |
close | long[] | Close data. |
close | short[] | Close data. |
close | List<T> | Close data. |
close | <T>[] | Close data. |
Returns
An open, high, low, close (OHLC) plot with a single axes.
Examples
The following example plots data from a Deephaven table.
import static io.deephaven.csv.CsvTools.readCsv
import static io.deephaven.api.agg.Aggregation.AggAvg
cryptoTrades = readCsv("https://media.githubusercontent.com/media/deephaven/examples/main/CryptoCurrencyHistory/CSV/CryptoTrades_20210922.csv")
agg_list = [
AggLast("CloseTime = Timestamp"),\
AggFirst("OpenTime = Timestamp"),\
AggMax("High = Price"),\
AggMin("Low = Price"),
]
btcBin = cryptoTrades.where("Instrument=`BTC/USD`").update("TimestampBin = lowerBin(Timestamp, MINUTE)")
tOHLC = btcBin.aggBy(agg_list, "TimestampBin").\
join(btcBin,"CloseTime = Timestamp","Close = Price").\
join(btcBin,"OpenTime = Timestamp","Open = Price")
plotOHLC = ohlcPlot("BTC", tOHLC, "TimestampBin", "Open", "High", "Low", "Close")\
.chartTitle("BTC OHLC - Aug 22 2021")\
.show()
- cryptoTrades
- btcBin
- tOHLC
- plotOHLC
Shared Axes
Just like XY series plots, the Open, High, Low and Close plot can also be used to present multiple series on the same chart, including the use of multiple X or Y axes. An example of this follows:
btcBin = cryptoTrades.where("Instrument=`BTC/USD`").update("TimestampBin = lowerBin(Timestamp, MINUTE)")
ethBin = cryptoTrades.where("Instrument=`ETH/USD`").update("TimestampBin = lowerBin(Timestamp, MINUTE)")
agg_list = [
AggLast("CloseTime = Timestamp"),\
AggFirst("OpenTime = Timestamp"),\
AggMax("High = Price"),\
AggMin("Low = Price"),
]
btcOHLC = btcBin.aggBy(agg_list, "TimestampBin").\
join(btcBin,"CloseTime = Timestamp","Close = Price").\
join(btcBin,"OpenTime = Timestamp","Open = Price")
ethOHLC = ethBin.aggBy(agg_list, "TimestampBin").\
join(ethBin,"CloseTime = Timestamp","Close = Price").\
join(ethBin,"OpenTime = Timestamp","Open = Price")
plotOHLC = ohlcPlot("BTC", btcOHLC, "TimestampBin", "Open", "High", "Low", "Close")\
.chartTitle("BTC and ETC OHLC - Aug 22 2021")\
.twinX()\
.ohlcPlot("ETH", ethOHLC, "TimestampBin", "Open", "High", "Low", "Close")\
.show()
- btcBin
- ethBin
- btcOHLC
- ethOHLC
- plotOHLC