Hey guys,

I'm trying to write a function that will tell me if a pair of stocks are stationary. However, I'm having some trouble with both using the getSymbol function and with using the output to generate a ratio. This is my code

correlation_check=function(ticker1,ticker2) {
	stock1=getSymbols(toString(ticker1), src="yahoo", from= '2005-6-01', to ='2012-6-21')
	stock2=getSymbols(toString(ticker2), src="yahoo", from= '2005-6-01', to ='2012-6-21')
	ratio=(toString(stock1)$toString(stock1).Open)/(toString(stock2)$toString(stock2).Open)
	return=adf.test(ratio)
}

The function is supposed to return whether the 2 ratio of the 2 stock prices are stationary.

Problem 1: getSymbol requires the symbol to be entered as e.g "COKE". How can I run the ticker1/ticker2 into the function?

Problem 2: If getSymbol works, stock2's class becomes a character. How do I get a column within the ticker for each stock for a ratio?

Thanks so much!

--
Yitao Zhang
Stanford University '14
B.A. in Economics
(650)-391-6966 | yitaoz@stanford.edu




	[[alternative HTML version deleted]]

