def __init__(self): super().__init__() self.setWindowTitle("QGraphicsView") layout = QGridLayout() self.setLayout(layout) self.resize(800, 300) self.ws = BinanceFutureWebsocket() plots = {} fplt.y_pad = 0.07 # pad some extra (for control panel) fplt.max_zoom_points = 7 fplt.autoviewrestore() self.ax, self.ax_rsi = fplt.create_plot('Complicated Binance Futures Example', rows=2, init_zoom_periods=3000) self.axo = self.ax.overlay() layout.addWidget(self.ax.vb.win, 0, 0) self.ax_rsi.hide() self.ax_rsi.vb.setBackgroundColor(None) # don't use odd background color self.ax.set_visible(xaxis=True) self.symbol = "BTCUSDT" self.interval = "1m" self.change_asset() fplt.timer_callback(self.realtime_update_plot, 1) # update every second fplt.show(qt_exec=False)
def drawCandleStickChart(timestamp, openVal, high, low, closeVal, volume, exchange, symbol): # create two plots ax = fplt.create_plot(exchange + '-' + symbol, rows=1) # plot candle sticks candles = [timestamp, openVal, closeVal, high, low] fplt.candlestick_ochl(candles, ax=ax) # # put an MA on the close price # fplt.plot(timestamp, closeVal.rolling(25).mean(), ax=ax, legend='ma-25') # overlay volume on the top plot volumes = [timestamp, openVal, closeVal, volume] fplt.volume_ocv(volumes, ax=ax.overlay()) # restore view (X-position and zoom) if we ever run this example again fplt.autoviewrestore() # we're done fplt.show()
#fplt.plot(df['time'], maxim, ax=ax, legend='maxim') #fplt.plot(df['time'], minim, ax=ax, legend='minim') # draw second plot for i, window in enumerate(windows): if (i < 5): fplt.plot(df['time'], volatility[i], ax=ax2, legend='volatility ' + str(window)) if (i >= 5): fplt.plot(df['time'], volatility[i], ax=ax3, legend='volatility ' + str(window)) #fplt.set_y_range(0, 0.005, ax=ax2) # hard-code y-axis range limitation # draw third plot #fplt.plot(df['time'], volatility_diff, ax=ax3, color='#927', legend='volatility_diff') # draw fourth plot #fplt.plot(df['time'], open_price_position_relative_to_volatility_box, ax=ax4, color='#927', legend='open_price_position_relative_to_volatility_box') # restore view (X-position and zoom) if we ever run this example again fplt.autoviewrestore() # we're done fplt.show() # %% i = 1
def draw_plot(self, plot_title, kbars): fplt = self.setup_plot(plot_title, kbars) fplt.autoviewrestore() fplt.show()