bokeh library lets you build data visualization applications on the web and run them on a server. Below is plot that uses
bokeh.server along with other python libraries to display up-to-date (mostly U.S.) stock market closing prices.
alpha_vantage python libraries to access free data providers. The former library lets you access stock market data from Morningstar among other providers. Alpha Vantage provides similar data with minimal time delay (1 minute).
heroku’s free tier service to host the app online. It’s easy to use if you are used to using
git. The free-tier comes with usage limits, most of which are sufficient for my purpose. The only noticeable limit is the fact that the machine goes to sleep after 30 minutes of inactivity. Hence, you likely waited a while until the plot showed up.
I also used
docker to make the app portable to other platforms if necessary (and to get myself familiarized with it).
By default, cross site connections to the Bokeh server websocket are not allowed. You can enable websocket connections originating from additional hosts by specifying them with the –allow-websocket-origin option.
Not really understanding how servers work, I fumbled with this for quite a bit. I added
--allow-websocket-origin=blog.micbon.comas well as
--allow-websocket-origin=mm-plot-stocks.herokuapp.comto allow access from this page and the
herokupage. I embedded the plots using both
<iframe>tags to see the difference.
not so responsive
I found it difficult to make the application responsive (resize along with the display size). It may be possible if I fumbled a little longer but since the plot itself wouldn’t be able to show much when it’s too small I decided to leave it at a fixed size.
another plotting library
I also created the same plot using
dashmodule. You can see the app here and the source codes here . It was actually easier to use in my opinion. The only trouble I have is making it work with
Docker. I still have not figured out how… :(