PassivRegression
New Member
- Joined
- Mar 28, 2019
- Messages
- 3
Hi everyone,
i have a dataset containing funds, their monthly returns and cashflows. It's a long data structure, so i have multiple rows for each fund. Then i have to solve an Equation with solver for each fund. I want to calculate an internal rate of return using the formla:
AssetatStart*(1+r)^T + Sum(cashflow*(1+r)^T-t) = AssetatEnd
T is the amount of periods for each fund, t is the time (the month).
Im able to do this (calculate r) for 1 fund, but im unable to automate it in VBA to run for all. The solutions i found on this forum all solved individually for each row, but i need to solve for each id (meaning ech fund containing multiple rows). In Addition to that, each fund has a different amount of rows, which makes it even more complicated (at least for me ).
[TABLE="width: 500"]
<tbody>[TR]
[TD]id[/TD]
[TD]cash flow[/TD]
[TD]Assets[/TD]
[TD]time[/TD]
[TD]Asset at Start[/TD]
[TD]Asset at End[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]50[/TD]
[TD]100[/TD]
[TD]1[/TD]
[TD]100[/TD]
[TD]128[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]30[/TD]
[TD]150[/TD]
[TD]2[/TD]
[TD]100[/TD]
[TD]128[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]-10[/TD]
[TD]128[/TD]
[TD]3[/TD]
[TD]100[/TD]
[TD]128[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]-20[/TD]
[TD]80[/TD]
[TD]1[/TD]
[TD]80[/TD]
[TD]95[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]30[/TD]
[TD]95[/TD]
[TD]2[/TD]
[TD]80[/TD]
[TD]95[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]50[/TD]
[TD]120[/TD]
[TD]1[/TD]
[TD]120[/TD]
[TD]150[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]-60[/TD]
[TD]110[/TD]
[TD]2[/TD]
[TD]120[/TD]
[TD]150[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]20[/TD]
[TD]160[/TD]
[TD]3[/TD]
[TD]120[/TD]
[TD]150[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]30[/TD]
[TD]150[/TD]
[TD]4[/TD]
[TD]120[/TD]
[TD]150[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]-5[/TD]
[TD]..[/TD]
[TD]1[/TD]
[TD]..[/TD]
[TD]..[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]-10[/TD]
[TD]..[/TD]
[TD]2[/TD]
[TD]..[/TD]
[TD]..[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]-20[/TD]
[TD]..[/TD]
[TD]3[/TD]
[TD]..[/TD]
[TD]..[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]30[/TD]
[TD]..[/TD]
[TD]1[/TD]
[TD]..[/TD]
[TD]..[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]-10[/TD]
[TD]..[/TD]
[TD]2[/TD]
[TD]..[/TD]
[TD]..[/TD]
[/TR]
</tbody>[/TABLE]
Thank you for your time.
Best regards,
PassivRegression
i have a dataset containing funds, their monthly returns and cashflows. It's a long data structure, so i have multiple rows for each fund. Then i have to solve an Equation with solver for each fund. I want to calculate an internal rate of return using the formla:
AssetatStart*(1+r)^T + Sum(cashflow*(1+r)^T-t) = AssetatEnd
T is the amount of periods for each fund, t is the time (the month).
Im able to do this (calculate r) for 1 fund, but im unable to automate it in VBA to run for all. The solutions i found on this forum all solved individually for each row, but i need to solve for each id (meaning ech fund containing multiple rows). In Addition to that, each fund has a different amount of rows, which makes it even more complicated (at least for me ).
[TABLE="width: 500"]
<tbody>[TR]
[TD]id[/TD]
[TD]cash flow[/TD]
[TD]Assets[/TD]
[TD]time[/TD]
[TD]Asset at Start[/TD]
[TD]Asset at End[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]50[/TD]
[TD]100[/TD]
[TD]1[/TD]
[TD]100[/TD]
[TD]128[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]30[/TD]
[TD]150[/TD]
[TD]2[/TD]
[TD]100[/TD]
[TD]128[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]-10[/TD]
[TD]128[/TD]
[TD]3[/TD]
[TD]100[/TD]
[TD]128[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]-20[/TD]
[TD]80[/TD]
[TD]1[/TD]
[TD]80[/TD]
[TD]95[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]30[/TD]
[TD]95[/TD]
[TD]2[/TD]
[TD]80[/TD]
[TD]95[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]50[/TD]
[TD]120[/TD]
[TD]1[/TD]
[TD]120[/TD]
[TD]150[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]-60[/TD]
[TD]110[/TD]
[TD]2[/TD]
[TD]120[/TD]
[TD]150[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]20[/TD]
[TD]160[/TD]
[TD]3[/TD]
[TD]120[/TD]
[TD]150[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]30[/TD]
[TD]150[/TD]
[TD]4[/TD]
[TD]120[/TD]
[TD]150[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]-5[/TD]
[TD]..[/TD]
[TD]1[/TD]
[TD]..[/TD]
[TD]..[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]-10[/TD]
[TD]..[/TD]
[TD]2[/TD]
[TD]..[/TD]
[TD]..[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]-20[/TD]
[TD]..[/TD]
[TD]3[/TD]
[TD]..[/TD]
[TD]..[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]30[/TD]
[TD]..[/TD]
[TD]1[/TD]
[TD]..[/TD]
[TD]..[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]-10[/TD]
[TD]..[/TD]
[TD]2[/TD]
[TD]..[/TD]
[TD]..[/TD]
[/TR]
</tbody>[/TABLE]
Thank you for your time.
Best regards,
PassivRegression