| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent dbf1cad commit fe38188
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1617,6 +1617,7 @@ def plot(x, y=None, color=None, width=1, ax=None, style=None, legend=None, zooms | |||
| 1617 | 1617 | if style is None or any(ch in style for ch in '-_.'): | |
| 1618 | 1618 | connect_dots = 'finite' # same as matplotlib; use datasrc.standalone=True if you want to keep separate intervals on a plot | |
| 1619 | 1619 | item = ax.plot(x, y, pen=_makepen(color=used_color, style=style, width=width), name=legend, connect=connect_dots) | |
| 1620 | + item.setClipToView(True) | ||
| 1620 | 1621 | item.setDownsampling(auto=True, method='subsample') | |
| 1621 | 1622 | item.setZValue(5) | |
| 1622 | 1623 | else: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,8 +8,8 @@ | |||
| 8 | 8 | ||
| 9 | 9 | This example includes dipping in to the internals of finplot and | |
| 10 | 10 | the underlying lib pyqtgraph, which is not part of the API per se, | |
| 11 | - and may thus change in the future. If so happens, this example | ||
| 12 | - will be updated to reflect such changes. | ||
| 11 | + and may thus change in the. If so happens, this example will be | ||
| 12 | + updated to reflect such changes. | ||
| 13 | 13 | ||
| 14 | 14 | Included is also some third-party libraries to make the example | |
| 15 | 15 | more realistic. | |
@@ -29,9 +29,9 @@ | |||
| 29 | 29 | import websocket | |
| 30 | 30 | ||
| 31 | 31 | ||
| 32 | - class BinanceFutureWebsocket: | ||
| 32 | + class BinanceWebsocket: | ||
| 33 | 33 | def __init__(self): | |
| 34 | - self.url = 'wss://fstream.binance.com/stream' | ||
| 34 | + self.url = 'wss://stream.binance.com/stream' | ||
| 35 | 35 | self.symbol = None | |
| 36 | 36 | self.interval = None | |
| 37 | 37 | self.ws = None | |
@@ -113,8 +113,8 @@ def on_error(self, error, *args, **kwargs): | |||
| 113 | 113 | ||
| 114 | 114 | ||
| 115 | 115 | def do_load_price_history(symbol, interval): | |
| 116 | - url = 'https://www.binance.com/fapi/v1/klines?symbol=%s&interval=%s&limit=%s' % (symbol, interval, 1000) | ||
| 117 | - print('loading binance future %s %s' % (symbol, interval)) | ||
| 116 | + url = 'https://www.binance.com/api/v1/klines?symbol=%s&interval=%s&limit=%s' % (symbol, interval, 1000) | ||
| 117 | + print('loading binance %s %s' % (symbol, interval)) | ||
| 118 | 118 | d = requests.get(url).json() | |
| 119 | 119 | df = pd.DataFrame(d, columns='Time Open High Low Close Volume a b c d e f'.split()) | |
| 120 | 120 | df = df.astype({'Time':'datetime64[ms]', 'Open':float, 'High':float, 'Low':float, 'Close':float, 'Volume':float}) | |
@@ -390,7 +390,7 @@ def create_ctrl_panel(win): | |||
| 390 | 390 | layout.setColumnMinimumWidth(1, 30) | |
| 391 | 391 | ||
| 392 | 392 | panel.interval = QComboBox(panel) | |
| 393 | - [panel.interval.addItem(i) for i in '1d 4h 1h 30m 15m 5m 1m'.split()] | ||
| 393 | + [panel.interval.addItem(i) for i in '1d 4h 1h 30m 15m 5m 1m 1s'.split()] | ||
| 394 | 394 | panel.interval.setCurrentIndex(6) | |
| 395 | 395 | layout.addWidget(panel.interval, 0, 2) | |
| 396 | 396 | panel.interval.currentTextChanged.connect(change_asset) | |
@@ -418,11 +418,11 @@ def create_ctrl_panel(win): | |||
| 418 | 418 | fplt.y_pad = 0.07 # pad some extra (for control panel) | |
| 419 | 419 | fplt.max_zoom_points = 7 | |
| 420 | 420 | fplt.autoviewrestore() | |
| 421 | - ax,ax_rsi = fplt.create_plot('Complicated Binance Futures Example', rows=2, init_zoom_periods=300) | ||
| 421 | + ax,ax_rsi = fplt.create_plot('Complicated Binance Example', rows=2, init_zoom_periods=300) | ||
| 422 | 422 | axo = ax.overlay() | |
| 423 | 423 | ||
| 424 | 424 | # use websocket for real-time | |
| 425 | - ws = BinanceFutureWebsocket() | ||
| 425 | + ws = BinanceWebsocket() | ||
| 426 | 426 | ||
| 427 | 427 | # hide rsi chart to begin with; show x-axis of top plot | |
| 428 | 428 | ax_rsi.hide() | |
@@ -432,5 +432,5 @@ def create_ctrl_panel(win): | |||
| 432 | 432 | ctrl_panel = create_ctrl_panel(ax.vb.win) | |
| 433 | 433 | dark_mode_toggle(True) | |
| 434 | 434 | change_asset() | |
| 435 | - fplt.timer_callback(realtime_update_plot, 1) # update every second | ||
| 435 | + fplt.timer_callback(realtime_update_plot, 0.5) # update twice every second | ||
| 436 | 436 | fplt.show() | |
| Back | FazBrowse Home | New Git URL |
0 commit comments