SHARE
TWEET

Generating stable equity line

mjaniec Oct 24th, 2012 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # read post: http://www.reakkt.com/2012/10/how-to-generate-save-investment-strategy.html
  2.  
  3. k <- 500 # liczba strategii
  4.  
  5. n <- 500 # dlugosc okresu modelowania
  6.  
  7. x <- matrix(NA,n,k)
  8.  
  9. for (i in 1:k) x[,i] <- rnorm(n,mean=runif(1,0.01,0.05),sd=runif(1,1,6))/100
  10.  
  11. range(cov(x))
  12.  
  13. x <- sapply(1:k, function(i) cumsum(x[,i]))
  14.  
  15. y <- rowSums(x)
  16.  
  17. par(mfrow=c(2,1))
  18.  
  19. matplot(x,type="l",lty="solid",xlab="time",ylab="return")
  20.  
  21. plot(y,type="l",xlab="time",ylab="return")
  22.  
  23. par(mfrow=c(1,1))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top