请问如何计算“内部收益率(IRR)”,路过均有分啦
请问如何计算“内部收益率(IRR)”,Excel内有个函数IRR就可以实现这个功能,但 C++ Builder 内的函数有实现这个功能的函数吗?
[解决办法]
C++ 里没有这些财务算法的
lz你最好找懂财务的人 或者 去Excel 帮助区看看 这个IRR函数的计算原理
[解决办法]
[解决办法]
不懂财务的飘过
[解决办法]
正根的取值范围
下界:|a0|/(|a0|+M0)
上界:(|an|+Mn)/|an|
M0=max{|an|,...,|a1|}
Mn=max{|an-1|,...,|a0|},n-1为下标
[解决办法]
老外用sql写的,供参考:
create table IncomeTable (
amt float,
d datetime
)
insert into IncomeTable values (-1000,'19980101')
insert into IncomeTable values (200,'19990101')
insert into IncomeTable values (200,'20000101')
insert into IncomeTable values (200,'20010101')
insert into IncomeTable values (200,'20020101')
insert into IncomeTable values (200,'20030101')
insert into IncomeTable values (200,'20040101')
go
create function irr(
@d datetime
) returns decimal(18,10) as begin
declare @irrPrev float set @irrPrev = 0
declare @irr float set @irr = 0.1
declare @pvPrev float
declare @pv float
set @pvPrev = (
select sum(amt)
from IncomeTable
)
set @pv = (
select sum(amt/power(1e0+@irr,cast(d-@d as float)/360e0))
from IncomeTable
)
while abs(@pv) >= 0.0001 begin
declare @t float
set @t = @irrPrev
set @irrPrev = @irr
set @irr = @irr + (@t-@irr)*@pv/(@pv-@pvPrev)
set @pvPrev = @pv
set @pv = (
select sum(amt/power(1e0+@irr,cast(d-@d as float)/365e0))
from IncomeTable
)
end
return @irr
end
go
select dbo.irr('19980101')
go
drop function irr
drop table IncomeTable
go
[解决办法]
学习下。