-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrice_Generator.R
More file actions
49 lines (48 loc) · 1.01 KB
/
Copy pathPrice_Generator.R
File metadata and controls
49 lines (48 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
library(htmlTable)
library(IBrokers)
library(Quandl)
library(quantmod)
library(RcppRoll)
library(rvest)
library(TTR)
library(xml2)
library(xts)
library(zoo)
set.seed(1)
MAX <- (10)
N <-c(1:MAX)
LEN <- (9)
N2 <- (MAX+1)
Z_MEAN_1 <- (0)
Z_MEAN_2 <- (0)
RETURN_MEAN <- rnorm( N , 0 , 0.001 )
RETURN_SD <- rnorm( N , 0 , 0.1 )
u <- (RETURN_MEAN)# Expected annual return (%)
sd <- (RETURN_SD)# Expected annual standard deviation (%)
s <- rnorm(2, 200, 15)
#_
a <- 0#LEAVE ALONE
t <- (1:N2)# LEAVE ALONE -- TIME
a <- 0#LEAVE ALONE
for(i in N )
{Sys.sleep(0.1)
set.seed(1)
Z <- mvrnorm(n = MAX, mu = c(Z_MEAN_1,Z_MEAN_2), Sigma = matrix(c( 0.025 , .05 , .05 , 0.2 ), ncol = 2), empirical = TRUE)
STOCKS <- data.frame(Z)
s <- (rnorm(N, 200, 15))
price_1 <- (s[1])# Price vector
for(i_1 in STOCKS$X1)
{
S = s[1] + s[1]*(u/MAX + sd[1]/sqrt(MAX)*i_1)
price_1 <- S[1]
s[1] = S
a = a + 1
}
price_1 <- (S[i])
print(price_1)
#plot(price_1, y = NULL, type = "l")
#plot(price_2, y = NULL, type = "l")
Sys.time()
}
XXX <- data.frame(price_1 , N)
XXX