When calculating duration would you use the clean price or the dirty price? why for either?
2 Answers
By definition, modified duration is $$ D_\text{mod} = \frac{1}{P} \frac{dP}{dy} $$ where $P$ is the dirty price of a bond.
Clean price is the standard quoting convention for the vast majority of bond markets (though not all), but nearly all analytics, be it yield to maturity, DV01, or duration, are all computed using dirty price.
Accrued coupon does not depend on yield so it does not really matter but the convention is to use dirty price which is the market value of the bond
EDIT: i initially incorrectly stated that the clean bond price was used by convention. Helin was correct to point out the opposite is true. For instance here is a documentation from FTSE where you can see that the market value of bonds is used for calculation (market value being dirty price that is clean price plus accrued coupons)
https://www.ftse.com/products/downloads/FTSE_Fixed_Income_Index_Guide_to_Calculation_new.pdf