Ejemplo n.º 1
0
def get_sensitivity_analysis_excel_lecture() -> Lecture:
    title = 'Sensitivity Analysis in Excel'
    youtube_id = '1wECF1RjsNM'
    week_covered = 6
    notes = LectureNotes([
        'Data tables in Excel allow calculating a cell multiple times, changing some other cell. This is perfect for '
        'sensitivity analysis if we target an output cell and change an input cell',
        'One-way data tables change one input at a time, two-way data tables change two inputs at a time',
        'You are basically limited to changing two inputs at once, without doing some clever hacks',
        'Visualization rule of thumb: graph one-way data tables and use conditional formatting for two-way',
        'Conditional formatting changes the format of cells based on conditions, such as putting the largest numbers '
        'in green and the smallest in red',
        'Row input cell means that your inputs are going horizontally in a row. Column input cell means that your '
        'inputs going vertically in a column. For one-way data tables, you will use only one of the two. For '
        'two-way data tables, you will use both'
    ],
                         title=title)
    resources = [
        RESOURCES.examples.intro.excel.dynamic_salary_retirement_model,
    ]
    return Lecture(title,
                   week_covered,
                   notes,
                   youtube_id=youtube_id,
                   resources=resources)
Ejemplo n.º 2
0
def get_internal_randomness_retirement_excel_lecture() -> Lecture:
    title = 'Adding Internal Randomness to an Excel Model'
    youtube_id = 'CTXV_BzffC8'
    week_covered = 9
    notes = LectureNotes([
        'Typically you would add internal randomness as you build the model, not afterwards. It can '
        'require substantial changes to the original logic to add it afterwards',
        'In most cases Monte Carlo simulation should be used when the model is already built',
        'Here we will be randomly picking for each year whether it is a recession, normal, or expansion economy',
        'In this case, as we want to add different behavior year by year based on the randomness, '
        'it is not possible via an external method such as Monte Carlo simulation',
        'Here I am treating interest rate and savings rate as discrete random variables since they are tied to the '
        'state of the economy which is a discrete random variable. I could have assigned the quality of the economy '
        'to a normal distribution to make it continuous and then the other variables could be continuous as well',
        'There are no special tricks here in Excel, we are just applying the previous approach for discrete random '
        'variables and hooking it into the model',
    ],
                         title=title)
    resources = [
        RESOURCES.examples.internal_randomness.excel.
        dynamic_salary_model_random,
    ]
    return Lecture(title,
                   week_covered,
                   notes,
                   youtube_id=youtube_id,
                   resources=resources)
Ejemplo n.º 3
0
def get_intro_probabilistic_modeling_lecture() -> Lecture:
    title = 'Introduction to Probabilistic Modeling'
    youtube_id = 'OvLatB0ax1Y'
    week_covered = 7
    notes = LectureNotes([
        'Probability is a key concept for financial models as it related to risk',
        'The base result from a deterministic model only gives a single answer, but does not '
        'consider the probability distribution of the result',
        'E.g. your model could predict a positive NPV from a project, but through probabilistic '
        'modeling you determine that there is a 98% chance the NPV is negative. Do you still want to '
        'take the project? This is important information to know when making that decision.',
        'We discuss three techniques in this course that take advantage of probability theory: '
        'scenario modeling, internal randomness, and Monte Carlo simulation',
        'Scenario modeling and Monte Carlo simulation are also methods of exploring the parameter '
        'space, just like sensitivity analysis',
        'Internal randomness is useful for when the probability is so core to the model that it '
        'should be built in from the beginning, rather than extending the base model to add probability'
    ],
                         title=title)
    resources = []
    return Lecture(title,
                   week_covered,
                   notes,
                   youtube_id=youtube_id,
                   resources=resources)
Ejemplo n.º 4
0
def get_functions_lecture() -> Lecture:
    title = 'Grouping Logic with Python Functions'
    youtube_id = 'e5IGeMHmq0Q'
    week_covered = 3
    notes = LectureNotes([
        'Functions are the logical building blocks for any Python program, including our models',
        'Functions contain a piece of logic which then can be reused flexibly with different inputs',
        'We have functions in Excel, e.g. =SUM, =IF, =VLOOKUP, but as an Excel user you typically do not define '
        'functions. Python has built-in functions and also it is very easy to define your own.',
        'Ultimately, you should be able to run your entire model by running a single function',
        'The sub-models should also be functions, and the steps within the sub-models should also be functions. This '
        'can be broken into as many layers as is necessary. Your higher-level custom functions will be calling your '
        'lower-level custom functions.',
        'Not only will you have better readability and organization of your model, but also you will be able to '
        'reuse logic more often which lowers maintenance costs',
        'Functions scope the variables defined within. You cannot use those variables outside the function. This lets '
        'you use more general variable names which increases readability'
        'Default arguments are a great way to keep your function flexible but also easy to use',
        'For these lab exercise, I have provided cells to check your work. After adding your solution and '
        'running the exercise cell, then run the check cell which will throw an AssertionError or NameError '
        'if incorrect and nothing if correct.',
        'The exercises test creating functions with and without default arguments and adding docstrings to functions'
    ],
                         title=title)
    resources = LECTURE_4_COMMON_RESOURCES + [
        LectureResource(
            'Python Built-in Functions Official Reference',
            external_url='https://docs.python.org/3/library/functions.html')
    ]
    return Lecture(title,
                   week_covered,
                   notes,
                   youtube_id=youtube_id,
                   resources=resources)
Ejemplo n.º 5
0
def get_python_scenario_analysis_lecture() -> Lecture:
    title = 'Scenario Analysis in Python'
    youtube_id = 'LkVlviRFQtA'
    week_covered = 8
    notes = LectureNotes([
        'Just as with sensitivity analysis and any other extension to the base model, your model '
        'needs to be set up appropriately to add scenario analysis. All the main logic should be '
        'in functions, and the functions should not access variables which were defined outside a '
        'function unless they are passed in as arguments.',
        'Dictionaries are a helpful data structure for scenario analysis as you can put the name of the '
        'scenario as the key and have the input values as the value',
        'The process is very similar to other methods of exploring the parameter space. Run the model with '
        'each set of inputs and keep the outputs associated with the inputs. In scenario analysis we often '
        'also assign probabilities to the cases and take the expected value of the results',
        'Before you complete the lab, ensure that your Python sensitivity analysis lab is working properly, or '
        'else this and any other future extensions to the model will probably also not work properly'
    ],
                         title=title)
    resources = [
        RESOURCES.examples.scenario.python.dynamic_salary_model_scenario,
    ]
    return Lecture(title,
                   week_covered,
                   notes,
                   youtube_id=youtube_id,
                   resources=resources)
Ejemplo n.º 6
0
def get_styling_pandas_lecture() -> Lecture:
    title = 'Styling Pandas DataFrames'
    youtube_id = 'S-wnf_q6kYQ'
    week_covered = 5
    notes = LectureNotes([
        'Just as it is important to format tables in Excel to increase readability, we should '
        'do the same with any Pandas DataFrames we display to the reader of the model',
        'There is a philosophical difference in how styling is done in Excel versus Pandas. In Excel, '
        'you directly format the table which stores your data. In Pandas, you create a styled object '
        'immediately before displaying which is separate from the original data, the data itself does '
        'not get formatted',
        'Because of this difference in philosophy, the way I recommend working with Pandas styling is to '
        'create a styler function that accepts a DataFrame and returns the styled object. This way you '
        'can just call it on your DataFrame as you display it. This has a couple advantages: your data logic '
        'is completely separate from formatting code, and you can apply consistent formatting to multiple different '
        'DataFrames easily.'
    ],
                         title=title)
    resources = [
        RESOURCES.examples.visualization.python.intro_pandas_notebook,
        RESOURCES.external.visualization.pandas_styling_guide,
    ]
    return Lecture(title,
                   week_covered,
                   notes,
                   youtube_id=youtube_id,
                   resources=resources)
Ejemplo n.º 7
0
def get_conditionals_lecture() -> Lecture:
    title = 'Branching Logic with Python Conditionals'
    youtube_id = 'mOkdoRzqXH4'
    week_covered = 2
    notes = LectureNotes([
        'Conditionals let you choose which logic to run based on some logical condition',
        'This is just like using Excel =IF, but more flexible as we can run any arbitrary '
        'operation rather than just returning a single value',
        'If/else if/else pattern becomes a lot more clear in Python as they are written as '
        'separate blocks rather than a nested =IF statement in Excel',
        'Logical conditions are always evaluated first to True or False. If True, goes into '
        'if part, if False, goes into else part (if included)',
        'Be careful about single = vs double ==, it is an easy mistake to make and you will '
        'get a SyntaxError applying the incorrect one',
        'Elif is never strictly necessary but can help simplify the code substantially',
        'The lab exercises test knowledge of conditionals but also build on our prior knowledge '
        'of for loops and show how they can be combined'
    ],
                         title=title)
    resources = LECTURE_4_COMMON_RESOURCES
    return Lecture(title,
                   week_covered,
                   notes,
                   youtube_id=youtube_id,
                   resources=resources)
Ejemplo n.º 8
0
def get_project_3_lecture() -> Lecture:
    project_title = 'Monte Carlo Cost of Capital'
    project_num = 3
    title = f'Project {project_num} - {project_title}'
    youtube_id = '1mlVhKn81DY'
    week_covered = 10
    notes = LectureNotes([
        'The focus of this project is to start working towards the Discounted Cash Flow (DCF) valuation '
        'of a stock. The weighted average cost of capital (WACC) is a component of that model',
        'This project also tests your ability to carry out a Monte Carlo simulation',
        'Project 4 will be the full DCF valuation, which means it will include doing this analysis again '
        'for a different company. I encourage you to write general functions that will be useful for both, '
        'and after this project you can move those functions into a separate file so they can be shared',
        'This is also our first project that requires working with external data',
        'You can feel free to modify any of the data files. If you do modify them, then submit them along '
        'with your project. If you did not modify the file, leave it out of the submission',
        'To earn the bonus, complete the project without modifying any data files. I would recommend saving '
        'this for last as it will be a substantial challenge. If you plan to do the bonus, as you modify the '
        'files for your model, take note of every manual step that you take so you can try to automate it later',
        'Please see the project description for some links to extra resources to help you automate the data cleanup',
        'As with Project 2 and the remaining projects in the course, you are free to submit a Python model, Excel '
        'model, or combination Python/Excel model. The only requirement is if you do submit a combination model, '
        'the final outputs should be in Python',
    ],
                         title=title)
    resources = [
        *RESOURCES.projects.project_3.resources(),
    ]
    return Lecture(title,
                   week_covered,
                   notes,
                   youtube_id=youtube_id,
                   resources=resources)
Ejemplo n.º 9
0
def get_project_4_lecture() -> Lecture:
    project_title = 'Full DCF Valuation'
    project_num = 4
    title = f'Project {project_num} - {project_title}'
    youtube_id = 'FtcMf0yjPVw'
    week_covered = 12
    notes = LectureNotes([
        'The focus of this project is to complete the full Discounted Cash Flow (DCF) valuation '
        'of a stock',
        'The other main focus of the project is to transition you into modeling in the real world '
        "where you won't have the template and answers provided",
        'This is an open-ended project, you get to choose the company you want to value and you can '
        'feel free to use Python, Excel, or a combination',
        'Be sure to complete all the extensions to the model including sensitivity analysis, scenario '
        'analysis, Monte Carlo simulation, and visualization or you will lose substantial points',
        'Your analysis of the company is important to set the assumptions for the forecasts. You need to '
        'research the company and its plans for the future and incorporate your findings into the forecasts',
        'You also need to analyze the results from the model and the extensions, and produce a report of '
        'your research and findings from the model',
        'The bonus is similarly unstructured, do a great job in any area(s) of the model to be eligible for the bonus'
    ],
                         title=title)
    resources = [
        *RESOURCES.projects.project_4.resources(),
    ]
    return Lecture(title,
                   week_covered,
                   notes,
                   youtube_id=youtube_id,
                   resources=resources)
Ejemplo n.º 10
0
def get_mc_retirement_excel_lecture() -> Lecture:
    title = 'Applying Monte Carlo Simulation to an Excel Model'
    youtube_id = 'f7CM9urH3sI'
    week_covered = 10
    notes = LectureNotes([
        'The process for running Monte Carlo simulations in Excel is nearly the same as that in '
        'Python when we use Python to run the simulations on the Excel model using xlwings',
        'The main difference is that we write the inputs into Excel and extract the results '
        'using xlwings rather than running Python logic for the core model',
        'Excel recalculates whenever an input is changed. So writing the inputs in is enough '
        'to get the result calculated',
        'For the analysis, you can either keep the results in Python and follow the process '
        'for analyzing the results in Python, or you can output them back to Excel and '
        'analyze the outputs there',
        'Keep in mind that if you visualize the outputs in Excel, next time you run the simulation '
        'it will go slow due to the visualizations. Because of this it may be a better idea in '
        'general to do the analysis in Python if you have a choice'
    ],
                         title=title)
    resources = [
        RESOURCES.examples.monte_carlo.excel.dynamic_salary_model_mc,
        RESOURCES.examples.monte_carlo.excel.excel_monte_carlo_notebook,
    ]
    return Lecture(title,
                   week_covered,
                   notes,
                   youtube_id=youtube_id,
                   resources=resources)
Ejemplo n.º 11
0
def get_formal_mc_lecture() -> Lecture:
    title = 'Formal Introduction to Monte Carlo Simulations'
    youtube_id = 'p4YoSmh0wQQ'
    week_covered = 10
    notes = LectureNotes([
        'The process described here to run Monte Carlo simulations may sound very similar to that to run '
        "sensitivity analysis, and that's because it is. The only difference is that you randomly pick "
        "the input values from distributions with each run of the model rather than having fixed input ranges",
        "Running the Monte Carlo simulation is not enough. You will have a bunch of outputs, but you must "
        "analyze them and visualize them to extract meaning",
        "The main insights we can draw from analyzing a Monte Carlo simulation relate to the probabilities "
        "of certain outcomes in the model. We can also get a deeper picture of the relationships between "
        "inputs and outputs in a more complex model where that may not be clear",
        'The probability table is the quantitative version of plotting the data on a histogram. I would generally '
        'recommend including both as the histogram allows quick understanding of the shape of the '
        'entire distribution whereas '
        'the probability table helps in quantifying the distribution',
        'The Value at Risk (VaR) represents losing at least some amount with a degree of confidence, e.g. in '
        '95% of periods the portfolio should not lose more than \$1,000. The probability table can be interpreted '
        'in the same way if the outcome you are analyzing is the gain/loss',
        'The probability of a certain outcome makes sense when you have some kind of goal in mind, then you can '
        'evaluate the probability of achieving that goal. If there is no specific goal in mind, there is no '
        'need to carry out this analysis'
    ],
                         title=title)
    resources = []
    return Lecture(title,
                   week_covered,
                   notes,
                   youtube_id=youtube_id,
                   resources=resources)
Ejemplo n.º 12
0
def get_mc_retirement_python_lecture() -> Lecture:
    title = 'Applying Monte Carlo Simulation to a Python Model'
    youtube_id = 'DAddBN2xPuI'
    week_covered = 10
    notes = LectureNotes([
        'It can make sense to set up a separate dataclass for your simulation-specific inputs, or you '
        'may add them to the existing dataclass',
        'Once you start running large numbers of simulations, some unexpected situations may occur in your '
        'model such as inputs going negative that were supposed to only be positive, or one input being '
        'greater than another when it is supposed to be less. To solve this, we can build functions which produce the '
        'random inputs according to the necessary conditions in our model',
        'Create a function which runs a single simulation, then call that function in a loop over the number of '
        'iterations to run all the simulations',
        'Because we typically have multiple changing inputs and may even have multiple outputs, it is useful to '
        'store data as a list of tuples and then create a DataFrame at the end',
        "It doesn't hurt to take the quantile of the entire DataFrame to see the distributions of the inputs as well. "
        "It can be a nice check to make sure your random inputs are working appropriately",
        "After running a multivariate regression, be sure to add some text interpreting the results",
        "We can check the standardized coefficients (coef * std) to understand which inputs have the greatest "
        "impact on the outputs. Be careful that these results are influenced by your choice of the input distributions. "
        "If your input distributions are not reasonable, neither will be the results"
    ],
                         title=title)
    resources = [
        RESOURCES.examples.monte_carlo.python.dynamic_salary_model_mc,
    ]
    return Lecture(title,
                   week_covered,
                   notes,
                   youtube_id=youtube_id,
                   resources=resources)
Ejemplo n.º 13
0
def get_intro_dcf_lecture() -> Lecture:
    title = 'Introduction to Discounted Cash Flow (DCF) Valuation'
    youtube_id = '9wRZmIbnEmw'
    week_covered = 11
    notes = LectureNotes([
        'The Discounted Cash Flow (DCF) valuation of a stock is often considered a capstone finance '
        'model as incorporates many different concepts and also the technical skills to implement them',
        'I have often heard of job applicants being asked to prepare a DCF model to prove their skills and knowledge',
        'It is also generally considered the valuation approach which can be the most accurate, though there are '
        'a lot of assumptions which must be made which could influence the results',
        'There are two main portions of the DCF model: coming up with the weighted average cost of capital (WACC) '
        'and estimating future free cash flows. Each of these portions have smaller tasks involved',
        'At the end of the day, the concept of the model is extremely simple: take the present value of future '
        'cash flows to determine the value of the company. The difficult part is figuring out those cash flows '
        'and the discount rate',
        'In this segment we will be focusing on the cost of capital estimation, and we will come back in the next '
        'segment to cover FCF estimation',
        'We will focus on using the Capital Asset Pricing Model (CAPM) to estimate the cost of equity and we will '
        'discuss several approaches for estimating the cost and market value of debt depending on the availability '
        'of data and amount of time that can be invested into building the model'
    ],
                         title=title)
    resources = []
    return Lecture(title,
                   week_covered,
                   notes,
                   youtube_id=youtube_id,
                   resources=resources)
Ejemplo n.º 14
0
def get_ev_lecture() -> Lecture:
    title = 'Enterprise Value and Equity Value'
    youtube_id = 'hhmWGkoJmCU'
    week_covered = 11
    notes = LectureNotes([
        'When we take the present value of future cash flows, we will get the enterprise value which is '
        'a combination of the value from different sources of capital',
        'Ultimately we are interested in determining the value of the stock which represents only equity value, '
        'and so we need to extract the equity value from the enterprise value by removing the other components',
        'Many struggle with the concept that additional cash reduces enterprise value. I think it is useful to '
        'think through scenarios with the two interpretations of enterprise value: asset value or cost to acquire '
        'the company. In the context of cost to acquire, if an acquirer buys the business, they immediately own that '
        'cash on hand, so really the cash on hand offsets the purchase price. In the context of asset value, imagine '
        'two companies with identical operations. One decides to issue an additional \$10M of stock just to put cash '
        'on the balance sheet. Now they have \$10M of additional equity value, and if cash also added to enterprise value '
        'then all of a sudden they would be worth \$20M more than the other company despite the same operations. If the '
        'cash comes in the equation negatively, then there is no change in value for the stock issuance, which makes '
        'sense as the two companies still have the same operations'
    ],
                         title=title)
    resources = []
    return Lecture(title,
                   week_covered,
                   notes,
                   youtube_id=youtube_id,
                   resources=resources)
Ejemplo n.º 15
0
def get_implement_dynamic_salary_excel_lecture() -> Lecture:
    title = 'Implementing the Dynamic Salary Model'
    youtube_id = 'uU3Za6p3KJs'
    week_covered = 2
    notes = LectureNotes([
        'We are building this model from scratch as it is so different from the original',
        'We can break this larger problem down into three sub-problems: determining '
        'salary over time, determining wealth over time, and determining when the '
        'individual can retire. Each of these become worksheets in the model',
        'In the overall inputs, it is good to have sections if inputs are relevant '
        'only to individual sub-problems. Also reference over the inputs onto the '
        'individual sheet for both visual organization of having everything for the '
        'calculation on one sheet as well as keeping cell references shorter',
        '=IF and =MOD combined can figure out whether it is a promotion year',
        'A cumulative sum can be used to determine how many promotions have occurred '
        'up until a given point in time',
        'Calculating factors helps split out the calculation and make it more clear'
    ],
                         title=title)
    resources = [
        RESOURCES.examples.intro.excel.dynamic_salary_retirement_model,
    ]
    return Lecture(title,
                   week_covered,
                   notes,
                   youtube_id=youtube_id,
                   resources=resources)
Ejemplo n.º 16
0
def get_project_1_lecture() -> Lecture:
    project_title = 'Excel and Python TVM'
    project_num = 1
    title = f'Project {project_num} - {project_title}'
    youtube_id = 'vcvE5RrtrL4'
    week_covered = 2
    notes = LectureNotes([
        'This project is really about cash flow modeling which is a huge part of financial modeling.',
        'This is a classic capital budgeting problem. Buy production capacity, produce units for variable '
        'cost, maximize NPV based on selecting the investment in production capacity and unit volume',
        'Leave the bonus for last. It is fairly separate from the rest of the problem. The bonus is really '
        'intended for the more advanced students coming in with Python or programming experience who did '
        'not have a hard time with the main project to provide some additional learning. Usually very few '
        'students complete the bonuses',
        'You are completing the entire project in both Excel and Python separately so we can understand '
        'the differences',
        'Please start as early as you can. This project has the highest learning curve and students who '
        'have waited to the last minute have ended up struggling in the entire course'
    ],
                         title=title)
    resources = [
        *RESOURCES.projects.project_1.resources(),
    ]
    return Lecture(title,
                   week_covered,
                   notes,
                   youtube_id=youtube_id,
                   resources=resources)
Ejemplo n.º 17
0
def get_visualization_intro_lecture() -> Lecture:
    title = 'Introduction to Visualization'
    youtube_id = 'CsBirrZ3uFc'
    week_covered = 5
    notes = LectureNotes([
        'Visualization is a key modeling concept as often we have many different outputs to understand, '
        'but humans are terrible at getting understanding by looking at lots of numbers',
        'Thoughtfully creating appropriate visualizations will allow someone to glance at your model '
        'and gain immediate understanding at a much richer level',
        'Tables are a more primitive form of visualization which lay out the numbers in a better format, '
        'while charts/graphs can summarize a lot of numbers in one picture',
        'For the most part, visualization in Excel is straightforward: insert chart and follow the prompts. '
        'Your numbers should already be in tables.',
        'Python, being open-source and developed by the community, has a dizzying array of options for '
        'visualization. There is far more than you can do in Excel, including interactive plots, '
        'but it is generally a bit more complicated to work with',
        'In this course, we will focus on Pandas (powered by matplotlib) to produce graphs simply',
    ],
                         title=title)
    resources = []
    return Lecture(title,
                   week_covered,
                   notes,
                   youtube_id=youtube_id,
                   resources=resources)
Ejemplo n.º 18
0
def get_project_overview_lecture() -> Lecture:
    project_title = 'Project Grading Overview'
    project_num = 0
    title = f'Project {project_num} - {project_title}'
    youtube_id = 'SW4Yk-pQdA8'
    week_covered = 2
    notes = LectureNotes([
        'The biggest part of the typical project grade is accuracy, but that only represents 60% of the total.',
        'Answers with the baseline model inputs are often provided, so use these to ensure you have built the model '
        'correctly. But you cannot rely on these alone. Your model needs to be able to work with any reasonable value '
        'for any input and adjust appropriately. After you have matched the baseline result, then start changing '
        'around the inputs and ensure that your model responds in a way that is logical and consistent with the '
        'change in the input.',
        'I have built out automated grading for the first three projects for the accuracy. It will tell me if '
        'everything in your model works properly. In order for this auto-grading to work properly, you need '
        'to conform to the expectations of the project, this is why I make following the template a separate grade.',
        'If the auto-grader finds that your model does not work properly, then I go through it in detail to understand '
        'where the issues are occurring. I fix the issues one by one until your model works properly. Then I give '
        'comments on where exactly you went wrong and take off points appropriately.',
        "Regardless of the auto-grading, I go through everyone's model line by line to assess the readability and "
        "formatting of the model."
    ],
                         title=title)
    resources = [
        RESOURCES.projects.grading_overview,
    ]
    return Lecture(title,
                   week_covered,
                   notes,
                   youtube_id=youtube_id,
                   resources=resources)
Ejemplo n.º 19
0
def get_python_classes_lecture() -> Lecture:
    title = 'Creating Python Data Types with Classes'
    youtube_id = 'Q9UJ4Nqoung'
    week_covered = 3
    notes = LectureNotes([
        "We've talked about strings, floats, ints, lists, tuples, and dicts as basic data types. It is "
        "possible to define your own custom data types as well using classes",
        'I will not be expecting you to construct your own data types in this class. This section is mainly '
        'so you can understand how Python works in general. We will start using custom data types defined '
        'in external packages so it is good to have an understanding of this and how to use custom objects.',
        'The difference between objects of the same data type (same class definition) is the data contained '
        'within. They will all have the same functions attached to them (called methods when it is functions '
        'attached to objects)',
        'Feel free to study the car example in more detail to get a greater understanding of how to define '
        'classes, but we will not spend time on this',
        'Dataclasses are simplified versions of classes meant to group data together. We will use them '
        'to organize our model inputs.',
        'The lab exercises test working with externally-defined custom data types and creating and using '
        'dataclasses for our model inputs.',
    ],
                         title=title)
    resources = LECTURE_4_COMMON_RESOURCES + [
        RESOURCES.examples.intro.python.car_example,
        LectureResource(
            'Python Classes Official Reference',
            external_url='https://docs.python.org/3/reference/datamodel.html')
    ]
    return Lecture(title,
                   week_covered,
                   notes,
                   youtube_id=youtube_id,
                   resources=resources)
Ejemplo n.º 20
0
def get_project_2_lecture() -> Lecture:
    project_title = 'Probabilistic Loan Pricing'
    project_num = 2
    title = f'Project {project_num} - {project_title}'
    youtube_id = 'Jxuuw8mM-vQ'
    week_covered = 7
    notes = LectureNotes([
        'The focus of this project is to reinforce probabilistic modeling and to solve a common '
        'problem faced by lenders: deciding the loan terms to offer',
        'This project also tests your ability to explore the parameter space and visualize the results, '
        'extending the base model',
        'This model typically incorporates internal randomness. This means you will get a different result each time '
        'you run your model. You can increase the number of iterations to get a more consistent result, but '
        'it will also take longer for the model to run. When checking your answers against the provided solutions, they '
        'will not match exactly, but as you run the model multiple times each number should be similar to the reported '
        'answers. When you are ready to submit the model, run it with '
        '1000 iterations and be sure to allow time for this',
        'This project, and the remaining projects going forward in the course, may be submitted as an '
        'Excel model, a Python model, or a combination model that uses both Python and Excel',
        'It is up to you how you want to structure the model and which tools to use, but this problem is '
        'difficult to solve using only Excel. If you want to work in Excel as much as possible, I would '
        'recommend building the base deterministic model in Excel then handle the randomness and exploring '
        'the parameter space using Python',
        'As always, save the bonus for last, though students have generally found this bonus exercise easier than '
        'that of the first project',
    ],
                         title=title)
    resources = [
        *RESOURCES.projects.project_2.resources(),
    ]
    return Lecture(title,
                   week_covered,
                   notes,
                   youtube_id=youtube_id,
                   resources=resources)
Ejemplo n.º 21
0
def get_lists_lecture() -> Lecture:
    title = 'Grouping Objects with Python Lists'
    youtube_id = 'a8UeoMMgLQw'
    week_covered = 3
    notes = LectureNotes([
        'Lists are one of the basic container data types in Python. They hold other objects so we '
        'can work with them as a group',
        'Lists hold objects one by one in order and objects can be looked up from the list using '
        'the numeric index of the object',
        'It is a very common pattern to create an empty list, then go through some logic in a loop to create '
        'the object you want in the list and add it in each run of the loop',
        'This numeric index is zero-based, so look up the first object by 0, the second object by 1, '
        'and so on.',
        'We can pass a slice to get a group of objects out of the list as a new list or '
        'a single integer to get a single object out of the list',
        'Negative numbers means count from the end of the list, -1 is last object, -2 is second to '
        'last object, and so on',
        "Objects can be added to the list when it is created, but also later on using .append "
        "and .insert. Objects can be removed using .pop",
        'Lab exercise 1 tests list building for loop pattern, 2 tests adding objects to lists, and '
        '3 tests list indexing and slicing'
    ],
                         title=title)
    resources = LECTURE_4_COMMON_RESOURCES
    return Lecture(title,
                   week_covered,
                   notes,
                   youtube_id=youtube_id,
                   resources=resources)
Ejemplo n.º 22
0
def get_dynamic_salary_model_python_lecture() -> Lecture:
    title = 'Salaries in the Python Dynamic Salary Retirement Model'
    youtube_id = '190Xci0yDpA'
    week_covered = 4
    notes = LectureNotes([
        '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',
    ],
                         title=title)
    resources = [
        RESOURCES.examples.intro.python.dynamic_salary_retirement_model,
    ]
    return Lecture(title,
                   week_covered,
                   notes,
                   youtube_id=youtube_id,
                   resources=resources)
Ejemplo n.º 23
0
def get_syllabus_lecture() -> Lecture:
    title = 'Syllabus'
    youtube_id = 'k5KxoG-Oi-A'
    week_covered = 1
    notes = LectureNotes([
        "Get the textbook if you're someone who learns well from reading, and doesn't have a "
        "lot of Excel experience. Otherwise it probably won't be very helpful",
        "Mac and Windows are both fine, though I don't have much experience on Mac so I won't be as "
        "helpful with OS-specific issues",
        "This class is hard. Those who don't have good technical skills already should prepare to "
        "put a lot of work in or consider another course.",
        "We focus on the modeling process and skills, not as much on the finance, so you need to "
        "have a good knowledge of finance first.",
        "If you don't have any of the required Excel skills, take a look at the resources provided on "
        "the syllabus and ask me any questions",
        "The lab sessions are perhaps the most valuable part of the course because you can get "
        "lots of hands on feedback",
        "I have consistently heard that these are the hardest (and most rewarding) projects in the "
        "finance program at UF. Start early and ask questions.",
        "I would highly encourage those who don't have Python experience to work through some of the "
        "resources in the syllabus. This will greatly enhance your learning and allow you to focus on the "
        "models rather than struggling with programming basics.",
        "Please review the syllabus document for the grading structure",
    ],
                         title=title)
    return Lecture(title, week_covered, notes, youtube_id=youtube_id)
Ejemplo n.º 24
0
def get_debt_details_pipeline_lecture() -> Lecture:
    title = 'Creating a Data Loading Module for Capital IQ Debt Details'
    youtube_id = 'mL4hDzrvxL0'
    week_covered = 15
    notes = LectureNotes([
        'For the DCF model we have explored using the market value of individual debt instruments to estimate '
        'the market value of debt for the whole company',
        'For Project 3, we looked at using Capital IQ as the source of those debt details',
        'Here I examine how to automate the loading and cleaning of the debt details from Capital IQ, '
        'so they are ready to be worked with in the model',
        'I also look at taking the resulting code and making a Python module, so it can be reused in future models',
        'To clean up the data, I use a combination of Pandas methods, string methods, and regular '
        'expressions (regex)'
    ],
                         title=title)
    resources = [
        RESOURCES.examples.data_pipeline.load_capiq_debt_module,
        RESOURCES.projects.project_3.wmt_debt_details,
        RESOURCES.examples.data_pipeline.pfizer_debt_details,
    ]
    return Lecture(title,
                   week_covered,
                   notes,
                   youtube_id=youtube_id,
                   resources=resources)
Ejemplo n.º 25
0
def get_intro_internal_randomness_lecture() -> Lecture:
    title = 'Introduction to Internal Randomness'
    youtube_id = '9jPlnhUCQzY'
    week_covered = 8
    notes = LectureNotes([
        'Internal randomness can be very powerful but also has one major drawback: your model is no longer '
        'deterministic, so the same inputs will produce different outputs each time. While this is the goal of '
        'internal randomness, it also makes it difficult to know if the model is working correctly.',
        'You should only use internal randomness in cases where the randomness is so integral to the model '
        "that it wouldn't make sense to have the model without it",
        "The external counterpart to internal randomness is Monte Carlo simulation, which will be the next "
        "extension we examine for our models. In most cases, Monte Carlo simulation will achieve your goals and "
        "you don't need internal randomness",
        'Pick distributions which make sense for your inputs, but usually just pick a normal distribution with '
        'reasonable mean and standard deviation',
        'For the mean, use the historical mean or your best estimate of the expected value of the input. For the '
        'standard deviation, a rule of thumb is that you should pick a standard deviation such that +/- 1x stdev '
        'changes from the mean are common, 2x occur occasionally, 3x are rare, and 4x will almost never occur.'
    ],
                         title=title)
    resources = []
    return Lecture(title,
                   week_covered,
                   notes,
                   youtube_id=youtube_id,
                   resources=resources)
Ejemplo n.º 26
0
def get_relaxing_salary_assumption_lecture() -> Lecture:
    title = 'Relaxing the Salary Assumption'
    youtube_id = '_PuQgUIpMTg'
    week_covered = 2
    notes = LectureNotes([
        'We will experience first-hand the tradeoff in relaxing assumptions: greater accuracy '
        'but also greater complexity',
        'We are going to now a fairly realistic assumption for salary. It is still not however '
        'the most realistic possible. For example, promotions should be less frequent and '
        'smaller raises during recessions and more frequent/larger raises during expansionary periods. '
        'Promotions should not come at a fixed interval, they should be faster in the early stages '
        'of the career and there should be randomness to it. The model should be run many times '
        'to understand the distribution of years to retirement based on the randomness in the salary.',
        "Obviously that would lead to quite a complex model already, and that's only thinking about "
        "the salary assumption.",
        'In deciding how much to relax assumptions, the desired degree of accuracy of the model is '
        'critically important. For what decisions is the model being used? Will those decisions be any '
        'different if the model increases in accuracy? What is the cost of being wrong?'
    ],
                         title=title)
    resources = []
    return Lecture(title,
                   week_covered,
                   notes,
                   youtube_id=youtube_id,
                   resources=resources)
Ejemplo n.º 27
0
def get_probability_math_review_lecture() -> Lecture:
    title = 'Math Review for Probabilistic Modeling'
    youtube_id = '2OIjIrtUERQ'
    week_covered = 7
    notes = LectureNotes([
        'Discrete variables: specific values, continuous variables: range of values. Note that an underlying '
        'variable can be continuous but the modeler can choose to make it discrete within the model to '
        'simplify it. E.g. condition of the economy is continuous, but you might make it discrete by '
        'classifying the economic conditions into recession, neutral, or expansion. This does not work in the '
        'other direction: a variable which is truly discrete cannot be made continuous',
        'Expected value is a key concept in probability theory. We will use it in scenario analysis to get '
        'the expected outcome across multiple different cases of the inputs',
        'The variance graph shows two series with the same mean but different variances. Variance is a measure '
        'of how much the value is moving around. If it moves a lot, it has high variance. Variance has nothing '
        'to do with the average, mean, or expected value.',
        'Probability distributions tell you how likely it is to observe different values of a given variable',
        'Discrete variables: think table of values with probabilities. Continuous variables: think curve, '
        'usually displayed by a graph but defined by a function',
        'The CLT is extremely powerful, because of it most of the distributions for continuous variables '
        'are normal distributions. So if we need to pick a distribution for a variable, the normal distribution '
        'is reasonable choice the majority of the time'
    ],
                         title=title)
    resources = []
    return Lecture(title,
                   week_covered,
                   notes,
                   youtube_id=youtube_id,
                   resources=resources)
Ejemplo n.º 28
0
def get_extending_simple_retirement_model_lecture() -> Lecture:
    title = 'Simple Retirement Model Assumptions'
    youtube_id = 'kSuy87EELWE'
    week_covered = 2
    notes = LectureNotes([
        'Part of the reason we begin with such a seemingly simple problem is to show '
        'how complex it is to model any real-world situation with a high degree of accuracy',
        'You may have thought we solved the retirement problem already, but there is '
        'a lot that we left out intentionally to make the problem simpler',
        'Assumptions are key to any model. They allow you to simplify the problem so it is '
        'actually feasible to solve. The stronger your assumptions, the less accurate the model, '
        'but the simpler it is to implement.',
        'No real-world model will ever be perfectly accurate. The world is just too complex to capture it all. '
        'We always have to settle for some level of assumptions',
        'The assumptions form the base of the model, from which we can generate the logic and equations',
        "There can be many different possible assumptions for a given model. It is a big part of the modeler's "
        "job to pick the best assumptions that can get the model as accurate as needed while balancing the costs "
        "of building and maintaining complex models"
    ],
                         title=title)
    resources = []
    return Lecture(title,
                   week_covered,
                   notes,
                   youtube_id=youtube_id,
                   resources=resources)
Ejemplo n.º 29
0
def get_xlwings_combining_excel_python_lecture() -> Lecture:
    title = 'Combining Excel and Python using xlwings'
    youtube_id = 'LYzVXHCJs40'
    week_covered = 9
    notes = LectureNotes([
        'xlwings is a package that makes it quite easy to combine Excel and Python in ways that should work for '
        'nearly every use case',
        'This can be done without xlwings using the Microsoft COM API in Python, but xlwings is far more convenient',
        'We are focusing here on only manipulating Excel from Python, but I encourage you to explore running Python '
        'from Excel on your own time',
        'Now with xlwings, anything that you can do in Excel, you can make it happen from Python',
        'It is easy to transfer individual values, ranges, and tables back and forth between Excel and Python',
        'For those who have a lot of difficulty with Python and feel comfortable in Excel, xlwings allows building out '
        'the core model in Excel and adding extensions such as Monte Carlo simulation, sensitivity analysis, and '
        'scenario analysis in Python',
    ],
                         title=title)
    resources = [
        RESOURCES.examples.connecting_python_excel.xlwings.example_notebook,
        RESOURCES.examples.connecting_python_excel.xlwings.example_workbook,
        RESOURCES.labs.connecting_python_excel.xlwings.lab_xlsx,
    ]
    return Lecture(title,
                   week_covered,
                   notes,
                   youtube_id=youtube_id,
                   resources=resources)
Ejemplo n.º 30
0
def get_python_sensitivity_analysis_lab_lecture() -> Lecture:
    title = 'Lab Exercise - Adding Sensitivity Analysis to Project 1 - Python'
    youtube_id = 'YtE5oRv2Ot4'
    week_covered = 7
    notes = LectureNotes([
        'The lab exercise here is the same as that we did for Excel but now just doing it '
        'in Python',
        'You are free to use the manual approach or the sensitivity package but I would recommend '
        'the sensitivity package',
        'Be sure to upgrade your sensitivity package before working on the exercise',
        'The lecture on adding sensitivity analysis to the Python Dynamic Salary Retirement model '
        'will be very helpful for this',
        'You may need to restructure your model before you can even begin adding sensitivity analysis. '
        'You must have a function which accepts the data and produces the final output from that data, and '
        'your functions must not access the overall model_data'
    ],
                         title=title)
    resources = [
        RESOURCES.examples.intro.python.dynamic_salary_retirement_model,
    ]
    return Lecture(title,
                   week_covered,
                   notes,
                   youtube_id=youtube_id,
                   resources=resources)