A Framework for Deploying Python in Finance [3 Steps]

Feb 29, 2024

If you’re struggling to understand Python and it’s uses cases for Finance, read on.

⭐️ PLUS - Read to the very end for some special announcements 👇️ 

UPDATE: Thank Tech it’s Friday has changed to ‘Framework Friday’

On Friday’s I’ll be bringing you 1 actionable tech framework that you can use to develop your skills and create more time for the things that matter.

I want to make sure you get high quality, useful content that stands the test of time.

This newsletter has had 3 full re-writes, so whether you liked it or not, hit reply and give me your feedback, it really counts!

For years, I resisted learning how to code (I wish I hadn’t).

I’d done a bit of web design, i.e copying and pasting HTML from others, but that was it.

Then I got thrown in the deep end working with Microsoft Dynamics. An auto-update broke my customers’ systems, and

I spent 48 hours (with no sleep) learning Microsoft’s AL language to provide VERY basic patches.

I then forgot about coding…

Since then, ChatGPT became a thing, and I’ve used Python for all sorts of stuff like writing apps to re-format Excel data and creating forecasts.

If only I’d had ChatGPT back in my Dynamics days 😉

With that in mind, let's look at…

How and where to deploy Python

Python is super hot right now.

  1. Because anyone with access to ChatGPT or similar can generate code.

  2. Because people now realise it can be used to do a LOT of stuff.

  3. Because it’s now built into tools like Excel.

But, there’s a lot of noise out there, which I’m hoping we can cut through today.

To keep things simple, we’ll focus on these 3 areas:

  1. Data Analysis - e.g visualisation

  2. Financial Forecasting - e.g predictions

  3. Automating Finance Tasks - e.g data re-formatting

Notice how none of those include the term ‘Algorithmic trading’ 😉

Whether you just want to understand, or take steps to actually implement Python, today’s edition is here to help.

So, deploying Python in 3-Steps, let’s go!


The Framework [LAW]

  1. [L] Library

Python code often starts with ‘Import’ followed by a silly word like ‘Matplotlib’. This tells Python to import a ‘Library’, or pre-assembled code.

If Python was a spreadsheet → Libraries would be the Excel templates you steal from somebody else.

Libraries are the cheat codes of the Python world, so it’s important to have a base understanding of them for each use case.

I’ve compiled a least of Python libraries against each of our focus areas on this link.

Key takeaway - If there’s not a library for your use case, Python may not be the best option. At least not without a developer.

Pro Tip - Use this prompt with an AI of your choice:

“List some Python libraries that can be used for [Use Case] (that don't relate to the finance industry or algorithmic trading) and describe what they do.”

You can see my example using ChatGPT here.

  1. [A] Application

Your use case will dictate what tool you need to use.

  1. Data Analysis, Forecasting and Predictions

This is best done in a Jupyter notebook (like Google Colab) which is an online environment where you can run code (no install required). Python in Excel is also an option, but it's still in preview, but an Excel plugin like PyXLL will also work.

I'll show you how to run code in Google Colab at the end of the newsletter…

  1. Finance Automation

This is best done by installing Python on your computer combined with a developer tool like Visual Studio Code. Similar to VBA (which is being phased out), you can run code on your machine to automate stuff like spreadsheet manipulation, the creation of PowerPoints or anything else there's a library for.

But, anything you run on your machine won’t be useable by other team members if they don’t have Python installed. You’d need to package the code into an app that can be shared (I can feel another newsletter coming on…).

Key Takeaways - It’s important to match your application to your specific use case. Online environments like Jupyter notebooks have a much lower barrier to entry that installing developer tools like Visual Studio Code.

Pro Tip - Use this prompt with an AI of your choice:

“I’m thinking of performing [use case] using a library like [library]. Is this the library you’d suggest? If so, which platform (e.g Google Colab or Visual Studio Code) would you use to deploy it?”

You can see my example using ChatGPT here.

  1. [W] Workflow

The last step is deciding how often you’re likely to re-use your Python code.

You might only ever use it as a means to do some ad-hoc analysis, or create a bit of code to merge spreadsheets together for reporting. But there may come a time where it needs to form part of a workflow.

There are now plenty of no-code automation platforms that will allow you to build Python into a workflow. Tools like Zapier allow you to add Python code as a step or a Zap.

Simple example:

  • Step 1 - Every time a spreadsheet is added to Google Drive folder

  • Step 2 - Use Python code to reconfigure data into correct column formats

  • Step 3 - Send an e-mail to ‘Team Member A’ to pick up

Key Takeaway - Python become infinitely more powerful when added to day to day workflows. Have a think about where it can slot into yours.


Bringing things together

Here’re a few more ideas.

Data Visualization

  • Use Case: Create an interactive heat map visualizing the spending across different departments.

    • Library: Plotly

    • Platform: Jupyter Notebook (Google Colab)

    • Workflow: - Ad-hoc

Financial Forecasting

  • Use Case: Use Prophet to analyze past sales data and forecast next quarter's sales figures.

    • Library: Prophet

    • Platform: Zapier + Code by Zapier

    • Workflow: Quarterly when sales data is uploaded as a Google Sheet

Finance Task Automation

  • Use Case: Automate the process of summarising expenses by category

    • Library: pandas

    • Platform: Local Python Environment (Visual Studio Code)

    • Workflow: Monthly via packaged app pointing at CSV data

Fancy giving it a go? 👇


Putting it into practise

The best way to get concepts to stick is to put them into practise.

Try this:

  1. Login to an AI of your choice (ChatGPT Pro or Copilot preferred as they’re better with coding)

  2. Enter this prompt:

    “Using the Matplotlib library, generate some Python code that someone in corporate finance could use in Google Colab to get an immediate impression of the power of Python - Use dummy data within the code to avoid the need for data upload or data connection - Exclude anything to do with the finance industry or algorithmic trading.”

  3. Copy the code

  4. Create a new Notebook in Google Colab (login using this link)

  5. Copy the code and hit play (top left)

You can also copy the code from my chat here.


You’ll be a Python pro in no time!

If you enjoyed this framework, let me know by hitting reply.

That’s it for this week.

See you next time!


2 Ways I can help

When you’re ready here’s how I can help you:

  1. I’m now available for 1:1 coaching sessions 🥳 - Find out more here [Fully booked until April].

  2. Join the AI & Automation Academy Waitlist - Get early bird access to my up and coming course here.

Subscribe to Framework Friday

Join 1,100+ finance pros, and receive 1 actionable tech framework you can use to win back your time, develop your skills, and stay ahead of the game.

Subscribe for FREE with your name and e-mail:

We hate SPAM. We will never sell your information, for any reason.