# compute return from yield

I was wondering if someone familiar with the RQuantLib library can have a look and let me know if this makes sense.

I am trying to get total return of a 5 year constant maturity treasury bond. Does the below make sense?

### Bonds
# Calculate total returns from the yield of 5 year constant matury bond
getSymbols("DGS5", src="FRED") #load US Treasury 5y yields from FRED
data <-DGS5
ret[1]<-0
for (i in 1:(nrow(data)-1)) {
temp <- FixedRateBondPriceByYield(yield=data[i+1,1]/100, issueDate=Sys.Date(), maturityDate=advance("UnitedStates/GovernmentBond", Sys.Date(), 10, 3),  rates=data[i,1]/100,period=2)[1]/100-1
ret[i+1]<-temp

}
#total return will be the price return + yield/360
tret <- ret + lag(data,k=1)/360/100