SHARE
TWEET

Untitled

a guest Dec 27th, 2012 120 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from pandas import Series, DataFrame, ols
  2. from pandas.io.data import DataReader
  3. from DataContainer import DataContainer
  4. import random
  5.  
  6. window = 21
  7. basic = DataReader("BHI", "yahoo")
  8. print len(basic)
  9. dependance = 15
  10.  
  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.         ]
  23.  
  24. keys = random.sample(sp100, dependance)
  25.  
  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)
RAW Paste Data
Top