当前位置: 首页>>代码示例>>Python>>正文


Python numpy.npv方法代码示例

本文整理汇总了Python中numpy.npv方法的典型用法代码示例。如果您正苦于以下问题:Python numpy.npv方法的具体用法?Python numpy.npv怎么用?Python numpy.npv使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在numpy的用法示例。


在下文中一共展示了numpy.npv方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_npv

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import npv [as 别名]
def test_npv(self):
        assert_almost_equal(
            np.npv(0.05, [-15000, 1500, 2500, 3500, 4500, 6000]),
            122.89, 2) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:6,代码来源:test_financial.py

示例2: test_npv_decimal

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import npv [as 别名]
def test_npv_decimal(self):
        assert_equal(
            np.npv(Decimal('0.05'), [-15000, 1500, 2500, 3500, 4500, 6000]),
            Decimal('122.894854950942692161628715')) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:6,代码来源:test_financial.py

示例3: mirr

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import npv [as 别名]
def mirr(values, finance_rate, reinvest_rate):
    """
    Modified internal rate of return.

    Parameters
    ----------
    values : array_like
        Cash flows (must contain at least one positive and one negative
        value) or nan is returned.  The first value is considered a sunk
        cost at time zero.
    finance_rate : scalar
        Interest rate paid on the cash flows
    reinvest_rate : scalar
        Interest rate received on the cash flows upon reinvestment

    Returns
    -------
    out : float
        Modified internal rate of return

    """
    values = np.asarray(values)
    n = values.size

    # Without this explicit cast the 1/(n - 1) computation below
    # becomes a float, which causes TypeError when using Decimal
    # values.
    if isinstance(finance_rate, Decimal):
        n = Decimal(n)

    pos = values > 0
    neg = values < 0
    if not (pos.any() and neg.any()):
        return np.nan
    numer = np.abs(npv(reinvest_rate, values*pos))
    denom = np.abs(npv(finance_rate, values*neg))
    return (numer/denom)**(1/(n - 1))*(1 + reinvest_rate) - 1 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:39,代码来源:financial.py

示例4: mirr

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import npv [as 别名]
def mirr(values, finance_rate, reinvest_rate):
    """
    Modified internal rate of return.

    Parameters
    ----------
    values : array_like
        Cash flows (must contain at least one positive and one negative
        value) or nan is returned.  The first value is considered a sunk
        cost at time zero.
    finance_rate : scalar
        Interest rate paid on the cash flows
    reinvest_rate : scalar
        Interest rate received on the cash flows upon reinvestment

    Returns
    -------
    out : float
        Modified internal rate of return

    """
    values = np.asarray(values, dtype=np.double)
    n = values.size
    pos = values > 0
    neg = values < 0
    if not (pos.any() and neg.any()):
        return np.nan
    numer = np.abs(npv(reinvest_rate, values*pos))
    denom = np.abs(npv(finance_rate, values*neg))
    return (numer/denom)**(1.0/(n - 1))*(1 + reinvest_rate) - 1 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:32,代码来源:financial.py

示例5: test_npv

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import npv [as 别名]
def test_npv(self):
        assert_almost_equal(np.npv(0.05, [-15000, 1500, 2500, 3500, 4500, 6000]),
                            122.89, 2) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:5,代码来源:test_financial.py

示例6: mirr

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import npv [as 别名]
def mirr(values, finance_rate, reinvest_rate):
    """
    Modified internal rate of return.

    Parameters
    ----------
    values : array_like
        Cash flows (must contain at least one positive and one negative value)
        or nan is returned.  The first value is considered a sunk cost at time zero.
    finance_rate : scalar
        Interest rate paid on the cash flows
    reinvest_rate : scalar
        Interest rate received on the cash flows upon reinvestment

    Returns
    -------
    out : float
        Modified internal rate of return

    """

    values = np.asarray(values, dtype=np.double)
    n = values.size
    pos = values > 0
    neg = values < 0
    if not (pos.any() and neg.any()):
        return np.nan
    numer = np.abs(npv(reinvest_rate, values*pos))
    denom = np.abs(npv(finance_rate, values*neg))
    return (numer/denom)**(1.0/(n - 1))*(1 + reinvest_rate) - 1 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:32,代码来源:financial.py

示例7: calc_opex_annualized

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import npv [as 别名]
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 = np.npv(Inv_IR, opex_list)
    EAC = ((opexnpv * Inv_IR) / (1 - (1 + Inv_IR) ** (-Inv_LT_yr)))  # calculate positive EAC
    return EAC 
开发者ID:architecture-building-systems,项目名称:CityEnergyAnalyst,代码行数:9,代码来源:equations.py


注:本文中的numpy.npv方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。