Esempio n. 1
0
    def __getitem__(self, item):
        if not isinstance(item, (list, tuple)):
            inc_statement = self.income_statements[item]
            bs = self.balance_sheets[item]
            date_item = pd.to_datetime(item)
            inc_statements = IncomeStatements({date_item: inc_statement})
            b_sheets = BalanceSheets({date_item: bs})
        else:
            inc_statements = self.income_statements[item]
            b_sheets = self.balance_sheets[item]

        return FinancialStatements(inc_statements, b_sheets)
Esempio n. 2
0
def _combine_statements(
        statements: FinancialStatements, other_statements: FinancialStatements,
        func: Callable) -> Tuple[IncomeStatements, BalanceSheets]:
    if isinstance(other_statements, (float, int)):
        new_inc_df = func(statements.income_statements.df, other_statements)
        new_inc = IncomeStatements.from_df(
            new_inc_df,
            statements.income_statements.config.items,
            disp_unextracted=False)
        new_bs_df = func(statements.balance_sheets.df, other_statements)
        new_bs = BalanceSheets.from_df(new_bs_df,
                                       statements.balance_sheets.config.items,
                                       disp_unextracted=False)
    elif isinstance(other_statements, FinancialStatements):
        new_inc = func(statements.income_statements,
                       other_statements.income_statements)
        new_bs = func(statements.balance_sheets,
                      other_statements.balance_sheets)
    else:
        raise NotImplementedError(
            f'cannot {func.__name__} type {type(statements)} to type {type(other_statements)}'
        )

    return new_inc, new_bs
Esempio n. 3
0
def quarterly_stockrow_income_stmt_cat(quarterly_stockrow_income_df_cat) -> IncomeStatements:
    stmt = IncomeStatements.from_df(quarterly_stockrow_income_df_cat)
    return stmt
Esempio n. 4
0
def annual_stockrow_income_stmt_cat(annual_stockrow_income_df_cat) -> IncomeStatements:
    stmt = IncomeStatements.from_df(annual_stockrow_income_df_cat)
    return stmt
Esempio n. 5
0
def quarterly_capiq_income_stmt(quarterly_capiq_income_df) -> IncomeStatements:
    stmt = IncomeStatements.from_df(quarterly_capiq_income_df)
    return stmt
Esempio n. 6
0
def annual_capiq_income_stmt(annual_capiq_income_df) -> IncomeStatements:
    stmt = IncomeStatements.from_df(annual_capiq_income_df)
    return stmt
Esempio n. 7
0
def get_dcf_fcf_calculation_exercise() -> LabExercise:

    lab_1_inputs = dict(adjustments=100,
                        change_ar=1000,
                        change_inventory=500,
                        change_ap=800,
                        change_ppe=2000,
                        dep_amort=200,
                        net_income=300)

    lab_1_nwc = lab_1_inputs['change_ar'] + lab_1_inputs[
        'change_inventory'] - lab_1_inputs['change_ap']
    lab_1_capex = lab_1_inputs['change_ppe'] + lab_1_inputs['dep_amort']
    lab_1_fcf = lab_1_inputs['net_income'] + lab_1_inputs[
        'adjustments'] - lab_1_nwc - lab_1_capex

    stmt_folder = LAB_EXERCISES_PATH / 'DCF' / 'FCF'
    bs_path = os.path.join(stmt_folder, 'WMT Balance Sheet.xlsx')
    inc_path = os.path.join(stmt_folder, 'WMT Income Statement.xlsx')

    bs_df = pd.read_excel(bs_path, index_col=0)
    inc_df = pd.read_excel(inc_path, index_col=0)

    bs_data = BalanceSheets.from_df(bs_df)
    inc_data = IncomeStatements.from_df(inc_df)
    stmts = FinancialStatements(inc_data, bs_data)
    lab_2_date_1 = '2019-04-30'
    lab_2_date_2 = '2019-07-31'

    bullet_contents = [
        [
            'Calculate free cash flow from the following information:',
            f"Net income is {lab_1_inputs['net_income']}, the total of non-cash expenditures is "
            f"{lab_1_inputs['adjustments']}, "
            f"the changes in accounts receivable, inventory, accounts payable, and PPE are {lab_1_inputs['change_ar']}, "
            f"{lab_1_inputs['change_inventory']}, {lab_1_inputs['change_ap']}, and {lab_1_inputs['change_ppe']}, "
            f"and depreciation & amortization is {lab_1_inputs['dep_amort']}."
        ],
        [
            'Load in the income statement and balance sheet data associated with Project 3, "WMT Balance Sheet.xlsx" '
            'and "WMT Income Statement.xlsx"',
            'Calculate the free cash flows from these data. Note that some items are missing in these data such as '
            'depreciation. You will just need to exclude any missing items from your calculation',
            f'Get the FCFs for {lab_2_date_1} and {lab_2_date_2}.'
        ]
    ]

    answer_contents = [
        [
            fr'The NWC is \${lab_1_nwc:,.0f}',
            fr'The CapEx is \${lab_1_capex:,.0f}',
            fr'The FCF is \${lab_1_fcf:,.0f}'
        ],
        [
            fr'The FCF for {lab_2_date_1} is \${stmts.fcf[lab_2_date_1]:,.0f}',
            fr'The FCF for {lab_2_date_2} is \${stmts.fcf[lab_2_date_2]:,.0f}',
        ]
    ]

    return LabExercise(bullet_contents,
                       'Calculate FCFs',
                       f"Free Cash Flow Calculation",
                       label='lab:dcf-fcf-calc',
                       answers_content=answer_contents)
Esempio n. 8
0
def get_fcf_calculation_lab_lecture() -> LabExerciseLecture:
    title = 'Free Cash Flow Calculation'
    short_title = 'Calculate FCF Lab'
    youtube_id = 'zVTkT5p0SHs'
    week_covered = 12

    lab_1_inputs = dict(adjustments=100,
                        change_ar=1000,
                        change_inventory=500,
                        change_ap=800,
                        change_ppe=2000,
                        dep_amort=200,
                        net_income=300)

    lab_1_nwc = lab_1_inputs['change_ar'] + lab_1_inputs[
        'change_inventory'] - lab_1_inputs['change_ap']
    lab_1_capex = lab_1_inputs['change_ppe'] + lab_1_inputs['dep_amort']
    lab_1_fcf = lab_1_inputs['net_income'] + lab_1_inputs[
        'adjustments'] - lab_1_nwc - lab_1_capex

    stmt_folder = LAB_EXERCISES_PATH / 'DCF' / 'FCF'
    bs_path = os.path.join(stmt_folder, 'WMT Balance Sheet.xlsx')
    inc_path = os.path.join(stmt_folder, 'WMT Income Statement.xlsx')

    bs_df = pd.read_excel(bs_path, index_col=0)
    inc_df = pd.read_excel(inc_path, index_col=0)

    bs_data = BalanceSheets.from_df(bs_df)
    inc_data = IncomeStatements.from_df(inc_df)
    stmts = FinancialStatements(inc_data, bs_data)
    lab_2_date_1 = '2019-04-30'
    lab_2_date_2 = '2019-07-31'

    bullets = [
        [
            'Calculate free cash flow from the following information:',
            f"Net income is {lab_1_inputs['net_income']}, the total of non-cash expenditures is "
            f"{lab_1_inputs['adjustments']}, "
            f"the changes in accounts receivable, inventory, accounts payable, and PPE are {lab_1_inputs['change_ar']}, "
            f"{lab_1_inputs['change_inventory']}, {lab_1_inputs['change_ap']}, and {lab_1_inputs['change_ppe']}, "
            f"and depreciation & amortization is {lab_1_inputs['dep_amort']}."
        ],
        [
            'Load in the income statement and balance sheet data associated with Project 3, "WMT Balance Sheet.xlsx" '
            'and "WMT Income Statement.xlsx"',
            'Calculate the free cash flows from these data. Note that some items are missing in these data such as '
            'depreciation. You will just need to exclude any missing items from your calculation',
            f'Get the FCFs for {lab_2_date_1} and {lab_2_date_2}.'
        ]
    ]
    answers = [
        [
            fr'The NWC is \${lab_1_nwc:,.0f}',
            fr'The CapEx is \${lab_1_capex:,.0f}',
            fr'The FCF is \${lab_1_fcf:,.0f}'
        ],
        [
            fr'The FCF for {lab_2_date_1} is \${stmts.fcf[lab_2_date_1]:,.0f}',
            fr'The FCF for {lab_2_date_2} is \${stmts.fcf[lab_2_date_2]:,.0f}',
        ]
    ]
    resources = [
        LECTURE_12_SLIDES,
        RESOURCES.labs.dcf.fcf.wmt_balance_sheet,
        RESOURCES.labs.dcf.fcf.wmt_income_statement,
    ]
    return LabExerciseLecture.from_seq_of_seq(
        title,
        bullet_content=bullets,
        answers_content=answers,
        short_title=short_title,
        youtube_id=youtube_id,
        resources=resources,
        week_covered=week_covered,
    )
Esempio n. 9
0
def quarterly_stockrow_income_stmt_mar(quarterly_stockrow_income_df_mar) -> IncomeStatements:
    stmt = IncomeStatements.from_df(quarterly_stockrow_income_df_mar)
    return stmt
Esempio n. 10
0
def annual_stockrow_income_stmt_mar(annual_stockrow_income_df_mar) -> IncomeStatements:
    stmt = IncomeStatements.from_df(annual_stockrow_income_df_mar)
    return stmt