本文整理汇总了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