code: def get_beta(values1, values2):
      # http://statsmodels.sourceforge.net/stable/regression.html
      model = sm.OLS(values1, values2)
      results = model.fit()
      return results.params[0]
  
imports: from __future__ import print_function
  from pyalgotrade import strategy
  from pyalgotrade import dataseries
  from pyalgotrade.dataseries import aligned
  from pyalgotrade import plotter
  from pyalgotrade.barfeed import yahoofeed
  from pyalgotrade.stratanalyzer import sharpe
  import numpy
  import statsmodels.api
label_desc: Use image node_id 1 for calling a global function with example usage: get_beta(values1, values2) and returns: results