本文整理匯總了Python中numpy.mirr方法的典型用法代碼示例。如果您正苦於以下問題:Python numpy.mirr方法的具體用法?Python numpy.mirr怎麽用?Python numpy.mirr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類numpy
的用法示例。
在下文中一共展示了numpy.mirr方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_mirr_decimal
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import mirr [as 別名]
def test_mirr_decimal(self):
val = [Decimal('-4500'), Decimal('-800'), Decimal('800'), Decimal('800'),
Decimal('600'), Decimal('600'), Decimal('800'), Decimal('800'),
Decimal('700'), Decimal('3000')]
assert_equal(np.mirr(val, Decimal('0.08'), Decimal('0.055')),
Decimal('0.066597175031553548874239618'))
val = [Decimal('-120000'), Decimal('39000'), Decimal('30000'),
Decimal('21000'), Decimal('37000'), Decimal('46000')]
assert_equal(np.mirr(val, Decimal('0.10'), Decimal('0.12')), Decimal('0.126094130365905145828421880'))
val = [Decimal('100'), Decimal('200'), Decimal('-50'),
Decimal('300'), Decimal('-200')]
assert_equal(np.mirr(val, Decimal('0.05'), Decimal('0.06')), Decimal('0.342823387842176663647819868'))
val = [Decimal('39000'), Decimal('30000'), Decimal('21000'), Decimal('37000'), Decimal('46000')]
assert_(np.isnan(np.mirr(val, Decimal('0.10'), Decimal('0.12'))))
示例2: test_mirr
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import mirr [as 別名]
def test_mirr(self):
val = [-4500, -800, 800, 800, 600, 600, 800, 800, 700, 3000]
assert_almost_equal(np.mirr(val, 0.08, 0.055), 0.0666, 4)
val = [-120000, 39000, 30000, 21000, 37000, 46000]
assert_almost_equal(np.mirr(val, 0.10, 0.12), 0.126094, 6)
val = [100, 200, -50, 300, -200]
assert_almost_equal(np.mirr(val, 0.05, 0.06), 0.3428, 4)
val = [39000, 30000, 21000, 37000, 46000]
assert_(np.isnan(np.mirr(val, 0.10, 0.12)))
示例3: mirr
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import mirr [as 別名]
def mirr(cflo, finance_rate=0, reinvest_rate=0):
"""Computes the modified internal rate of return of a generic cashflow
as a periodic interest rate.
Args:
cflo (pandas.Series): Generic cashflow.
finance_rate (float): Periodic interest rate applied to negative values of the cashflow.
reinvest_rate (float): Periodic interest rate applied to positive values of the cashflow.
Returns:
Float or list of floats.
**Examples.**
>>> cflo = cashflow([-200] + [100]*4, start='2000Q1', freq='Q')
>>> mirr(cflo) # doctest: +ELLIPSIS
18.92...
>>> mirr([cflo, cflo]) # doctest: +ELLIPSIS
0 18.920712
1 18.920712
dtype: float64
"""
# negativos: finance_rate
# positivos: reinvest_rate
if isinstance(cflo, pd.Series):
cflo = [cflo]
retval = pd.Series([0] * len(cflo), dtype=np.float64)
for index, xcflo in enumerate(cflo):
retval[index] = (100 * np.mirr(xcflo,
finance_rate,
reinvest_rate))
if len(retval) == 1:
return retval[0]
return retval