Use “c” when you want to use it a signal in black scholes formula.

read.table function will be used to get the data into R (/\ used opposite

than the one used in windows)

http://www.ats.ucla.edu/stat/r/faq/inputdata_R.htm.

**Example 1**

> test.txt <- read.table ("C:/Documents and Settings/shivbhakta.joshi/My

Documents/test.txt", header=T)

> print(test.txt)

> column <- test.txt[,c('make','price')].

**Example 2**

grb <- read.table ("C:/Documents and Settings/shivbhakta.joshi/My

Documents/GRB_afterglow.dat", header=T, skip=1)

x <- (grb[,1]).

**Grabbing data from tables into a single dimensional array**

x <- (grb[,1])

y <- log(grb[,1]).

__Another way to create returns for stock daily return is__

f=dft$age/dft$price (using dollar sign extraction)

Deleting column http://www.sr.bham.ac.uk/~ajrs/R/r-manipulate_data.html

> add <- add[-2] to delete the element 2nd

Adding data to array busing column command

> add <- c(1,d).

**Using Data frames**

Data.frame is used to combine the arrays back into table format

people = data.frame (x,y)

Write.CSV command executed

write.csv(people,"filename.csv")

grb <- read.table ("C:/Documents and Settings/satyadhar.joshi/My

Documents/GRB_afterglow.dat", header=T, skip=1)

x <- (grb[,1])

y <- log(grb[,1])

people = data.frame (x,y)

write.csv(people,"filename.csv")

These methods can be used to compute beta from columns of a csv file.

**Working formula of Black Scholes**

BS <-

function(S, K, T, r, sig, type="C"){

d1 <- (log(S/K) + (r + sig^2/2)*T) / (sig*sqrt(T))

d2 <- d1 - sig*sqrt(T)

if(type=="C"){

value <- S*pnorm(d1) - K*exp(-r*T)*pnorm(d2)

}

if(type=="P"){

value <- K*exp(-r*T)*pnorm(-d2) - S*pnorm(-d1)

}

return(value)

}

Black Scholes <- function(s, k, r=.1, t=5, sigma=.9,call=TRUE) {

#calculate call/put option

d1 <- (log(s/k)+(r+sigma^2/2)*t)/(sigma*sqrt(t))

d2 <- d1 - sigma * sqrt(t)

ifelse(call==TRUE,s*pnorm(d1) - k*exp(-r*t)*pnorm(d2),k*exp(-r*t)

* pnorm(-d2) - s*pnorm(-d1))

}

**Predefined Black schools model:**

http://shafik.net/~shafik/FinancialEngineering/Code/

black_scholes ("c",5600,5600,.1,.08,.22 )

this depicts use of functions in R.

**Merton Distance to Default (different as per needs)**

**ARIMA and Forecasting Using R**

__Commands:__

library(Quandl)

> Quandl.auth("1LkmpypqJskJzKcpd2TV")

>stockData=Quandl("YAHOO/INDEX_GSPC", start_date="2004-01-01", end_date="2014-04-17")

stockData[,7]

// ran Arima here:

results2=arima(stockData[,7], order = c(3,0,0))

fit <- arima(myts, order=c(p, d, q)

fit <- arima(stockData[,7],order = c(3,0,0))

results=arima(stockData[,7])

fit <- arima(stockData[,7],order = c(3,0,0))

predict(arima(stockData[,7], order = c(3,0,0))

results=arima(stockData[,7])

x2=(forecast(fit, 100))

plot(x2).

**Excel and R:**

http://rcom.univie.ac.at/download.html#statconnDCOM

http://www.r-bloggers.com/a-million-ways-to-connect-r-and-excel/

http://cran.r-project.org/web/packages/XLConnect/vignettes/XLConnect.pdf

http://cran.r-project.org/web/packages/XLConnect/XLConnect.pdf

https://stat.ethz.ch/R-manual/R-patched/library/base/html/getwd.html

__Playing with arrays and matrix__

http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-my-matrices-lose-dimensions_003f

https://stat.ethz.ch/pipermail/r-help/2008-February/154088.html

http://stat.ethz.ch/R-manual/R-devel/library/base/html/rev.html.

__ARIMA and Predict statement__

http://stat.ethz.ch/R-manual/R-patched/library/stats/html/predict.arima.html

http://people.duke.edu/~rnau/411arim.htm

http://www.statmethods.net/advstats/timeseries.html

http://stackoverflow.com/questions/14272937/time-series-prediction-using-r

http://www.inside-r.org/packages/cran/forecast/docs/forecast.Arima.

__Market check__

http://www.bloomberg.com/quote/SPX:IND/chart.

__Other good References__

http://heather.cs.ucdavis.edu/~matloff/132/NSPpart.pdf.

**One on One Customized Training:**

qcfinance.in believes in personalized touch so that our clients are completely satisfied with our service. In this regard, we offer** One on One Customized Training** to our clients.

These Trainings are provided on request by our clients & are customized according to their individual needs.

The course structure & timings for these training are highly flexible, classes are scheduled as per the convenience of our clients.

**Contact Us for More details: info@qcfinance.in.**