Opening up Python to the business

When was the last time you were on a plane? Probably a while back, right? When you got on the plane, did you turn right and take a seat, or were you told to turn left, and to fly the plane yourself? Sounds like a really silly question! Most people flying on a plane are not trained to fly a plane. We entrust that role to a professional pilot.


The pilot in turn entrusts the building of an aircraft to a firm like Boeing or Airbus, who have thousands of trained engineers. Every single flight is standing on many thousands of man hours of development, engineering and training. What is clear is that every part of this chain are important. The pilots are important, as is the flight crew who supports them, as are all the engineers who built the aircraft.


Let’s think about doing analysis of financial markets. The end consumers of this analysis, the business, are usually investors and trading. Python is a great tool for doing financial analysis. However, for the output to be usable by the end consumer we need to have ways of publishing it in a user friendly way, preferably using some element of visualisation (a picture says a thousand words!). We don’t want to make our analysis only accessible to folks who are familiar with Python! Using the analogy from above, what technology is going to be our “pilot”? Here are a few options that we can try, to make our analysis more accessible to end users, ranging from creating PDFs to creating web dashboards. We go through some of the Python tools we can use with all these cases:

Creating PDFs with analysis

This is probably the most obvious way to publish results and everyone is familiar with using PDFs. The downside is that any results are “static” and hence not interactive. Users have to consume the results in the way they are published, and can’t customise the output. In my tcapy FX TCA library, creating PDFs was one of the ways to share results with users. I used several libraries for generating the PDFs for Python in tcapy including pdfkit, Jinja and WeasyPrint. You can see an example PDF I generated for TCA here.

Using Excel based add-ins to bridge to Python

We can also use tools like xlwings to make Python accessible from Excel, which most people are familiar with, and allows some interaction with the analysis. This requires us however, to usually install something on the users’ machine. Also we may not want to be limited by Excel as a user interface.

Jupyter Notebooks

Jupyter notebooks are a great way to combine our analysis and output, to make our analysis “interactive”. We can also host a Jupyter server remotely, so we don’t need to install anything on a users machine. However, people will still need at least a bit of knowledge of how to use Jupyter notebooks (and preferably a bit of Python) to take advantage of more interactive element afforded by the user of Jupyter notebooks. It’s possible to use tools like ipywidgets to create mini-dashboards too in Jupyter notebooks. We can also wrap up Jupyter notebooks into static websites, using Jupyterbook. I’ve used Jupyterbook quite a bit myself, and it is a very nice tool!

Creating web dashboards

A nice way to share analysis in an interactive way is to create web based dashboards. There are many different tools that can be used for this. We can create a front end web GUI in JavaScript using tools like React, and then use Python for the backend to do our analysis. There are lots of nice visualisation tools like D3.js for JavaScript too. However, if we want to stick to using Python, there are are many tools that can be used to create web dashboards, which handle the JavaScript for us.


Dash – Interactive Python based dashboards, which make use of Plotly graphs

I’ve use Dash a lot, including for my tcapy FX TCA Python library, and the library has got better over the years which I’ve been using it, and has got corporate backing from Plotly. It is designed to work with Plotly for generating charts (as you might expect). Whilst I’ve only used the open source version, which I’ve found sufficient for my use cases, there is also an Enterprise version which adds tools like a point-and-click dashboard creator etc. You can also embed Dash dashboards into Jupyter notebooks using jupyter-dash. There lots of nice examples in the Dash gallery. There’s also a new library webdash, which lets you run Dash websites entirely in your browser (ie. without having a Flask server!) and there’s a proof of concept demo here, that shows how to add non-Plotly charts too.


Panel – A high-level app and dashboarding solution for Python

Unlike Dash, which is focused on using Plotly, Panel by contrast let’s you use many different plotting libraries, not just Plotly.


iDOM – Create highly interactive web pages purely in Python

iDOM is a interactive dashboard library. It can support Jupyter and Dash underneath, and they are also working on using Streamlit and Bokeh. It is however a lot newer than Dash.


Voila – Voilà turns Jupyter notebooks into standalone web applications

If your analysis was originally a Jupyter notebook, Voila lets you convert it into a webapp for users to play with.


chartpy – Wrapper for Plotly/Matplotlib and Dash

I’ve also written a nice wrapper for Plotly and many other plotting libraries inside my chartpy library. I’ve also recently extended it to wrap around Dash, which effectively writes a lot of the boilerplate code for Dash, such as creating components and handling all the callbacks. I’ve created a small demo with Dash and chartpy, of a simple dashboard which plots Quandl tickers, which I’ve spun out of my tcapy library. I’m also planning to get it to support other backends in the future.


If we make our Python analysis more accessible to more technical users, it increases the likelihood of it making an impact for the end users, who are the decision makers investing capital. Being able to effectively communicate the findings of our analysis is crucial. There are many ways of making our Python analysis more accessible to users, whether it is through publishing PDFs or through more interactive means such as a web dashboard. Which one is most appropriate, will depend on your specific use case and the demands of your end users.