Ejemplo n.º 1
0
def test_npv():
    df = pd.DataFrame(
        data={
            'cash flow': [-100] + [10] * 12,
            'date':
            [date.today() + relativedelta(months=i) for i in range(13)]
        })
    assert npv(df, 0.1) == approx(14.04634, abs=FLOAT_ABS)
Ejemplo n.º 2
0
def dcf(fcf, wacc, short_term_growth, long_term_growth):
    latest_fcf_date = fcf.index.max()
    dates = pd.date_range(latest_fcf_date, periods=6, freq='365D')[1:]
    future_cash_flows = [fcf[latest_fcf_date]]
    for i in range(5):
        next_year_fcf = future_cash_flows[-1] * (1 + short_term_growth)
        future_cash_flows.append(next_year_fcf)
    future_cash_flows = future_cash_flows[1:]
    df = pd.DataFrame(data={'fcf': future_cash_flows, 'date': dates})
    # df.set_index('date', inplace=True)
    df['terminal value'] = 0
    last_index = df.index[-1]
    last_short_term_fcf = df.at[last_index, 'fcf']
    df.at[last_index, 'terminal value'] = last_short_term_fcf * (
        1 + long_term_growth) / (wacc - long_term_growth)
    df['cash flow'] = df[['fcf', 'terminal value']].apply(sum, axis=1)
    return npv(df, wacc) * sqrt((1 + wacc))
Ejemplo n.º 3
0
def dcf(fcfs, wacc, short_term_growth, long_term_growth):
    latest_fcf_date = fcfs.index.max()
    dates = pd.date_range(latest_fcf_date, periods=6, freq="365D")[1:]
    future_cash_flows = [fcfs[latest_fcf_date]]
    for i in range(5): # 5?
        next_year_fcf = future_cash_flows[-1] * (1 + short_term_growth)
        future_cash_flows.append(next_year_fcf)
    future_cash_flows = future_cash_flows[1:]
    df = pd.DataFrame(data={"fcf": future_cash_flows, "date": dates})
    # df.set_index('date', inplace=True)
    df["terminal value"] = 0
    last_index = df.index[-1]
    last_short_term_fcf = df.at[last_index, "fcf"]
    df.at[last_index, "terminal value"] = (
        last_short_term_fcf * (1 + long_term_growth) / (wacc - long_term_growth)
    )
    df["cash flow"] = df[["fcf", "terminal value"]].apply(sum, axis=1)
    return npv(df, wacc) * sqrt((1 + wacc))