Calculating Day Count for Accrued Interest and Market Values
Introduction
When calculating the market value of an asset it is necessary to use the correct number of days (day count) since the last payment.
There are several industry standard methods of estabilishing the number of days to use. Each stock or bond will have the method used detailed in the listing particulars, or uses a known method eg UK Treasury Stocks use the ICMA Actual/Actual (ACT/ACT  ICMA) method.
Using the information in the next section to get the factor, the actual amount of Accrued interest would be calculated thus:
AInt = Nominal x couponRate x factor
The result would then be added to (Nominal x cleanPrice / 100) to get the full market value
Glossary
Term
 Description


Date1
 Starting point of the accrual. This would be either the issue date or the date of the last interim payment.

D1,M1,Y1
 The date parts (day, month year) of Date1

Date2
 date to which interest is being accrued. (When dealing with a trade this is the settlement/payment date)

D2,M2,Y2
 The date parts (day, month year) of Date2

Date3
 next interest payment date after date2. This would be the maturity date if there are no more interim payments to be made

D3,M3,Y3
 The date parts (day, month year) of Date3

EOM
 End of the Calendar month

Freq
 Annual interim payment frequency e.g. 4 = paid quarterly

Nom
 Nominal (aka par value) or quantity

Calculation Formulas
Where the notation Daten – Datem is used, it is the difference between the two dates expressed in days.
30/360
First of all make the following substitutions :
If D1 = 31 set D1 = 30
If D2 = 31 and D1 = 30 or 31 set D2 = 30
If M1 = 2 and Y1 is a leap year and D1=29 set D1=30
If M1 = 2 and Y1 is not a leap year and D1=28 set D1=30
Factor = [ (360 x (Y2Y1)) + (30 x (M2M1)) + (D2D1) ] / 360
ISMA 30/360 (30E/360)
First of all make the following substitutions
If D1 = 31 set D1 = 30
If D2 = 31 set D2 = 30
Factor = [ (360 x (Y2Y1)) + (30 x (M2M1)) + (D2D1) ] / 360
30E+/360
First of all make the following substitutions:
If D1 = 31 set D1=30
If D2 = 31 and M2 = 12 set M2 = 1, D2=1 and Y2 = Y2 + 1
If D2 = 31 set M2=M2 + 1 and D2=1
Factor = [ (360 x (Y2Y1)) + (30 x (M2M1)) + (D2D1) ] / 360
ISDA ACT/ACT
If neither Date1 nor Date2 are in a leap year treat as ACT/365
Otherwise:
YD1 Number of days in the year of Y1 i.e. if Y1 is a leap year then YD1=366
YD2 Number of days in the year of Y2
DD1 Number of days between Date1 and 31st December of Y1
DD2 Number of days between 1st January of Y2 and Date2
Factor = (DD1 / YD1) + (DD2 / YD2)
NL/365
This is basically ACT/365 but disregards 29th Feb
If neither Y1 nor Y2 are in a leap year then treat as ACT/365
If Y1 is a leap year and M1 > 2 treat as ACT/365
If Y2 is a leap year and M2 = 1 treat as ACT/365
If Y2 is a leap year and M2 = 2 and D2 < 29 treat as ACT/365
Otherwise
Factor = [ (Date2 – Date1) 1 ] / 365
ACT/ACT (ICMA)
This is the method used when calculating accrued interest on Gilts
Factor = (date2  date1) / [Freq x (date3  date1)]
ACT/365L (ACT/ACT AFB)
If Freq = 1 and Y1 is a leap year and M1 < 3 treat as ACT/366
If Freq = 1 and Y3 is a leap year and M3 > 2 treat as ACT/366
If Freq = 1 and Y3 is a leap year and M3 = 2 and D3 = 29 treat as ACT/366
If Freq > 1 and Y3 is a leap year treat as ACT/366
Otherwise
Factor = (date2  date1) / 365
ACT/360
Factor = (date2 – date1) / 360
ACT/365 (aka ACT/365 Fixed)
Factor = (date2  date1) / 365
ACT/366 (This is not a real type, but a catchall for others where specified above)
Factor = (date2  date1) / 366
Related Links
 Calculating Money Type Asset Value
How to calculate book and market values for Certificates of Deposit (CD's), Stocks & Bonds and Bills
Comments
i wil be an finanance
Your formula for ACT/ACT ISDA is only correct if Y2 = Y1 +1. For the general case add (Y2Y11) to factor and consider Y2=Y1... for an implementation (Java) see http://svn.finmath.net/finmath%20lib/trunk/src/mai...