Menu główne
##########################################################################################
### Symulacja inwestycji giełdowej ###
##########################################################################################
N=1000
ls=300 # licza sesji
X=1000
BH=matrix(runif(N*30,0.0006,0.0112),N,ls)
BB=matrix(runif(N*30,-
SH=matrix(runif(N*30,0.0002,0.0098),N,ls)
SB=matrix(runif(N*30,-
i=1
bh=1
stan=c()
while (i<ls)
if (bh==1) dl=ceiling(runif(1,64,126)) else dl=ceiling(runif(1,28,112))
stan[i:(i+dl-
i=i+dl
bh=1-
}
stan
for (i in 1:ls)
{
if (stan[i]==0)
{
BH[,i]=0
SH[,i]=0
}
else
{
BB[,i]=0
SB[,i]=0
}
}
B=BH+BB+1
S=SH+SB+1
XB=apply(B,1,prod)*X
XS=apply(S,1,prod)*X
par(mfrow=c(3,1))
hist(XB,xlim=c(1000,4000))
hist(XS,xlim=c(1000,4000))
hist(XB-
mean(XB-
sd(XB-