def explore_parameters_graphic() -> lg.TikZPicture:
    model_style = ['fill=orange!30'] + ALL_NODE_STYLE

    prior_input = None
    pic_contents = []
    output_nodes = []
    for i in range(NUM_MODEL_ROWS):
        if prior_input is None:
            input_position = None
        else:
            input_position = lg.Below(of=prior_input)
        input_node = lg.Node('Inputs', input_position, options=_io_style(i))
        model_node = lg.Node('Model',
                             lg.Right(of=input_node),
                             options=model_style)
        output_node = lg.Node('Outputs',
                              lg.Right(of=model_node),
                              options=_io_style(i))
        output_nodes.append(output_node)
        im_arrow = lg.Arrow(input_node, model_node)
        mo_arrow = lg.Arrow(model_node, output_node)
        pic_contents.extend(
            [input_node, model_node, output_node, im_arrow, mo_arrow])
        prior_input = input_node
    visualize_index = math.floor(NUM_MODEL_ROWS / 2)
    visualize_node = lg.Node('Visualization',
                             lg.Right(of=output_nodes[visualize_index]),
                             options=model_style)
    visualize_arrows = [
        lg.Arrow(out_node, visualize_node) for out_node in output_nodes
    ]
    pic_contents.append(visualize_node)
    pic_contents.extend(visualize_arrows)
    tp = lg.TikZPicture(pic_contents)
    return tp
def internal_randomness_graphic() -> lg.TikZPicture:
    model_style = ['fill=orange!30'] + ALL_NODE_STYLE
    middle_index = math.floor(NUM_MODEL_ROWS / 2)

    output_nodes = []
    pic_contents = []
    for i in range(NUM_MODEL_ROWS):
        if i == 0:
            output_position = None
        else:
            output_position = lg.Below(
                of=output_node)  # below last output node

        output_node = lg.Node('Outputs', output_position, options=_io_style(i))
        output_nodes.append(output_node)
        pic_contents.append(output_node)

    center_output = output_nodes[middle_index]
    model_node = lg.Node('Model',
                         lg.Left(of=center_output),
                         options=model_style)
    input_node = lg.Node('Inputs',
                         lg.Left(of=model_node),
                         options=_io_style(middle_index))

    im_arrow = lg.Arrow(input_node, model_node)
    output_arrows = [
        lg.Arrow(model_node, out_node) for out_node in output_nodes
    ]
    pic_contents.extend([model_node, input_node, im_arrow, *output_arrows])

    tp = lg.TikZPicture(pic_contents)
    return tp
Пример #3
0
    def _get_contents(self):
        all_node_options = ['every text node part/.style={align=center}']

        debt_options = all_node_options + ['fill=blue']

        debt_text_options = all_node_options + ['text=white']

        equity_options = all_node_options + ['fill=orange']

        wacc_options = all_node_options + ['fill=violet!80']

        debt_equity_width = 3

        total_height = 4
        debt_height = self.weight_of_debt * total_height
        equity_height = self.weight_of_equity * total_height

        debt_contents = [
            'Debt',
            pl.OutputLineBreak(),
            f'Pre-tax: {self.cost_of_debt:.2%}',
            pl.OutputLineBreak(),
            f'After: {self.after_tax_cost_of_debt:.2%}',
        ]

        equity_contents = [
            'Equity',
            pl.OutputLineBreak(), f'{self.cost_of_equity:.2%}'
        ]

        wacc_contents = ['WACC', pl.OutputLineBreak(), f'{self.wacc:.2%}']

        debt_rect = lg.Rectangle(debt_equity_width,
                                 debt_height,
                                 debt_contents,
                                 shape_options=debt_options,
                                 text_options=debt_text_options)
        equity_rect = lg.Rectangle(debt_equity_width,
                                   equity_height,
                                   equity_contents,
                                   offset=(0, 2.15),
                                   shape_options=equity_options)
        wacc_rect = lg.Rectangle(2,
                                 4.3,
                                 wacc_contents,
                                 offset=(3, 1.5),
                                 shape_options=wacc_options)

        contents = lg.TikZPicture([
            pl.TextSize(-1), debt_rect, equity_rect, wacc_rect,
            lg.Arrow(debt_rect, wacc_rect),
            lg.Arrow(equity_rect, wacc_rect)
        ])

        return contents
def get_retirement_model_overview_frame():
    darker_green_def = pl.RGB(15, 82, 13, color_name='darkergreen')

    model_block_options = ['fill=darkergreen!60']

    model_sub_block_options = ['fill=darkergreen']

    text_options = ['text=white']

    model_node = lg.Rectangle(5,
                              8,
                              offset=(1.25, 4),
                              contents=pl.Bold('Model'),
                              content_position='bottom',
                              content_offset=0.2,
                              shape_options=model_block_options,
                              text_options=text_options)
    salary_node = lg.Rectangle(4,
                               1.75,
                               offset=(1.25, 6.75),
                               contents='Salary',
                               shape_options=model_sub_block_options,
                               text_options=text_options)
    wealth_node = lg.Rectangle(4,
                               1.75,
                               offset=(1.25, 4.25),
                               contents='Wealths',
                               shape_options=model_sub_block_options,
                               text_options=text_options)
    retirement_node = lg.Rectangle(4,
                                   1.75,
                                   offset=(1.25, 1.75),
                                   contents='Retirement',
                                   shape_options=model_sub_block_options,
                                   text_options=text_options)

    return lp.GraphicFrame([
        lg.TikZPicture([
            model_node, salary_node, wealth_node, retirement_node,
            lg.Arrow(salary_node, wealth_node),
            lg.Arrow(wealth_node, retirement_node)
        ])
    ],
                           title='The Structure of the Retirement Model',
                           pre_env_contents=darker_green_def)
Пример #5
0
def get_model_structure_graphic() -> lg.TikZPicture:
    inputs_block_options = ['fill=orange!30']

    model_block_options = ['fill=blue!50']

    sub_model_block_options = ['fill=blue!90']

    step_block_options = ['fill=cyan!20']

    outputs_block_options = ['fill=green!20']

    text_options = ['text=white']

    step_text_options = ['text=black']

    inputs_text_options = outputs_text_options = step_text_options

    arrow_options = [
        'line width=0.75mm',
    ]

    inputs_rectangle = lg.Rectangle(2,
                                    8,
                                    offset=(-3.35, 4),
                                    contents=pl.Bold('Inputs'),
                                    shape_options=inputs_block_options,
                                    text_options=inputs_text_options)

    model_rectangle = lg.Rectangle(5,
                                   8,
                                   offset=(1.25, 4),
                                   contents=pl.Bold('Model'),
                                   content_position='bottom',
                                   content_offset=0.2,
                                   shape_options=model_block_options,
                                   text_options=text_options)

    outputs_rectangle = lg.Rectangle(2,
                                     8,
                                     offset=(5.85, 4),
                                     contents=pl.Bold('Outputs'),
                                     shape_options=outputs_block_options,
                                     text_options=outputs_text_options)

    sub_model_rectangles = []
    step_rectangles = []
    for i in range(3):
        y_offset = 1.75 + i * 2.5
        sub_model_rectangles.append(
            lg.Rectangle(4,
                         1.75,
                         offset=(1.25, y_offset),
                         contents='Sub-Model',
                         shape_options=sub_model_block_options,
                         text_options=text_options,
                         content_position='bottom'), )
        for j in range(3):
            x_offset = j * 1.25
            step_rectangles.append(
                lg.Rectangle(
                    1.1,
                    1,
                    offset=(x_offset, y_offset + 0.2),
                    contents='Step',
                    shape_options=step_block_options,
                    text_options=step_text_options,
                ))

    arrows = [
        lg.Arrow((-2.3, 4), (-1.3, 4), options=arrow_options),
        lg.Arrow((3.8, 4), (4.8, 4), options=arrow_options),
    ]

    return lg.TikZPicture([
        inputs_rectangle,
        model_rectangle,
        *sub_model_rectangles,
        *step_rectangles,
        outputs_rectangle,
        *arrows,
    ])
Пример #6
0
def get_dcf_graphic(include_output: bool = True, include_fcf: bool = True, include_coc: bool = True) -> lg.TikZPicture:
    all_node_options = [
        'inner sep=10pt',
        'rounded corners'
    ]

    model_node_options = all_node_options + [
        'fill=blue',
        'text=white'
    ]

    output_node_options = all_node_options + [
        'fill=green'
    ]

    input_node_options = all_node_options + [
        'fill=orange!60'
    ]


    all_nodes = []
    all_arrows = []

    if include_output:
        stock_value_node = lg.Node('Stock Value', options=output_node_options)

        value_node = lg.Node('Enterprise Value', location=lg.Above(of=stock_value_node), options=output_node_options)
        all_nodes.extend([stock_value_node, value_node])
        all_arrows.append(lg.Arrow(value_node, stock_value_node))

    if include_fcf:
        if not include_output:
            output_loc = None
        else:
            output_loc = lg.Above(lg.Right(of=value_node, by=0.1))

        fcf_node = lg.Node('Free Cash Flows', location=output_loc, options=model_node_options)
        historical_financials_node = lg.Node('Historical Financial Statements',
                                             location=lg.Above(lg.Right(of=fcf_node, by=0.1)),
                                             options=input_node_options)
        projections_node = lg.Node('Analyst Projections', location=lg.Above(lg.Left(of=fcf_node, by=0.1)),
                                   options=input_node_options)
        all_nodes.extend([fcf_node, historical_financials_node, projections_node])
        if include_output:
            all_arrows.append(lg.Arrow(fcf_node, value_node))
        all_arrows.extend([
            lg.Arrow(historical_financials_node, fcf_node),
            lg.Arrow(projections_node, fcf_node),
        ])

    if include_coc:
        if not include_output:
            output_loc = None
        else:
            output_loc = lg.Above(lg.Left(of=value_node, by=0.1))


        cost_of_capital_node = lg.Node('Cost of Capital', location=output_loc,
                                   options=model_node_options)
        debt_node = lg.Node('Current Debt Schedule', location=lg.Left(of=cost_of_capital_node), options=input_node_options)
        prices_node = lg.Node('Historical Stock Prices', location=lg.Above(lg.Left(of=cost_of_capital_node, by=0.1)),
                              options=input_node_options)
        all_nodes.extend([cost_of_capital_node, debt_node, prices_node])
        if include_output:
            all_arrows.append(lg.Arrow(cost_of_capital_node, value_node))
        all_arrows.extend([
            lg.Arrow(debt_node, cost_of_capital_node),
            lg.Arrow(prices_node, cost_of_capital_node),
        ])

    return lg.TikZPicture(
            [
                *all_nodes,
                *all_arrows
            ]
        )