Skip to content

Instantly share code, notes, and snippets.

@riqbal-k
Created October 16, 2022 13:33
Show Gist options
  • Save riqbal-k/8981edd3ec784b27bd246b2313d0e99e to your computer and use it in GitHub Desktop.
Save riqbal-k/8981edd3ec784b27bd246b2313d0e99e to your computer and use it in GitHub Desktop.
#Microsoft montly and daily log returns
ms.monthly.r<-Return.calculate(ms.monthly, method = "log")
ms.daily.r<-Return.calculate(ms.z, method = "log")
head(ms.monthly.r)
head(ms.daily.r)
#S and P montly and daily log returns
sp.monthly.r<-Return.calculate(sp.monthly, method = "log")
sp.daily.r<-Return.calculate(sp.z, method = "log")
head(sp.monthly.r)
head(sp.daily.r)
#daily and monhtly log returns for merged data
ms.sp.dp.r<-Return.calculate(ms.sp.dp, method = "log")
ms.sp.dm.r<-Return.calculate(ms.sp.dm, method = "log")
head(ms.sp.dp.r)
tail(ms.sp.dm.r)
To calculate simple returns, just replace "log" with "simple"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment