當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。