A Framework for Deploying Python in Finance [3 Steps]
Feb 29, 2024If 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.
-
Because anyone with access to ChatGPT or similar can generate code.
-
Because people now realise it can be used to do a LOT of stuff.
-
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:
-
Data Analysis - e.g visualisation
-
Financial Forecasting - e.g predictions
-
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]
-
[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.
-
[A] Application
Your use case will dictate what tool you need to use.
-
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…
-
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.
-
[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:
-
Login to an AI of your choice (ChatGPT Pro or Copilot preferred as they’re better with coding)
-
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.”
-
Copy the code
-
Create a new Notebook in Google Colab (login using this link)
-
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!
Adam
Subscribe to Framework Friday
1 tech, productivity, or mental framework to your inbox most Fridays. Access to my tech toolkit, 76 tools and how I've used them β Many of them free. Links to all my 100s of LinkedIn posts β Updated weekly
Subscribe for free withΒ just your e-mail:
I respect your privacy. Opt-out any time.