Compound interest quarterly

I know the financial formula for calculating compound interest:

Compound Interest Multiple = [1+(Annual Interest in decimals/365)]^(number of days).

I have a initial and final date. I calculate the difference between these two dates in days. Then i divide the total days for 90 (quarterly).

Quarter = (double) days / 90.0;

capitalAndInterest = capital * pow ((1.0 + rate/100.0/4.0), quarter);

Unfortunately that formula doesn't fit, cause i need to know at the end of each quarter what is the partial days' sum and the partial interest calculated.

Perhaps i should update capital compounded with the given rate at the end of every quarter ? ?

1) Take initial date and see in which quarter i'm in. If ie i'm in first quarter do a difference between initial date and the end of first quarter (31th march). Do the math calculation.

2) Do the same for final date.

3) Then calculate the exact quarters left

4) Cycle all these quarters and do the math calculation for each period (but how to cycle them ??)

5) Adding all these results in an array

but all that seems too complicated, perhaps there's another simpler approach to the solution ?

-

Your first formula would be correct for daily compounded interest computed on a rate quoted on an ACT/365 basis (actual number of days in the accrual period divided by 365).

This is how bank accounts often work as crediting interest at the end of each day is not a big deal. However in the financial world paying interest daily to a counterparty would not be practicable so they normally pay monthly, quarterly, semi-annually or annually. There are many different daycount conventions (ACT/ACT, ACT/360, ACT/365, ACT/365F, 30/360 etc etc) associated with this. There are also different ways to adjust the accrual periods for holidays/weekends (Day Roll conventions). In a year you might have four quarters of exactly 1/4 (of the stated rate), or 91, 91, 92, 91 or 89, 93, 88, 95. It all depends. And the periods don't just run to 31st March, a quarterly deal can be struck on any day.

In short, you're probably wasting your time trying to code this as it wont be how bonds/swaps and other financial instruments actually work.

-