This document summarizes a presentation about using Excel and Python together for financial analysis. It discusses:
1) Using Python for interactive data analysis and automated testing of Excel models.
2) Creating Monte Carlo simulations and exporting Excel macros to web apps with Python.
3) Developing user-defined functions in Python to extend Excel's functionality, like creating a correlation heatmap from multiple data sets.
3. About me
• Consultancy (Zürich):
– Consulting: Web apps for Finance
– Workshops: Excel & Python
– Open-source: xlwings
• Previously:
– 9yrs in Banking /Asset Management
– Background: Finance & Economics
3
4. Agenda
4
1) Scripting/Interaction
• Interactive data analysis
• Automated Testing of Spreadsheet Models
2) Macros
• Monte Carlo Simulation
• From Excel to web apps
3) User Defined Functions (UDFs)
• Correlation Analysis
7. Spreadsheet Risk: Automated Testing
7
• Audit/Regulation require effective controls
• Automated unit tests are a cornerstone of modern
software development (”test-driven development”)
• Excel: doesn’t offer any means to create unit tests
• Python: has a built-in unit test module
• Unit testing with xlwings is unintrusive:
- No add-in to be installed
- No changes to the original VBA code base
- Python standard lib + xlwings is all you need
• It’s a great way to verify & debug legacy VBA code
13. DJIA: Correlation Analysis
13
=CORREL(array1, array2)
Excel’s Correlation formula accepts just 2 data sets:
Here’s how we’re going to fix this:
• Add CORREL2 to get the full correlation matrix
• Visual representation: Heatmap