In this notebook, I will introduce how to build a real-time stock quote application.
For that purpose, we will use Fugle Realtime Websocket API and Dash.
- Python 3.6.9
pip install -r requirements.txtfrom fugle_realtime_websocket_api import *chart = chart_websocket_api(api_token = 'demo')If you want to get your own api_token, please visit Fugle Realtime API for more information.
Otherwise, you just can use api_token = 'demo' and query Symbol ID 2884 for trial.
df_ohlc = chart.get_chart_data(n = 5, symbol_id = '2884')n represents the time interval of the min K data.
symbol_id represents the stock code of the Taiwan stock market.
chart.plot_ohlc(df = df_ohlc, rise_color = 'red', down_color = 'green')
chart.plot_volume_bar(df = df_ohlc, rise_color = 'red', down_color = 'green')When close price is larger than open price, rise_color will be in red.
On the other hands, when close price is less than open price, down_color will be in green.
chart.plot_MA(df = df_ohlc, n = 5, line_color = 'blue', line_width = 2)n represents the time interval of the MA line.
quote = quote_websocket_api(api_token = 'demo')df_quote, price_list, symbol = quote.update_quote_data(symbol_id = '2884')quote.plot_order_book(df_quote, price_list, symbol)df_quote represents an order book that records the historical price since the execution of the code.
price_list represents the current price of the order book.
We use Dash to build our real-time stock quote application.
Dash is a productive Python framework for building web applications.
It is really suited for everyone to bulid a dashboard with highly custom user interface in Python.

http://127.0.0.1:8050!
If you want to get more informations, you can check demo.ipynb.