Check out the Pastebin Gadgets Shop. We have thousands of fun, geeky & affordable gadgets on sale :-)Want more features on Pastebin? Sign Up, it's FREE!


By: a guest on Dec 27th, 2012  |  syntax: None  |  size: 1.25 KB  |  views: 92  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print  |  QR code  |  clone
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. from pandas import Series, DataFrame, ols
  2. from import DataReader
  3. from DataContainer import DataContainer
  4. import random
  6. window = 21
  7. basic = DataReader("BHI", "yahoo")
  8. print len(basic)
  9. dependance = 15
  11. sp100 = [
  12.             "AAPL", "ABT", "ACN", "AEP", "ALL", "AMGN", "AMZN", "APC",
  13.             "AXP", "BA", "BAC", "BAX", "BK", "BMY", "BRK.B", "CAT", "C", "CL",
  14.             "CMCSA", "COF", "COP", "COST", "CPB", "CSCO", "CVS", "CVX", "DD", "DELL",
  15.             "DIS", "DOW", "DVN", "EBAY", "EMC", "EXC", "F", "FCX", "FDX", "GD", "GE",
  16.             "GILD", "GOOG", "GS", "HAL", "HD", "HNZ", "HON", "HPQ", "IBM", "INTC",
  17.             "JNJ", "JPM_1", "KFT", "KO", "LLY", "LMT", "LOW", "MA", "MCD", "MDT", "MET",
  18.             "MMM", "MO", "MON", "MRK", "MS", "MSFT", "NKE", "NOV", "NSC", "NWSA",
  19.             "NYX", "ORCL", "OXY", "PEP", "PFE", "PG", "PM", "QCOM", "RF", "RTN",
  20.             "SBUX", "SLB", "SLE", "SO", "SPG", "T", "TGT", "TWX", "TXN", "UNH", "UPS",
  21.             "USB", "UTX", "VZ", "WAG", "WFC", "WMB", "WMT", "XOM"
  22.         ]
  24. keys = random.sample(sp100, dependance)
  26. data = {key: DataReader(key, "yahoo") for key in keys}
  27. vals = {key: DataFrame(data=Series(data[key], name=key), index=basic.index) for key in data}
  28. model = ols(y=basic, x=vals, window=window)
clone this paste RAW Paste Data