The Depth of a Financial Model, Continued
********************************************
Explores building a more complex and realistic model with Python. Here we focus on extending the simple retirement model to have dynamic salary growth.
Resources
============
- :download:`Slides - The Depth of a Financial Model, Continued `
- :download:`Lecture Notes - The Depth of a Financial Model, Continued `
- `Markdown Basic Syntax `_
- `Markdown Extended Syntax `_
- `LaTeX Equations in Jupyter `_
- :download:`Dynamic Salary Retirement Model - Python `
Using Jupyter to Structure a Python Model
============================================
.. youtube:: Zk29_tWiWGc
:height: 315
:width: 80%
:align: center
|
Notes
--------
- It can be a bit tricky in the beginning to structure Python models in Jupyter as you are dealing with two different layers of organization
- Jupyter gives us nicely formatted markdown cells which make it easy to organize sections of the model
- Markdown is actually a general markup language, not anything specific to Jupyter, and it supports a lot of features. Jupyter has their own extension to markdown which also adds LaTeX equation support
- Most often, you will just need section headers, bullets, and equations, and anything else you can look at a Markdown reference
- It is easy to add a table of contents for a Jupyter notebook and you should do this to increase the readability of your model
- When adding a TOC item, spaces get converted to dashes for the reference
Resources
------------
- `Markdown Basic Syntax `_
- `Markdown Extended Syntax `_
- `LaTeX Equations in Jupyter `_
Transcript
-------------
.. raw:: html
|
Salaries in the Python Dynamic Salary Retirement Model
=========================================================
.. youtube:: 190Xci0yDpA
:height: 315
:width: 80%
:align: center
|
Notes
--------
- For development purposes, create a new variable data which is set equal to model_data. When you are done with the model, you will remove this.
- Write the logic for a function in a cell and run it to ensure it works, then move it into a function
- Using data in the functions while the original variable is model_data ensures that you are not accidentally accessing the overall (global) model_data when it should be the specific instance of ModelInputs being passed
- This may be confusing and sound like extra unnecessary steps, but setting things up this way will enable your model to be easily extended
- Here we will create a function which can get the salary in any given year
- We will write also some example code to test the function and show its results
- Later we will use this function in the overall calculation
Resources
------------
- :download:`Dynamic Salary Retirement Model - Python `
Transcript
-------------
.. raw:: html
|
Wealth in the Python Dynamic Salary Retirement Model
=======================================================
.. youtube:: ACSk15RnOG0
:height: 315
:width: 80%
:align: center
|
Notes
--------
- Here we will develop two functions which comprise the wealth sub-model
- First create a function which determines the amount of cash saved in a given year
- Then create a function which determines the amount of wealth in a given year
- We create some example code to show how the function works, but it will actually be applied in the Retirement sub-model
Resources
------------
- :download:`Dynamic Salary Retirement Model - Python `
Transcript
-------------
.. raw:: html
|
Retirement in the Python Dynamic Salary Retirement Model
===========================================================
.. youtube:: zHoYWl3YHJ8
:height: 315
:width: 80%
:align: center
|
Notes
--------
- Now we will bring everything together to calculate the years to retirement
- The salary and cash saved functions are already getting called from within the wealth function, so we only need to call the wealth function in the final loop
- Here we are making use of a while loop to stop the loop once a certain condition is met, in this case once wealth exceeds desired cash
- We will use formatted strings and new lines to create a good display for the output
Resources
------------
- :download:`Dynamic Salary Retirement Model - Python `
Transcript
-------------
.. raw:: html
|
Lab Exercise
===============
.. youtube:: 5ruLMjkQ6C4
:height: 315
:width: 80%
:align: center
|
Notes
--------
- Feel free to work from the example model though I would recommend you build that out yourself following the prior videos
- This exercise is exactly the same as the one we did for Excel to calculate the desired cash rather than taking it as an input
- Hint: You should add the new inputs to the ModelInputs dataclass and remove the desired cash input. Then you can create a function which calculates the desired cash based on the model inputs, and use that in place of where the desired cash was being accessed directly before
Resources
------------
- :download:`Dynamic Salary Retirement Model - Python `
Transcript
-------------
.. raw:: html
- 00:03: hey everyone
- 00:04: nick derbertus here teaching you
- 00:06: financial modeling and today
- 00:08: we're going to talk about the lab
- 00:09: exercise for the
- 00:11: section of the course on the depth of a
- 00:14: financial model
- 00:14: in python where we focused on building
- 00:17: out the dynamic salary model
- 00:19: in python so the lab exercise here
- 00:23: is the same as the one that we did for
- 00:26: excel
- 00:26: in the section on building out the excel
- 00:29: dynamic salary retirement model
- 00:32: and here what we want to do is we want
- 00:34: to
- 00:35: relax this assumption that there's some
- 00:38: fixed amount of desired cash
- 00:40: that we need for retirement and the way
- 00:42: that we talked about
- 00:44: relaxing that was that we're going to
- 00:46: think about instead of
- 00:47: just having a certain number instead
- 00:49: we're going to have
- 00:51: an amount that we want to spend each
- 00:53: year in retirement as an input
- 00:55: as well as the length of time that this
- 00:57: individual
- 00:58: is in retirement until they die
- 01:01: so then based off of those inputs
- 01:04: we can then calculate the desired cash
- 01:08: within the model and plug that through
- 01:11: into the existing structure
- 01:12: so that the rest of the model works the
- 01:14: same way that it did
- 01:16: before so that's the basic idea
- 01:20: and to accomplish this um something
- 01:24: a way you might want to go about it is
- 01:27: go ahead
- 01:27: and remove the desired cache from the
- 01:31: model inputs in the model
- 01:34: and add these two new inputs
- 01:37: and then it makes sense to create a
- 01:39: function which is able to
- 01:42: calculate the desired cache from the
- 01:44: model inputs
- 01:45: and then you'll just take uh calling
- 01:47: that function
- 01:48: and put it in the place of where you
- 01:51: were just directly
- 01:52: using the desired cache before and then
- 01:55: you really won't have to change much at
- 01:57: all
- 01:57: about the existing model and it will
- 01:59: just start working with this new
- 02:01: desired cache calculation
- 02:04: so thanks for listening and see you next
- 02:07: time
|