Using simulation p <- 100 sd <- 0.2 X <- 90 N <- 10 n <- 1000000 hit <- double(n) for (i in 1:n) { hit[i] <- as.numeric(any(p * exp(cumsum( rnorm(N, sd = sd / sqrt(250)) )) < X)) } sum(hit)/n
Instead of using rnorm you may want to use e.g. rt() or an (G)ARCH process or... Best Adrian On 25.11.2015 12:00, r-sig-finance-requ...@r-project.org wrote: > Message: 1 > Date: Tue, 24 Nov 2015 18:27:19 -0600 > From: Ernest Stokely <wizardc...@gmail.com> > To: R-SIG-Finance@r-project.org > Subject: [R-SIG-Finance] Computing stop probability > Message-ID: <ca1cb4f2-72e7-45b6-a124-a12bdab33...@gmail.com> > Content-Type: text/plain; charset=us-ascii > > Maybe a naive question but given the price and SD of an asset, is there a way > to calculate the probability of hitting a stop set at X over the next N days? > I know making appropriate assumptions, this is a Wiener process but can't > find the correct equation. > > A) Is there a closed form solution for this? > B) Is there an R function related to this? > > Ernie > > Sent from my iPhone -- Dr. Adrian Trapletti Steinstrasse 9b CH-8610 Uster Switzerland Phone : +41 (0) 44 994 56 30 Mobile : +41 (0) 79 103 71 31 Email : adr...@trapletti.org WWW : www.trapletti.org _______________________________________________ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.