title: Python script to calculate asset beta giving incorrect result
body: <p>I started programming about a week ago, and I completed the code-academy tutorial and watched some lectures online. My first goal is to build is an interactive portfolio optimization program. </p>
  
  <p>I have written a script to find the beta of an asset (co-variance of a and b / variance of b) however my results are no where near the actual beta's for the assets that I plug in. Using 'AAPL' and 'SPY' the result should be around .75, and it's yielding ~.16. </p>
  
  <p>I'd like to return the r^2 as well if possible, and use monthly data over a longer period of time. </p>
  
  <p>Here is my code: </p>
  
  <pre><code>from pandas.io.data import DataReader
  from datetime import datetime
  from datetime import date
  import numpy
  
  ### Enter the stocks to be analyzed
  
  s1 = input('Input the first ticker in quotations: ')
  s2 = input('Input the second ticker in quotations: ')
  
  
  ### Pulling stock data from yahoo finance
  
  today = date.today()
  
  stock_one = DataReader((s1),'yahoo', datetime(2013,1,1), today)
  stock_two = DataReader((s2),'yahoo', datetime(2013,1,1), today)
  
  a = stock_one['Adj Close']
  b = stock_two['Adj Close']
  
  ### Calculating the beta for the stock
  
  covariance = numpy.cov(a,b)[0][1]
  variance = numpy.var(a)
  
  beta = covariance / variance
  
  print 'The beta for your stock is ' + str(beta)
  </code></pre>