Data and analytics are the lifeblood of financial services, and finding and acting on information quickly can mean the difference between profit and loss. Dependency graphs are powerful tools for managing complicated chains of calculations that make it easier to understand calculation flows, analyze dependencies, efficiently recalculate values after data changes, and drill into calculation problems.
Excel is a dependency graph
The dependency graph that most people know, often without knowing what it’s called, is part of an Excel spreadsheet. If you enter a formula into cell A1 that makes it equal to B1 plus C1, then you change the value in B1, A1 automatically changes: there is a dependency graph behind the sheet that remembers that A1 depends on B1 and C1.
This feature of spreadsheets is one reason why they are so prevalent in financial markets. Why? Because of the three main reasons:
- You can track what depends on what. Excel has visualization tools that let you see which cells a particular calculation depends on, and trace down through many levels of calculation across the spreadsheet.
- Recalculation is efficient. If you have a big spreadsheet and change one input, only cells that depend on that input have to be recalculated; every other value is cached because the dependency graph makes it possible to note that they don’t need to calculate.
- The graph makes it easier to track down problems in calculations; you can identify specifically which cells might be causing problems for a calculated value by checking its dependencies and avoid cells which are uninvolved in the calculation chain.
That said, Excel does have a major disadvantage: while it’s easy to build simple spreadsheets, it’s quite difficult to build large and complex spreadsheets that are still maintainable. That’s because a spreadsheet is a flat grid without much other structure. This problem means that Excel isn’t great for enterprise development: many people have seen examples of simple spreadsheets gradually accruing functionality over years until they are so complex that only the person who built them can maintain them. And it’s worse when that one person leaves the company. And when there’s not just one spreadsheet but dozens or hundreds.
Beacon’s dependency graph: Gromit
The Beacon Core platform contains a dependency graph framework called Gromit, which delivers many of the same benefits as Excel’s dependency graph, but is designed for real enterprise scale and avoids the scalability and maintainability problems of spreadsheets.
Gromit lets you use traditional object oriented programming methodology in the popular programming language Python, which is designed to be modular and maintainable even for very large code bases. Beacon’s Gromit tools read the Python source code on the fly in your classes and methods and dynamically determine the shape of the dependency graph that links your calculations.
Marrying a dependency graph with object oriented code means that you get all the power of dependency tracking, efficient recalculation, and easy debugging, but in a framework that scales up to even the largest businesses in the world.
Gromit in practice
One domain where dependency graphs are particularly powerful is portfolio risk management, especially when the portfolio contains complex products such as derivatives or structured notes. The practice of risk management involves pricing your portfolio under different hypothetical market shocks, to understand how it will perform in many scenarios and motivate hedging decisions. A portfolio might contain hundreds of thousands of open positions, all of which need to be valued in tens of thousands of different scenarios.
That is a daunting computational challenge, but potentially made easier when a scenario involves just one piece of market data, which is a standard case in portfolio risk management. Then only positions that depend on that piece of data need to be recalculated, and the rest of the positions can be ignored.
This is exactly what a dependency graph helps identify: which calculations depend on which inputs. Gromit’s graph automatically marks values as needing recalculation when inputs anywhere in the chain beneath them move, but transparently caches them when their inputs don’t move. This caching dramatically reduces the calculation time for risk calculations, often by orders of magnitude.
Gromit also helps determine what scenarios need to be calculated: out of all the millions of pieces of market data, which ones do you need to shock for your actual portfolio? The dependency graph lets you start with a complex portfolio and quickly determine the market inputs that are relevant for your book.
Finally, under the hood, Gromit’s graph makes it easy for quants and technologists to trace these extremely complex calculations and drill into issues when they happen – which means you get back on your feet faster.