DearPyGui
DearPyGui copied to clipboard
Candle Series does not plot 1 min candle bodies
Candles with 1min time resolutions are not handled properly: the body of the candle is not plotted as shown is this example. 2min bar bodies however are properly drawn.
Here is some data and a small test that shows the problem:
import dearpygui.dearpygui as dpg
dpg.create_context()
dpg.create_viewport(title="Demo", width=1200, height=800)
dpg.setup_dearpygui()
x = [1621429200.0, 1621429260.0, 1621429320.0, 1621429380.0, 1621429440.0, 1621429500.0, 1621429560.0, 1621429620.0, 1621429680.0, 1621429740.0, 1621429800.0, 1621429860.0, 1621429920.0, 1621429980.0, 1621430040.0, 1621430100.0, 1621430160.0, 1621430220.0, 1621430280.0, 1621430340.0, 1621430400.0, 1621430460.0, 1621430520.0, 1621430580.0, 1621430640.0, 1621430700.0, 1621430760.0, 1621430820.0, 1621430880.0, 1621430940.0, 1621431000.0, 1621431060.0, 1621431120.0, 1621431180.0, 1621431240.0, 1621431300.0, 1621431360.0, 1621431420.0, 1621431480.0, 1621431540.0]
c = [35234.62, 34483.64, 34203.46, 33591.59, 32801.65, 33333.4, 32988.19, 33081.37, 32398.02, 31361.26, 30101, 31392.53, 32100, 32129.27, 32093.54, 32300.46, 33269.47, 33500, 33541.98, 34464.52, 35337.6, 35181.77, 33141.61, 33982.11, 34048.84, 34500.01, 34400, 34270.97, 34270.05, 34000, 33601.85, 34102.48, 34290.33, 34620.33, 34900.78, 35469.28, 35113.97, 35250, 35109.89, 35513.51]
o = [35226.38, 35234.62, 34483.65, 34179.61, 33591.59, 32800.47, 33358.6, 32901.09, 33084.2, 32674.76, 31361.26, 30101, 30980.33, 32180.03, 32129.27, 32103.94, 32437.76, 33269.47, 33534.58, 33540, 34475.5, 35348.35, 35299.52, 33141.61, 33982.11, 34029.01, 34500.01, 34467.85, 34270.97, 34270.05, 34000, 33601.86, 34152.69, 34290.33, 34620.33, 34900.78, 35484.44, 35112.82, 35221.98, 35114.7]
h = [35234.62, 36013.2, 34700, 34400, 33842.25, 34185.18, 33590, 33351.82, 33700, 32674.76, 31450.54, 31474.97, 32400.01, 32666, 32500, 32500, 33400, 33666, 33966, 34587.07, 35700, 35900, 35552.91, 34000, 34200, 34540.32, 35000, 34644.14, 34501.74, 34370, 34039.38, 34295.62, 34400, 34939, 35000, 35777.77, 35742.5, 35500, 35400, 35549.03]
l = [35226.38, 34000, 33972.76, 33570.38, 32500, 32641.15, 32780.98, 32667.44, 32250, 31337, 30100, 30000, 30925.82, 31750, 31200, 32000, 32200, 33044.82, 32963.04, 33499.99, 34416.47, 35180, 33000, 33000, 33600, 33590.85, 34200.1, 34000, 33662.52, 33788.17, 33500, 33500.04, 33703.05, 33871.99, 34457.77, 34800, 35000, 35000, 35000, 35068.32]
# artificially create a 2min bar spacing
xx = [t+i*1*60 for i, t in enumerate(x)]
# do the gui layout
with dpg.window(tag="main_window"):
with dpg.plot(label="Candle Series", height=500, width=-1):
dpg.add_plot_legend()
xaxis = dpg.add_plot_axis(dpg.mvXAxis, label="Day", time=True)
with dpg.plot_axis(dpg.mvYAxis, label="USDT"):
dpg.add_line_series(x, o, label="open")
dpg.add_line_series(x, c, label="close")
dpg.add_line_series(x, h, label="high")
dpg.add_line_series(x, l, label="low")
dpg.add_candle_series(x, opens=o, closes=c, highs=h, lows=l, label="Bar-BTCUSDT")
dpg.fit_axis_data(dpg.top_container_stack())
dpg.fit_axis_data(xaxis)
with dpg.plot(label="Candle Series", height=500, width=-1):
dpg.add_plot_legend()
xaxis = dpg.add_plot_axis(dpg.mvXAxis, label="Day", time=True)
with dpg.plot_axis(dpg.mvYAxis, label="USDT"):
dpg.add_line_series(xx, o, label="open")
dpg.add_line_series(xx, c, label="close")
dpg.add_line_series(xx, h, label="high")
dpg.add_line_series(xx, l, label="low")
dpg.add_candle_series(xx, opens=o, closes=c, highs=h, lows=l, label="Bar-BTCUSDT", )
dpg.fit_axis_data(dpg.top_container_stack())
dpg.fit_axis_data(xaxis)
dpg.show_viewport()
dpg.set_primary_window("main_window", True)
dpg.start_dearpygui()
dpg.destroy_context()
Would be great if it could be fixed. Also for bars with less than 1min resolution, e.g. as needed for instance in HFT.
Regarding the documentation it would be good to clarify if the order of the values in set_values for a candle series is as in the
add_candle_series i.e.
dpg.set_value(self.series_tag(update.key), [update.time, update.open, update.close, update.low, update.high])
Version of Dear PyGui
Version: 1.4.0 Operating System: macOs 11.5.2
We are working on revamping the candle series for the next release!