Exemple #1
0
def create_final_table(growth_cf_part, growth_cf, shs_out, r_f_rate, req_return):
    final_table = growth_cf_part.copy()
    final_table['INTRINSIC VALUE'] = list(
        map(lambda i: np.npv(r_f_rate, [0] + extracted_cfs(i, growth_cf)), growth_cf.index))
    final_table['BUY PRICE'] = list(
        map(lambda i: np.npv(req_return, [0] + extracted_cfs(i, growth_cf)), growth_cf.index))
    final_table['I.V. / SHARE'] = final_table['INTRINSIC VALUE'] / shs_out
    final_table['B.P. / SHARE'] = final_table['BUY PRICE'] / shs_out

    return final_table
Exemple #2
0
def bond_pricing(rate, r, n, M, m):
    '''
    债券定价
    -------
    Params
    rate: -> float 贴现率
    r: -> float 年利息率
    n: -> flaot 期限
    M: -> float 票面金额
    m: -> int 每年付息次数
    
    Return
    price: -> float 债券价格
    '''
    global cash_flow
    # 计算贴现率
    rate = rate / m
    # 计算每期利息率
    r = r / m
    # 计算每期利息
    C = M * r
    # 计算期数
    n = n * m
    # 汇总现金流到一个list中
    cash_flow = [0] + [C] * n
    price = npf.npv(rate, cash_flow) + M / (1 + rate)**n
    return price
    def calculate_npv(self,
                      rated_rpm_array,
                      D_rotor_array,
                      Power_rated_array,
                      hub_height_array,
                      water_depth_array,
                      aep_array,
                      cabling_cost=None):
        '''
        Calculate Net Present Value [Euro]

        Input:
        rated_rpm_array   [RPM]
        D_rotor_array     [m]
        Power_rated_array [MW]
        hub_height_array  [m]
        aep_array         [kWh]
        water_depth_array [m]
        '''

        self.calculate_expenditures(rated_rpm_array, D_rotor_array,
                                    Power_rated_array, hub_height_array,
                                    aep_array, water_depth_array, cabling_cost)

        self.calculate_cash_flow()

        self.NPV = npf.npv(self.discount_rate, self.CWF)

        return self.NPV
Exemple #4
0
def calculate_price_lecture(B0, roe, Ke, shares, discount_factor, pos):
    if pos == -1 :
        years = 7
        referenceDate = datetime(datetime.now().year+2,12,31)
    elif pos == -2 :
        years = 8
        referenceDate = datetime(datetime.now().year+1,12,31)
    elif pos == -3 :
        years = 9
        referenceDate = datetime(datetime.now().year,12,31)
    else :
        years = 10
        referenceDate = datetime(datetime.now().year-1,12,31)
    Ke *= 0.01
    roe *= 0.01
    Bt = B0
    excesses = [0,]
    excessRate = roe-Ke
    for i in range(years) :
        excessRate *= discount_factor
        roe = Ke + excessRate
        excess = Bt * roe - Bt * Ke
        excesses.append(excess)
        Bt += Bt * roe
    excessNetPresentValue = npf.npv(Ke,excesses)
    B = B0 + excessNetPresentValue
    priceAtThatTime = B/shares
    dayDifference = (referenceDate - datetime.now()).days
    price = priceAtThatTime / (1+Ke)**(dayDifference/365)
    return price
Exemple #5
0
 def test_npv_irr_congruence(self):
     # IRR is defined as the rate required for the present value of a
     # a series of cashflows to be zero i.e. NPV(IRR(x), x) = 0
     cashflows = numpy.array([-40000, 5000, 8000, 12000, 30000])
     assert_allclose(npf.npv(npf.irr(cashflows), cashflows),
                     0,
                     atol=1e-10,
                     rtol=0)
Exemple #6
0
def calc_opex_annualized(OpC_USDyr, Inv_IR_perc, Inv_LT_yr):
    Inv_IR = Inv_IR_perc / 100
    opex_list = [0.0]
    opex_list.extend(Inv_LT_yr * [OpC_USDyr])
    opexnpv = npf.npv(Inv_IR, opex_list)
    EAC = ((opexnpv * Inv_IR) / (1 - (1 + Inv_IR)**(-Inv_LT_yr))
           )  # calculate positive EAC
    return EAC
Exemple #7
0
    def get_profit(self,
                   r,
                   starch_price=320.36,
                   ethanol_price=1.48,
                   rp_price=351.05,
                   p_credit=0.0,
                   grain_product_index=1.0,
                   rP_index=1.0,
                   feedstock_index=1.0,
                   chem_index=1.0,
                   utility_index=1.0,
                   tax=0.35):
        '''return net profit as annualized value, $/yr '''
        revenue = self.get_revenue(starch_price=starch_price,
                                   ethanol_price=ethanol_price,
                                   p_credit=p_credit,
                                   rp_price=rp_price,
                                   grain_product_index=grain_product_index,
                                   rP_index=rP_index)[-1]
        cost = self.get_cost(feedstock_index=feedstock_index,
                             chem_index=chem_index,
                             utility_index=utility_index)[-1]
        taxable_income = revenue - cost
        net_profit = taxable_income * (1 - tax)  # assume 40% as default tax

        if self.tech_GP == 1:
            direct_fixed_cost = self.df[self.column][12]  # $/yr
            # depreciation_cost = self.df[self.column][16]  # $/yr
            depreciation_cost = direct_fixed_cost * 0.0655  # $/yr
        elif self.tech_GP == 2:
            direct_fixed_cost = self.df[self.column][12] + self.df[
                self.column][34]  # $/yr
            # depreciation_cost = self.df[self.column][16] + self.df[self.column][38]  # $/yr
            depreciation_cost = direct_fixed_cost * 0.0655  # $/yr
        working_capital = direct_fixed_cost * 0.05  # assume 5%
        cash_flow_list = [
            -(direct_fixed_cost * tax + working_capital),
            -(direct_fixed_cost * (1 - tax))
        ]
        for i in depreciation_rate:
            cash_flow_i = (revenue-(cost-depreciation_cost) - \
                           direct_fixed_cost*i)*(1-tax) + direct_fixed_cost*i
            cash_flow_list.append(cash_flow_i)
        npv = npf.npv(r, cash_flow_list)
        irr = npf.irr(cash_flow_list)
        annualized_value = npv / annuity_factor(20, r)
        a = [cost, revenue, taxable_income, net_profit]
        b = [
            direct_fixed_cost, working_capital, depreciation_cost,
            cash_flow_list
        ]
        return a, b, irr, npv, annualized_value


# wet_1 = Grain(plant_type=1, plant_capacity=5.0, tech_GP=2)
# (Grain(plant_type=1, plant_capacity=2.1, tech_GP=2).get_energy_use()[-1] + \
#     Grain(plant_type=1, plant_capacity=5.0, tech_GP=2).get_energy_use()[-1] + \
#         Grain(plant_type=2, plant_capacity=120, tech_GP=2).get_energy_use()[-1])/(10**6)
def oekonomie_berechnen_gw_ve(leistung_pv, eco, kW, kalkulatorischer_zins,
                              einspeiseverguetung_vektor):
    # Imports
    import numpy as np
    import numpy_financial as npf
    import copy
    # Berechnung
    kalkulatorischer_zins /= 100

    summe_e_pv2g = np.sum(leistung_pv) / (60 * 1000)

    # Erloese aus den Energieflüssen
    einspeiseverguetung = (np.minimum(10, kW) / kW * (einspeiseverguetung_vektor[0]/100) \
        + np.minimum(30, kW - np.minimum(10, kW)) / kW * (einspeiseverguetung_vektor[1]/100) \
        + np.minimum(60, kW - np.minimum(30, kW - np.minimum(10, kW)
                                         ) - np.minimum(10, kW)) / kW * (einspeiseverguetung_vektor[2]/100))
    ersparnis_pv2g = summe_e_pv2g * einspeiseverguetung

    # Gewinn 20 Jahre
    gewinn_pv_20 = np.zeros(20)
    gewinnkurve = np.zeros(21)
    gewinnkurve[0] = np.round(-1 * eco["invest"], 0)

    stromgestehung_zaehler = np.zeros(20)
    stromgestehung_nenner = np.zeros(20)

    for n in range(20):
        if n > 0:
            eco["betrieb"] += eco["betrieb"] * kalkulatorischer_zins
        gewinn_pv_20[n] = ersparnis_pv2g - eco["betrieb"]
        gewinnkurve[n + 1] = gewinnkurve[n] + gewinn_pv_20[n]

        #Stromgestehungskosten Zaehler und Nenner
        if n == 0:
            stromgestehung_zaehler[n] = (eco["invest"] + eco["betrieb"]) / (
                (1 + kalkulatorischer_zins)**n)
        stromgestehung_nenner[n] = summe_e_pv2g / (
            (1 + kalkulatorischer_zins)**n)

    gewinn_nettobarwert = np.concatenate([[gewinnkurve[0]], gewinn_pv_20])
    nettobarwert = np.round(
        npf.npv(kalkulatorischer_zins, gewinn_nettobarwert), 0)

    if kW == 0:
        rendite = 0
        nettobarwert = 0
    else:
        rendite = np.round(
            npf.irr(np.concatenate([[gewinnkurve[0]], gewinn_pv_20])), 2)
        rendite *= 100

    #Stromgestehungskosten
    zaehler = np.sum(stromgestehung_zaehler)
    nenner = np.sum(stromgestehung_nenner)
    stromgestehungskosten = np.round((zaehler / nenner) * 100, 1)

    return nettobarwert, rendite, gewinnkurve, stromgestehungskosten
Exemple #9
0
 def get_crop_cost_acf(self, r=0.07):
     '''return $/yr'''
     corn_cost = get_crop_cost('corn', self.landuse_matrix)[1]
     soybean_cost = get_crop_cost('soybean', self.landuse_matrix)[1]
     sg_cost = get_crop_cost('switchgrass', self.landuse_matrix)[1]
     crop_cost = corn_cost + soybean_cost + sg_cost
     npv = npf.npv(r, crop_cost)
     annualized_value = npv / annuity_factor(16, r)
     return crop_cost, annualized_value
Exemple #10
0
 def build_sensitivity_results(self, results_df):
     for index, row in results_df.iterrows():
         processed_cashflows = self.build_cashflows(row["R_AdjustFact"], row["E_AdjustFact"], row["FCI_AdjustFact"])
         cashflow_arr = np.array(processed_cashflows[Cash_flow])
         NPV = round(np_fi.npv(self.i, cashflow_arr), 2)
         IRR = round(np_fi.irr(cashflow_arr), 4)
         results_df.loc[index, 'NPV'] = NPV
         results_df.loc[index, 'IRR'] = IRR
     return results_df
Exemple #11
0
 def test_npv_broadcast(self):
     cashflows = [
         [-15000, 1500, 2500, 3500, 4500, 6000],
         [-15000, 1500, 2500, 3500, 4500, 6000],
         [-15000, 1500, 2500, 3500, 4500, 6000],
         [-15000, 1500, 2500, 3500, 4500, 6000],
     ]
     expected_npvs = [122.8948549, 122.8948549, 122.8948549, 122.8948549]
     actual_npvs = npf.npv(0.05, cashflows)
     assert_allclose(actual_npvs, expected_npvs)
Exemple #12
0
 def soln_net_present_value(self):
     """Marginal First Cost.
        SolarPVUtil 'Operating Cost'!E126:E250
     """
     npv = []
     net_cash_flow = self.soln_net_cash_flow()
     for n in range(len(net_cash_flow.index)):
         l = [0] * (n + 1) + [net_cash_flow.iloc[n]]
         npv.append(numpy_financial.npv(rate=self.ac.npv_discount_rate, values=l))
     result = pd.Series(npv, index=net_cash_flow.index)
     result.name = 'soln_net_present_value'
     return result
Exemple #13
0
 def soln_only_single_iunit_npv(self):
     """Net Present Value of single iunit cashflow, looking only at costs of the Solution.
        SolarPVUtil 'Operating Cost'!N126:N250
     """
     npv = []
     sosic = self.soln_only_single_iunit_cashflow()
     offset = self.single_iunit_purchase_year - sosic.first_valid_index() + 1
     for n in range(len(sosic.index)):
         l = [0] * (n + offset) + [sosic.iloc[n]]
         npv.append(numpy_financial.npv(rate=self.ac.npv_discount_rate, values=l))
     result = pd.Series(npv, index=sosic.index.copy())
     result.name = 'soln_only_single_iunit_npv'
     return result
Exemple #14
0
    def net_present_value_report(self, pro_forma):
        """ Uses the discount rate to calculate the present value for each column within the proforma

        Args:
            pro_forma (DataFrame): Pro-forma DataFrame that was created from each ValueStream or DER active

        """
        # use discount rate to calculate NPV for net
        npv_dict = {}
        # NPV for growth_cols
        for col in pro_forma.columns:
            if col == 'Yearly Net Value':
                npv_dict.update({
                    'Lifetime Present Value':
                    [npf.npv(self.npv_discount_rate, pro_forma[col].values)]
                })
            else:
                npv_dict.update({
                    col:
                    [npf.npv(self.npv_discount_rate, pro_forma[col].values)]
                })
        self.npv = pd.DataFrame(npv_dict, index=pd.Index(['NPV']))
Exemple #15
0
    def presentValue(self):
        # presentValue = (self.cashflow/((1 + self.discount) ** self.year))
        # print(self.year,"년에 대한" ,"현재 자산가지 :", presentValue)
        # 1. 세부 지표 값 구하기
        loss = [-750, -250]
        profit = [100] * 18
        cf = loss + profit
        cashflow = np.array(cf)

        # 2. 순현재가치(NPV)와 내부수익률(IRR) 구하기
        npv = npf.npv(0.045, cashflow)
        irr = npf.irr(cashflow)

        print("순현재가치(npv) : ", npv, "내부수익률(irr) : ", irr)
Exemple #16
0
    def summary(self):
        """
        Calculate some quick summary numbers for the village.

        Returns
        -------
        results : dict
            Dict of summary results.
        """

        count_nodes = 0
        income_per_month = 0
        gen_size_kw = 0
        for node in self.nodes:
            if node["conn"] == 1:
                count_nodes += 1
                income_per_month += (node["area"] * self.num_people_per_m2 *
                                     self.demand * self.tariff)
                gen_size_kw += (node["area"] * self.num_people_per_m2 *
                                self.demand_per_person_kw_peak)

        if self.origin:
            count_nodes -= 1  # so we don't count the generator

        total_length = 0.0
        for arc in self.network:
            if arc["enabled"] == 1:
                total_length += arc["len"]

        capex = (gen_size_kw * self.gen_cost +
                 self.cost_connection * count_nodes +
                 self.cost_wire * total_length)
        opex = self.opex_ratio * capex
        income = income_per_month * 12

        flows = np.ones(self.years) * (income - opex)
        flows[0] = -capex
        npv = npf.npv(self.discount_rate, flows)

        self.results = {
            "connected": count_nodes,
            "gen-size": int(gen_size_kw),
            "line-length": int(total_length),
            "capex": int(capex),
            "opex": int(opex),
            "income": int(income),
            "npv": int(npv),
        }

        return self.results
Exemple #17
0
    def cost_benefit_report(self, pro_forma):
        """ Calculates and returns a cost-benefit data frame

        Args:
            pro_forma (DataFrame): Pro-forma DataFrame that was created from each ValueStream or DER active

        """
        # remove 'Yearly Net Value' from dataframe before preforming the rest (we dont want to include net values, so we do this first)
        pro_forma = pro_forma.drop('Yearly Net Value', axis=1)

        # prepare for cost benefit
        cost_df = pd.DataFrame(pro_forma.values.clip(max=0))
        cost_df.columns = pro_forma.columns
        benefit_df = pd.DataFrame(pro_forma.values.clip(min=0))
        benefit_df.columns = pro_forma.columns

        cost_pv = 0  # cost present value (discounted cost)
        benefit_pv = 0  # benefit present value (discounted benefit)
        self.cost_benefit = pd.DataFrame({'Lifetime Present Value': [0, 0]},
                                         index=pd.Index(
                                             ['Cost ($)', 'Benefit ($)']))
        for col in cost_df.columns:
            present_cost = npf.npv(self.npv_discount_rate, cost_df[col].values)
            present_benefit = npf.npv(self.npv_discount_rate,
                                      benefit_df[col].values)

            self.cost_benefit[col] = [np.abs(present_cost), present_benefit]

            cost_pv += present_cost
            benefit_pv += present_benefit
        self.cost_benefit['Lifetime Present Value'] = [
            np.abs(cost_pv), benefit_pv
        ]

        # Transforming cost_benefit df bc XENDEE asked us to.
        self.cost_benefit = self.cost_benefit.T
Exemple #18
0
 def get_nitrate_cost(self, r=0.07, chem_index=1.0, utility_index=1.0):
     '''
     return total cost of nitrate removal facility: (year,days); 
     N_EAC = $/yr
     '''
     N_cost_capital = 633                         # depreciation cost: $633/day: equivalent annual cost per day
     overhead_cost = 72 * self.get_nitrate_days()      # $72/day in 2003
     utility_cost = 900 * self.get_nitrate_days()*utility_index      # $900/day
     labor_cost = 239 * self.get_nitrate_days()        # $239/day in 2003 (4 hrs/day for operation hour and 2 hrs/day for maintenance labor)
     N_cost_chemical = self.get_nitrate_days() * self.get_nitrate_chemical()[0] * 0.089 * 2.20462 * chem_index # 0.089 $/lb in 2003, 1 kg = 2.20462 lb
     N_cost_op = N_cost_chemical + overhead_cost + utility_cost + labor_cost  # (year, day)
     N_cost_total = N_cost_capital + N_cost_op   # return cost as a numpy array: (year, month)
     N_npv = npf.npv(r, N_cost_total.sum(axis=1))
     N_EAC = N_npv/annuity_factor(16, r)  # 16 yrs
     return [N_EAC]
Exemple #19
0
def NPV(rate: xl.Number, *values):
    """Calculates the net present value of an investment by using a discount
    rate and a series of future payments (negative values) and income
    (positive values).

    https://support.office.com/en-us/article/
        npv-function-8672cb67-2576-4d07-b67b-ac28acf2a568
    """
    if not len(values):
        return xl.ValueExcelError('value1 is required')

    cashflow = list(filter(xl.is_number, xl.flatten(values)))

    if xl.COMPATIBILITY == 'PYTHON':
        return numpy_financial.npv(rate, cashflow)

    return sum([
        float(val) * (1 + rate)**-(i + 1) for (i, val) in enumerate(cashflow)
    ])
Exemple #20
0
    def get_sediment_cost(self, r=0.07, chem_index=1.0):
        '''return chemical cost for sediment treatment as a numpy array: (year,month)'''
        polymer = (0.0062*self.NTU + 0.31)/1000     # kg/m3
        alum = (0.3*self.NTU + 30.0)/1000           # kg/m3
        
        # cost_alum = cost_inflation(cost=0.0787, cost_yr=2019, start_yr=2003)  # 0.0787 $/lb
        # cost_polymer = cost_inflation(cost=1.26, cost_yr=2019, start_yr=2003) # 1.26 $/lb
        alum_cost = alum*self.flow*0.0787*2.20462*chem_index      # 0.0787 $/lb, 1 kg = 2.20462 lb
        polymer_cost = polymer*self.flow*1.26*2.20462*chem_index  # 1.26 $/lb, 1 kg = 2.20462 lb
        number_days = np.zeros(((self.year.size, self.month.size)))
        for i in range(self.year.size):
            for j in range(12):
                number_days[i,j] = monthrange(self.year[i], self.month[j])[1]
        sediment_cost = (alum_cost + polymer_cost) * number_days 

        # discount cash flow analysis
        sediment_cost_PV = npf.npv(r, sediment_cost.sum(axis=1))
        sediment_EAC = sediment_cost_PV/annuity_factor(16, r)   # 16 yrs
        return [sediment_EAC]
Exemple #21
0
    def get_crop_revenue_acf(self, r=0.07, crop_index=1.0):
        '''return $/yr'''
        corn_production = get_yield_crop('corn', self.landuse_matrix)[1].sum(
            axis=1)  # kg/yr, (yr,)
        soybean_production = get_yield_crop('soybean',
                                            self.landuse_matrix)[1].sum(
                                                axis=1)  # kg/yr, (yr,)
        sg_production = get_yield_crop(
            'switchgrass', self.landuse_matrix)[1].sum(axis=1)  # kg/yr, (yr,)
        # production = [corn_production, soybean_production, sg_production]

        corn_revenue = corn_production * self.corn_price * crop_index  # corn_price = $0.152/kg
        soybean_revenue = soybean_production * self.soybean_price * crop_index  # soybean_price = $0.356/kg
        sg_revenue = sg_production * self.sg_price * 0.8 * crop_index  # sg_price = $0.04/kg, 80% moisture

        total_revenue = corn_revenue + soybean_revenue + sg_revenue
        npv = npf.npv(r, total_revenue)
        annualized_value = npv / annuity_factor(16, r)
        return corn_revenue, soybean_revenue, sg_revenue, total_revenue, annualized_value
Exemple #22
0
    def rim(roe, equity, 지속계수):
        Y10 = {
            '초과이익률': [roe - 요구수익률, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            'ROE': [roe, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            '순이익': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            '자본': [equity, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            '초과이익': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        }

        for i in range(1, 11):
            Y10['초과이익률'][i] = Y10['초과이익률'][i - 1] * 지속계수
            Y10['ROE'][i] = 요구수익률 + Y10['초과이익률'][i]
            Y10['순이익'][i] = Y10['자본'][i - 1] * Y10['ROE'][i]
            Y10['자본'][i] = Y10['자본'][i - 1] + Y10['순이익'][i]
            Y10['초과이익'][i] = Y10['순이익'][i] - (Y10['자본'][i - 1] * 요구수익률)

        순현재가치 = npf.npv(요구수익률, Y10['초과이익'])
        RIM주주가치 = 자본 + 순현재가치
        RIM주당가치 = round(RIM주주가치 * 100000000 / 주식수)
        return RIM주당가치
Exemple #23
0
def NPV(
    rate: xltypes.XlNumber,
    *values: Tuple[xltypes.XlNumber],
) -> xltypes.XlNumber:
    """Calculates the net present value of an investment by using a discount
    rate and a series of future payments (negative values) and income
    (positive values).

    https://support.office.com/en-us/article/
        npv-function-8672cb67-2576-4d07-b67b-ac28acf2a568
    """
    if not len(values):
        raise xlerrors.ValueExcelError('value1 is required')

    cashflow = [float(value) for value in values]
    rate = float(rate)

    if xl.COMPATIBILITY == 'PYTHON':
        return numpy_financial.npv(rate, cashflow)

    return sum(
        [val * (1 + rate)**-(i + 1) for (i, val) in enumerate(cashflow)])
Exemple #24
0
    def annuity_scalar(self, opt_years):
        """Calculates an annuity scalar, used for sizing, to convert yearly costs/benefits
        this method is sometimes called before the class is initialized (hence it has to be
        static)

        Args:
            opt_years (list): List of years that the user wants to optimize--should be length=1

        Returns: the NPV multiplier

        """
        n = self.end_year.year - self.start_year.year
        dollar_per_year = np.ones(n)
        base_year = min(opt_years)
        yr_index = base_year - self.start_year.year
        while yr_index < n - 1:
            dollar_per_year[yr_index + 1] = dollar_per_year[yr_index] * (1 + self.inflation_rate)
            yr_index += 1
        yr_index = base_year - self.start_year.year
        while yr_index > 0:
            dollar_per_year[yr_index - 1] = dollar_per_year[yr_index] * (1 / (1 + self.inflation_rate))
            yr_index -= 1
        lifetime_npv_alpha = npf.npv(self.npv_discount_rate, [0] + dollar_per_year)
        return lifetime_npv_alpha
Exemple #25
0
    def discount_factor(iy, n):
        disc = 1 / (1 + iy)**n
        print(str(round(disc, 5)), ' discount factor')


TVM.compound_int(n=2, iy=.05, pv=100)
TVM.future_value(n=2, iy=.05, pv=100)
TVM.discount_factor(n=2, iy=.05)

inv = npf.pv(rate=.05, nper=10, pmt=0, fv=100000)
investment_2 = npf.fv(rate=.08, nper=10, pmt=0, pv=-100000)
print("Investment 2 will yield a total of $" + str(round(investment_2, 2)) +
      " in 10 years")
print(inv)
# Calculate investment_3
investment_3 = npf.fv(rate=.08, nper=10, pmt=0, pv=-100000)
print("Investment 3 will yield a total of $" + str(round(investment_3, 2)) +
      " in 10 years")

# Calculate investment_3 and adjsut for inflation of 3%
investment_3_discounted = npf.pv(rate=.03, nper=10, pmt=0, fv=investment_3)
print("After adjusting for inflation, investment 3 is worth $" +
      str(round(-investment_3_discounted, 2)) + " in today's dollars")

#Discounting cashflows with NPV
# NPV = sum of all discounted cashflows
cashflows = np.array([100, 100, 100, 100, 100])
npvinv1 = npf.npv(rate=.03, values=cashflows)
print('NPV of INV1 is $', str(round(npvinv1, 2)) + " in today's dollars")
Exemple #26
0
 def financial_metrics(self, discount_rate):
     return irr(self.df.loc['Cash Flow']), npv(discount_rate,
                                               self.df.loc['Cash Flow'])
def oekonomie_berechnen_ms(leistung_pv, leistung_last, eco, kW,
                           mieterstrom_zuschlag, kalkulatorischer_zins,
                           betreiber, einspeiseverguetung_vektor):
    # Imports
    import numpy as np
    import numpy_financial as npf

    # Variablen statt festen Werten
    dt_min = 60  # Zeitschrittweite in Minuten

    # Berechnung
    kalkulatorischer_zins /= 100  # Prozent in dezimal

    e_pv2l = np.minimum(leistung_pv, leistung_last)  # in Watt!
    e_pv2g = leistung_pv - e_pv2l  # in Watt!
    # Grid to load
    e_g2l = leistung_last - leistung_pv  # in Watt!
    e_g2l[e_g2l <= 0] = 0  # in Watt!

    # Energiesummen
    summe_e_g2l = np.sum(e_g2l) / (dt_min * 1000
                                   )  # Wattminuten in kWh umgerechnet
    summe_e_pv2l = np.sum(e_pv2l) / (dt_min * 1000)  # in kWh
    summe_e_pv2g = np.sum(e_pv2g) / (dt_min * 1000)  # in kWh
    summe_pvs = np.sum(leistung_pv) / (dt_min * 1000)  # in kWh
    summe_last = np.sum(leistung_last) / (dt_min * 1000)  # in kWh

    # Eigenverbrauchsanteil
    Eigenverbrauchsanteil = np.round((summe_e_pv2l / summe_pvs) * 100, 1)
    # Autarkiegrad
    Autarkiegrad = np.round((summe_e_pv2l / summe_last) * 100, 1)

    # Erloese aus den Energieflüssen
    einspeiseverguetung = (np.minimum(10, kW) / kW * (einspeiseverguetung_vektor[0]/100) \
        + np.minimum(30, kW - np.minimum(10, kW)) / kW * (einspeiseverguetung_vektor[1]/100) \
        + np.minimum(60, kW - np.minimum(30, kW - np.minimum(10, kW)
                                         ) - np.minimum(10, kW)) / kW * (einspeiseverguetung_vektor[2]/100))
    einspeiseverguetung -= 0.004  # Marktprämie abziehen
    ersparnis_pv2g = summe_e_pv2g * einspeiseverguetung

    # Gewinn 20 Jahre
    gewinn_pv_20 = np.zeros(20)
    gewinnkurve = np.zeros(21)
    gewinnkurve[0] = np.round(-1 * eco["invest"], 0)

    # Mieterstromzuschlag
    if mieterstrom_zuschlag == 'Ja':
        if kW < 40:  # Zuschlag berechnen nach: für erste 40kW -8,5 ct, für danach nur -8,0 ct bis 750 kW
            c_mieterstromzuschlag = summe_e_pv2l * \
                np.maximum((einspeiseverguetung - 0.085),0)
        else:
            c_mieterstromzuschlag = summe_e_pv2l * \
                np.maximum((einspeiseverguetung - 0.08),0)
    else:
        c_mieterstromzuschlag = 0

    C_Verwaltung = 100 / 1.19  # Euro pro Jahr und Teilnehmer
    # Rolle und die damit verbundenen Kosten
    if betreiber == 'betreiber-0':
        c_pacht = 0
    else:
        c_pacht = kW * 150 / 20

    stromgestehung_zaehler = np.zeros(20)
    stromgestehung_nenner = np.zeros(20)
    # Berechnung über 20 Jahre:
    for n in range(20):

        if n > 0:  # Achtung, hier werden die aus eco_vorbereiten stammenden Werte überschrieben mit Inflation
            eco["betrieb"] += eco["betrieb"] * kalkulatorischer_zins
            eco["grundpreis"] += eco["grundpreis"] * kalkulatorischer_zins

        # Annahme, damit der Mieterstrom vermarktet werden kann.
        c_Mieterstrompreis = 0.9 * eco["strompreis_vektor"][n]

        # Bonusberechnung (nicht in Oekonomie_berechnen_MS_JB): lcoe
        #Stromgestehungskosten Zaehler und Nenner
        if n == 0:
            stromgestehung_zaehler[n] = (eco["invest"] + eco["betrieb"]) / (
                (1 + kalkulatorischer_zins)**n)
        else:
            #! die Betriebskosten muss ich doch auch jährlich abzinsen!
            stromgestehung_zaehler[n] = (eco["betrieb"]) / (
                (1 + kalkulatorischer_zins)**n)
        stromgestehung_nenner[n] = summe_pvs / ((1 + kalkulatorischer_zins)**n)
        # Ende lcoe

        # Zusammenrechnen der Kosten
        kosten_mieterstrom = -1 * summe_e_g2l*1*c_Mieterstrompreis / 1.19 \
            - eco["betrieb"] /1.19 - eco["umlage"][n]*summe_e_pv2l - \
            C_Verwaltung*eco["i_teilnehmer"] - c_pacht
        gewinne_mieterstrom = summe_last*1*c_Mieterstrompreis /1.19 \
            + c_mieterstromzuschlag + ersparnis_pv2g \
            + eco["grundpreis"] * eco["i_teilnehmer"] / 1.19
        # Volleinspeisung vs. MS:
        gewinn_pv_20[n] = np.maximum(summe_pvs * einspeiseverguetung - eco["betrieb"] /1.19,\
            gewinne_mieterstrom + kosten_mieterstrom)  # Mieterstrom
        gewinnkurve[n + 1] = gewinnkurve[n] + gewinn_pv_20[n]  # kumuliert
    # Schleifenende 20 Jahre

    gewinn_nettobarwert = np.concatenate([[gewinnkurve[0]], gewinn_pv_20])
    nettobarwert = np.round(
        npf.npv(kalkulatorischer_zins, gewinn_nettobarwert), 0)

    if kW == 0:  # warum fragen wir das ab?!
        rendite = 0
        nettobarwert = 0
    else:
        rendite = npf.irr(gewinn_nettobarwert)
        rendite = np.round(rendite * 100, 2)

    #BS: soweit OK

    #Stromgestehungskosten
    zaehler = np.sum(stromgestehung_zaehler)
    nenner = np.sum(stromgestehung_nenner)
    stromgestehungskosten = np.round((zaehler / nenner) * 100, 1)

    return nettobarwert, rendite, gewinnkurve, Eigenverbrauchsanteil, Autarkiegrad, stromgestehungskosten
Exemple #28
0
# Set the corporate tax rate
tax_rate = 0.35

# Calculate the WACC
wacc = percent_equity * cost_equity + percent_debt * cost_debt * (1 - tax_rate)
print("WACC: " + str(round(100 * wacc, 2)) + "%")

import numpy as np
import numpy_financial as npf

# Set your weighted average cost of capital equal to 12.9%
wacc = 0.129

# Calculate the net present value for Project 1
npv_project1 = npf.npv(0.129, cf_project1)
print("Project 1 NPV: " + str(round(npv_project1, 2)))

# Calculate the net present value for Project 2
npv_project2 = npf.npv(0.129, cf_project2)
print("Project 2 NPV: " + str(round(npv_project2, 2)))

import numpy as np

# Create a numpy array of cash flows for Project 1
cf_project_1 = np.array([-700, 100, 150, 200, 250, 300, 350, 400])

# Create a numpy array of cash flows for Project 2
cf_project_2 = np.array([-400, 50, 100, 150, 200, 250, 300])

# Scale the original objects by 1000x
Exemple #29
0
# Calculate investment_2
investment_1_discounted = npf.pv(rate=0.03,
                                 nper=10,
                                 pmt=0,
                                 fv=21589.24997272788)
print("After adjusting for inflation, investment 1 is worth $" +
      str(round(-investment_1_discounted, 2)) + " in today's dollars")

import numpy as np
import numpy_financial as npf

# Predefined array of cash flows
cash_flows = np.array([100, 100, 100, 100, 100])

# Calculate investment_1
investment_1 = npf.npv(rate=0.03, values=np.array([100, 100, 100, 100, 100]))
print("Investment 1's net present value is $" + str(round(investment_1, 2)) +
      " in today's dollars")

# Calculate investment_2
investment_2 = npf.npv(rate=0.05, values=np.array([100, 100, 100, 100, 100]))
print("Investment 2's net present value is $" + str(round(investment_2, 2)) +
      " in today's dollars")

# Calculate investment_3
investment_3 = npf.npv(rate=0.07, values=np.array([100, 100, 100, 100, 100]))
print("Investment 3's net present value is $" + str(round(investment_3, 2)) +
      " in today's dollars")

import numpy as np
import numpy_financial as npf
Exemple #30
0
def calc_dv01(rate, cashflows):
    # DV01: mudança esperada no valor presente para uma mudança de 1bp na taxa de juros
    return (abs(npf.npv(rate + 0.0001, cashflows)) +
            abs(npf.npv(rate - 0.0001, cashflows))) / 2