In [1]:
import pandas.io.data as web
import datetime
import random
import math


C:\Anaconda2\lib\site-packages\pandas\io\data.py:33: FutureWarning: 
The pandas.io.data module is moved to a separate package (pandas-datareader) and will be removed from pandas in a future version.
After installing the pandas-datareader package (https://github.com/pydata/pandas-datareader), you can change the import ``from pandas.io import data, wb`` to ``from pandas_datareader import data, wb``.
  FutureWarning)

In [2]:
start = datetime.datetime(2012, 1, 1)
end = datetime.datetime(2016, 5, 10)
stock = "TSLA"

In [3]:
gs = web.DataReader(stock, "yahoo", start, end)

In [4]:
gs.info()


<class 'pandas.core.frame.DataFrame'>
DatetimeIndex: 1095 entries, 2012-01-03 to 2016-05-10
Data columns (total 6 columns):
Open         1095 non-null float64
High         1095 non-null float64
Low          1095 non-null float64
Close        1095 non-null float64
Volume       1095 non-null int64
Adj Close    1095 non-null float64
dtypes: float64(5), int64(1)
memory usage: 59.9 KB

In [7]:
prices = [float(x) for x in gs['Adj Close']]

In [8]:
gs


Out[8]:
Open High Low Close Volume Adj Close
Date
2012-01-03 28.940001 29.500000 27.650000 28.080000 928100 28.080000
2012-01-04 28.209999 28.670000 27.500000 27.709999 630100 27.709999
2012-01-05 27.760000 27.930000 26.850000 27.120001 1005500 27.120001
2012-01-06 27.200001 27.790001 26.410000 26.910000 986300 26.910000
2012-01-09 27.000000 27.490000 26.120001 27.250000 897000 27.250000
2012-01-10 27.440001 27.760000 27.250000 27.620001 671800 27.620001
2012-01-11 27.620001 28.379999 27.299999 28.230000 672300 28.230000
2012-01-12 28.480000 28.620001 27.809999 28.250000 729300 28.250000
2012-01-13 28.400000 28.500000 22.639999 22.790001 5500400 22.790001
2012-01-17 26.620001 27.340000 26.410000 26.600000 4651600 26.600000
2012-01-18 26.690001 26.879999 26.250000 26.809999 1260200 26.809999
2012-01-19 27.190001 27.740000 26.610001 26.760000 1246300 26.760000
2012-01-20 26.900000 27.000000 26.400000 26.600000 662300 26.600000
2012-01-23 26.809999 27.209999 26.600000 26.770000 594600 26.770000
2012-01-24 26.629999 27.680000 26.440001 27.420000 858000 27.420000
2012-01-25 27.270000 28.010000 27.049999 27.969999 611200 27.969999
2012-01-26 28.070000 29.580000 28.000000 28.940001 1271100 28.940001
2012-01-27 28.500000 29.719999 28.500000 29.330000 748400 29.330000
2012-01-30 29.490000 29.610001 28.530001 29.570000 729000 29.570000
2012-01-31 29.900000 30.000000 28.870001 29.070000 956400 29.070000
2012-02-01 29.070000 29.700001 29.000000 29.580000 523200 29.580000
2012-02-02 29.719999 30.879999 29.610001 30.250000 805700 30.250000
2012-02-03 30.410000 31.330000 30.250000 31.150000 764500 31.150000
2012-02-06 31.100000 31.900000 31.049999 31.799999 652100 31.799999
2012-02-07 31.799999 31.799999 30.820000 31.600000 1021600 31.600000
2012-02-08 31.600000 32.009998 31.290001 31.930000 623700 31.930000
2012-02-09 32.000000 32.900002 31.430000 32.580002 1277100 32.580002
2012-02-10 32.259998 32.270000 29.840000 31.100000 1874200 31.100000
2012-02-13 31.549999 32.060001 30.900000 31.490000 1157900 31.490000
2012-02-14 31.740000 33.790001 31.400000 33.169998 1810800 33.169998
... ... ... ... ... ... ...
2016-03-30 235.089996 235.500000 226.500000 226.889999 4019700 226.889999
2016-03-31 229.339996 237.419998 225.009995 229.770004 7956700 229.770004
2016-04-01 244.830002 247.899994 233.250000 237.589996 15962000 237.589996
2016-04-04 249.119995 252.119995 243.639999 246.990005 13396500 246.990005
2016-04-05 240.500000 256.559998 240.000000 255.470001 9915200 255.470001
2016-04-06 253.970001 267.739990 253.449997 265.420013 11679900 265.420013
2016-04-07 266.450012 269.339996 254.509995 257.200012 8836800 257.200012
2016-04-08 260.500000 260.820007 248.020004 250.070007 7332200 250.070007
2016-04-11 251.000000 258.989990 245.300003 249.919998 9153900 249.919998
2016-04-12 249.500000 251.800003 243.630005 247.820007 5750800 247.820007
2016-04-13 248.509995 255.500000 247.330002 254.529999 4917900 254.529999
2016-04-14 253.000000 256.839996 251.050003 251.860001 4120000 251.860001
2016-04-15 251.309998 254.600006 249.119995 254.509995 3742000 254.509995
2016-04-18 252.229996 258.309998 251.660004 253.880005 4261800 253.880005
2016-04-19 253.119995 254.369995 241.250000 247.369995 6349400 247.369995
2016-04-20 246.259995 253.660004 241.500000 249.970001 5190800 249.970001
2016-04-21 248.990005 250.899994 246.910004 248.289993 2754900 248.289993
2016-04-22 248.889999 254.000000 245.710007 253.750000 3774600 253.750000
2016-04-25 253.009995 257.380005 250.759995 251.820007 3664300 251.820007
2016-04-26 252.050003 255.729996 249.389999 253.740005 3212500 253.740005
2016-04-27 252.750000 255.000000 249.399994 251.470001 3190700 251.470001
2016-04-28 249.850006 253.429993 247.440002 247.710007 2509500 247.710007
2016-04-29 248.139999 248.429993 237.809998 240.759995 5388700 240.759995
2016-05-02 241.500000 243.190002 234.820007 241.800003 3836400 241.800003
2016-05-03 237.360001 238.910004 231.619995 232.320007 4289200 232.320007
2016-05-04 230.289993 234.460007 220.399994 222.559998 8262500 222.559998
2016-05-05 228.460007 228.639999 209.789993 211.529999 11235800 211.529999
2016-05-06 210.869995 216.369995 208.110001 214.929993 5681100 214.929993
2016-05-09 215.720001 216.149994 206.800003 208.919998 4758100 208.919998
2016-05-10 207.550003 209.470001 205.000000 208.690002 4065200 208.690002

1095 rows × 6 columns


In [9]:
import random

def getDiffValue(lastDayValue, marginDayValue):
    return float(marginDayValue - lastDayValue)/marginDayValue

def selectSampleIndex(listSize, sampleSize, maxSeqLen):
    if listSize <= 0 or sampleSize <= 0 or listSize < sampleSize:
        return []
    
    resSample = set()
    while len(resSample) < sampleSize:
        pick = random.randint(0, listSize-maxSeqLen)
        resSample.add(pick)
    res = list(resSample)
    res.sort()
    return res

In [11]:
maxSeqLen = 20
marginDays = 5
minGain = 0.05
numSamples = 200

In [12]:
resIdx = selectSampleIndex(len(gs), numSamples, maxSeqLen)
resIdx[0:10], resIdx[-10:] #see first and last 10 index


Out[12]:
([4, 13, 22, 26, 42, 45, 47, 50, 51, 54],
 [1030, 1035, 1036, 1052, 1053, 1055, 1061, 1065, 1072, 1074])

In [16]:
outfilename = 'tesla_data.csv'
outfile = open(outfilename,'w')


#print header
header = 'day'+',day'.join([`num+1` for num in xrange(maxSeqLen-marginDays)])+',isBullish'+'\n'
outfile.write(header)

for idx in resIdx:
    isBullish = 0
    diff = getDiffValue(prices[idx+(maxSeqLen-marginDays)-1], prices[idx+maxSeqLen])
    if diff > minGain:
        isBullish = 1
    elif diff < (-1*minGain):
        isBullish = -1
    else:
        isBullish = 0
    #print idx, tsla_prices[idx:idx+10], tsla_prices[idx+15], good, diff
    #print tsla_prices[idx:idx+maxSeqLen-5], tsla_prices[idx+maxSeqLen], isBullish
    result = prices[idx:idx+maxSeqLen-marginDays]
    result.append(isBullish)
    trainset = ",".join([`price` for price in result])
    outfile.write(trainset)
    outfile.write('\n')

outfile.close()

In [14]:
prices


Out[14]:
[28.08,
 27.709999,
 27.120001000000002,
 26.91,
 27.25,
 27.620001000000002,
 28.23,
 28.25,
 22.790001,
 26.6,
 26.809998999999998,
 26.76,
 26.6,
 26.77,
 27.42,
 27.969998999999998,
 28.940001000000002,
 29.33,
 29.57,
 29.07,
 29.58,
 30.25,
 31.15,
 31.799999,
 31.6,
 31.93,
 32.580002,
 31.1,
 31.49,
 33.169998,
 33.599998,
 34.18,
 34.970001,
 34.5,
 34.220001,
 34.529999,
 33.75,
 33.619999,
 33.810001,
 33.41,
 34.41,
 34.040001000000004,
 33.77,
 33.110001000000004,
 33.119999,
 33.07,
 34.740002000000004,
 36.009997999999996,
 36.09,
 35.290001000000004,
 35.0,
 35.32,
 34.98,
 34.959998999999996,
 35.150002,
 34.400002,
 34.080002,
 37.400002,
 37.939999,
 37.849998,
 37.330002,
 37.240002000000004,
 36.580002,
 38.009997999999996,
 35.0,
 34.48,
 33.150002,
 32.459998999999996,
 33.09,
 33.439999,
 33.59,
 32.25,
 32.240002000000004,
 32.66,
 33.16,
 33.16,
 31.940001000000002,
 31.82,
 32.91,
 33.490002000000004,
 33.34,
 33.130001,
 33.779999,
 33.939999,
 32.459998999999996,
 31.83,
 32.470001,
 30.190001000000002,
 30.059998999999998,
 32.959998999999996,
 32.25,
 30.059998999999998,
 29.43,
 29.18,
 28.57,
 27.559998999999998,
 28.77,
 30.799999,
 31.02,
 30.280001000000002,
 29.809998999999998,
 31.690001000000002,
 30.41,
 29.5,
 28.15,
 27.879998999999998,
 27.91,
 29.219998999999998,
 28.93,
 30.08,
 29.120001000000002,
 29.66,
 29.77,
 29.389999,
 29.91,
 31.84,
 32.09,
 33.779999,
 32.189999,
 33.790001000000004,
 33.110001000000004,
 31.610001,
 31.959999,
 31.41,
 31.290001,
 30.4,
 30.66,
 31.23,
 30.99,
 31.49,
 31.27,
 31.51,
 32.700001,
 34.25,
 35.959998999999996,
 33.349998,
 32.150002,
 32.27,
 31.790001,
 30.66,
 29.84,
 28.950001,
 28.129998999999998,
 29.51,
 27.35,
 27.42,
 26.25,
 26.1,
 27.27,
 28.27,
 30.25,
 29.09,
 29.41,
 29.940001000000002,
 31.17,
 29.42,
 29.4,
 30.299999,
 30.01,
 29.51,
 29.110001,
 29.950001,
 30.73,
 29.5,
 28.32,
 28.690001000000002,
 28.41,
 28.41,
 28.52,
 28.139999,
 27.940001000000002,
 28.549999,
 29.35,
 27.370001000000002,
 27.799999,
 28.280001000000002,
 29.48,
 30.389999,
 32.540001000000004,
 31.34,
 31.049999,
 30.9,
 30.02,
 30.66,
 27.66,
 27.540001,
 28.49,
 29.280001000000002,
 29.16,
 29.799999,
 29.299999,
 29.4,
 28.889999,
 29.25,
 28.370001000000002,
 28.4,
 28.32,
 27.639999,
 27.33,
 28.059998999999998,
 28.82,
 28.040001,
 27.74,
 27.85,
 28.389999,
 27.42,
 27.52,
 27.379998999999998,
 28.129998999999998,
 29.25,
 28.92,
 31.5,
 31.15,
 31.540001,
 31.309998999999998,
 30.32,
 31.07,
 31.610001,
 31.379998999999998,
 30.82,
 31.84,
 32.919998,
 33.0,
 32.470001,
 32.130001,
 32.27,
 32.150002,
 33.23,
 33.689999,
 33.82,
 34.619999,
 33.900002,
 33.709998999999996,
 33.900002,
 34.169998,
 34.57,
 35.279999,
 35.259997999999996,
 33.610001000000004,
 33.810001,
 34.400002,
 34.59,
 34.610001000000004,
 34.43,
 34.0,
 34.279999,
 33.59,
 33.689999,
 33.220001,
 33.869999,
 35.360001000000004,
 34.77,
 34.400002,
 34.34,
 33.68,
 33.639998999999996,
 33.529999,
 32.91,
 33.259997999999996,
 33.900002,
 34.099998,
 34.380001,
 34.52,
 35.189999,
 36.0,
 36.990002000000004,
 36.98,
 38.029999,
 37.950001,
 37.52,
 37.509997999999996,
 38.299999,
 37.740002000000004,
 38.130001,
 39.169998,
 39.48,
 39.240002000000004,
 38.419998,
 37.889998999999996,
 38.450001,
 38.27,
 37.040001000000004,
 39.279999,
 38.540001000000004,
 35.16,
 36.110001000000004,
 34.380001,
 34.43,
 35.099998,
 34.830002,
 34.650002,
 35.580002,
 36.650002,
 37.689999,
 38.23,
 38.470001,
 39.099998,
 39.119999,
 38.98,
 36.849998,
 35.290001000000004,
 35.150002,
 35.080002,
 35.950001,
 36.009997999999996,
 36.619999,
 37.529999,
 37.860001000000004,
 38.16,
 37.889998999999996,
 43.93,
 44.34,
 41.099998,
 42.009997999999996,
 41.369999,
 41.830002,
 40.5,
 41.860001000000004,
 43.59,
 43.75,
 43.299999,
 45.59,
 45.450001,
 46.970001,
 47.830002,
 50.189999,
 51.009997999999996,
 50.43,
 52.0,
 51.200001,
 54.939999,
 53.990002000000004,
 53.279999,
 54.110001000000004,
 54.549999,
 59.5,
 55.509997999999996,
 55.790001000000004,
 69.400002,
 76.760002,
 87.800003,
 83.239998,
 84.839996,
 92.25,
 91.5,
 89.940002,
 87.589996,
 87.239998,
 92.730003,
 97.08000200000001,
 110.33000200000001,
 104.629997,
 104.949997,
 97.760002,
 92.589996,
 94.839996,
 95.370003,
 97.349998,
 102.040001,
 100.050003,
 94.470001,
 97.730003,
 98.18,
 100.300003,
 102.199997,
 103.389999,
 104.68,
 100.650002,
 99.550003,
 101.489998,
 102.400002,
 105.720001,
 109.25,
 107.360001,
 117.18,
 117.82,
 115.239998,
 120.089996,
 121.610001,
 123.449997,
 122.269997,
 125.610001,
 129.899994,
 127.260002,
 109.050003,
 120.25,
 119.029999,
 119.68,
 122.43,
 122.739998,
 121.699997,
 124.07,
 129.389999,
 134.619995,
 131.740005,
 134.279999,
 135.550003,
 138.0,
 144.679993,
 142.149994,
 134.229996,
 153.479996,
 153.0,
 147.380005,
 145.429993,
 139.360001,
 139.669998,
 142.0,
 144.899994,
 149.580002,
 147.860001,
 157.100006,
 161.83999599999999,
 164.220001,
 167.009995,
 166.449997,
 166.059998,
 169.0,
 168.940002,
 170.619995,
 169.929993,
 166.970001,
 160.699997,
 166.369995,
 163.520004,
 164.929993,
 165.53999299999998,
 166.580002,
 166.229996,
 166.220001,
 177.919998,
 183.389999,
 181.110001,
 182.330002,
 185.240005,
 188.639999,
 190.899994,
 193.369995,
 193.0,
 180.949997,
 173.309998,
 180.979996,
 183.070007,
 174.729996,
 168.779999,
 172.929993,
 178.699997,
 179.720001,
 183.940002,
 183.559998,
 182.800003,
 183.399994,
 172.600006,
 171.53999299999998,
 164.5,
 173.149994,
 169.66000400000001,
 162.860001,
 164.470001,
 159.220001,
 159.940002,
 162.169998,
 175.199997,
 176.809998,
 151.16000400000001,
 139.770004,
 137.949997,
 144.699997,
 137.800003,
 138.699997,
 137.600006,
 135.449997,
 121.58000200000001,
 126.089996,
 121.110001,
 122.099998,
 121.379997,
 120.839996,
 120.5,
 126.940002,
 127.279999,
 124.16999799999999,
 144.699997,
 138.949997,
 140.479996,
 137.360001,
 141.600006,
 142.190002,
 139.649994,
 147.470001,
 147.649994,
 147.940002,
 152.46000700000002,
 147.979996,
 140.720001,
 143.240005,
 143.550003,
 151.41000400000001,
 155.5,
 151.119995,
 152.440002,
 150.429993,
 150.100006,
 149.559998,
 147.0,
 149.360001,
 151.279999,
 147.529999,
 145.720001,
 139.33999599999999,
 161.270004,
 164.130005,
 170.970001,
 170.009995,
 176.679993,
 178.559998,
 181.5,
 174.600006,
 169.619995,
 178.380005,
 175.229996,
 182.83999599999999,
 181.41000400000001,
 177.110001,
 178.729996,
 174.419998,
 178.380005,
 186.529999,
 196.559998,
 196.619995,
 195.320007,
 199.630005,
 198.229996,
 203.699997,
 193.639999,
 209.97000099999997,
 209.600006,
 217.649994,
 248.0,
 253.0,
 252.539993,
 244.809998,
 250.559998,
 254.83999599999999,
 252.66000400000001,
 252.940002,
 246.210007,
 238.83999599999999,
 234.41000400000001,
 241.49000499999997,
 237.789993,
 230.97000099999997,
 233.979996,
 240.039993,
 235.83999599999999,
 234.91000400000001,
 228.88999900000002,
 220.169998,
 220.440002,
 212.960007,
 207.320007,
 212.36999500000002,
 208.449997,
 216.97000099999997,
 230.289993,
 225.399994,
 212.229996,
 207.520004,
 215.460007,
 216.92999300000002,
 204.190002,
 203.779999,
 198.08999599999999,
 193.91000400000001,
 199.110001,
 198.119995,
 204.380005,
 218.63999900000002,
 207.990005,
 207.860001,
 199.850006,
 198.509995,
 206.919998,
 207.889999,
 207.729996,
 210.91000400000001,
 216.61000099999998,
 207.279999,
 201.350006,
 178.58999599999999,
 182.259995,
 184.669998,
 190.16000400000001,
 190.619995,
 188.58999599999999,
 191.559998,
 196.08999599999999,
 195.300003,
 199.449997,
 204.880005,
 207.300003,
 211.559998,
 210.24000499999997,
 210.24000499999997,
 207.770004,
 204.699997,
 204.940002,
 203.990005,
 206.899994,
 208.169998,
 205.309998,
 202.300003,
 204.470001,
 203.520004,
 206.419998,
 224.61000099999998,
 231.669998,
 227.11999500000002,
 227.789993,
 229.58999599999999,
 237.22000099999997,
 232.5,
 236.88999900000002,
 235.600006,
 239.059998,
 240.059998,
 239.72000099999997,
 229.42999300000002,
 229.25,
 222.66000400000001,
 219.07000699999998,
 223.059998,
 219.460007,
 218.13000499999998,
 226.69999700000002,
 219.580002,
 217.16000400000001,
 215.399994,
 220.020004,
 220.539993,
 219.580002,
 222.49000499999997,
 223.539993,
 223.57000699999998,
 224.82000699999998,
 225.00999500000003,
 228.919998,
 223.30000299999998,
 233.270004,
 238.520004,
 238.49000499999997,
 248.92999300000002,
 252.38999900000002,
 248.13000499999998,
 259.320007,
 259.959991,
 260.309998,
 261.380005,
 262.01001,
 259.940002,
 256.76001,
 255.710007,
 254.33999599999999,
 256.77999900000003,
 262.549988,
 261.73999,
 263.25,
 263.859985,
 269.700012,
 284.119995,
 281.190002,
 286.040009,
 277.390015,
 282.109985,
 278.480011,
 281.100006,
 280.309998,
 279.200012,
 253.86000099999998,
 260.73999,
 261.380005,
 263.820007,
 259.320007,
 250.02999900000003,
 250.41000400000001,
 252.13999900000002,
 246.94999700000002,
 246.600006,
 245.25999500000003,
 242.67999300000002,
 240.24000499999997,
 251.419998,
 255.210007,
 260.619995,
 259.570007,
 259.27999900000003,
 257.01001,
 236.91000400000001,
 224.58999599999999,
 227.059998,
 229.69999700000002,
 226.350006,
 227.479996,
 230.47000099999997,
 235.33999599999999,
 231.100006,
 235.289993,
 235.24000499999997,
 221.669998,
 242.770004,
 238.100006,
 238.66000400000001,
 241.69999700000002,
 242.58999599999999,
 238.92999300000002,
 230.97000099999997,
 241.22000099999997,
 240.19999700000002,
 241.92999300000002,
 251.080002,
 249.100006,
 251.69999700000002,
 258.679993,
 253.979996,
 257.700012,
 247.74000499999997,
 248.710007,
 242.77999900000003,
 246.72000099999997,
 248.08999599999999,
 248.440002,
 244.520004,
 231.63999900000002,
 231.42999300000002,
 229.30000299999998,
 228.27999900000003,
 223.710007,
 214.36000099999998,
 216.88999900000002,
 209.83999599999999,
 208.880005,
 207.0,
 204.03999299999998,
 197.809998,
 205.820007,
 218.25999500000003,
 219.289993,
 222.600006,
 220.97000099999997,
 222.25999500000003,
 227.82000699999998,
 225.710007,
 222.229996,
 222.41000400000001,
 219.309998,
 210.08999599999999,
 211.27999900000003,
 210.94999700000002,
 210.61999500000002,
 206.66000400000001,
 202.21000700000002,
 204.25,
 192.690002,
 191.869995,
 193.070007,
 191.929993,
 196.570007,
 201.619995,
 201.28999299999998,
 206.550003,
 205.979996,
 199.369995,
 205.199997,
 203.600006,
 210.940002,
 218.36000099999998,
 218.55000299999998,
 220.99000499999997,
 217.36000099999998,
 217.479996,
 216.289993,
 212.80000299999998,
 202.880005,
 203.770004,
 204.350006,
 204.46000700000002,
 211.710007,
 217.11000099999998,
 207.33999599999999,
 204.110001,
 203.759995,
 207.190002,
 203.33999599999999,
 197.330002,
 199.559998,
 202.440002,
 200.630005,
 193.880005,
 190.880005,
 190.320007,
 193.740005,
 191.070007,
 188.679993,
 195.699997,
 194.729996,
 200.71000700000002,
 195.649994,
 198.080002,
 199.630005,
 201.720001,
 194.300003,
 190.41000400000001,
 185.0,
 190.570007,
 188.770004,
 187.58999599999999,
 191.0,
 203.100006,
 203.25,
 207.669998,
 210.08999599999999,
 210.899994,
 209.77999900000003,
 207.46000700000002,
 207.830002,
 206.699997,
 206.78999299999998,
 205.270004,
 209.41000400000001,
 219.440002,
 218.600006,
 218.42999300000002,
 231.55000299999998,
 230.479996,
 232.44999700000002,
 226.05000299999998,
 226.02999900000003,
 230.50999500000003,
 232.94999700000002,
 230.42999300000002,
 236.80000299999998,
 236.61000099999998,
 239.49000499999997,
 244.74000499999997,
 243.17999300000002,
 244.100006,
 248.83999599999999,
 248.75,
 247.13999900000002,
 244.350006,
 245.61999500000002,
 247.729996,
 247.460007,
 247.42999300000002,
 251.44999700000002,
 250.80000299999998,
 249.44999700000002,
 248.350006,
 248.99000499999997,
 245.919998,
 249.13999900000002,
 256.290009,
 256.0,
 250.69999700000002,
 251.41000400000001,
 250.690002,
 250.38000499999998,
 253.11999500000002,
 260.410004,
 261.890015,
 262.51001,
 259.790009,
 267.670013,
 265.170013,
 268.790009,
 267.089996,
 262.019989,
 268.26001,
 269.149994,
 280.019989,
 279.72000099999997,
 267.880005,
 254.960007,
 257.920013,
 259.149994,
 262.160004,
 265.649994,
 263.140015,
 266.679993,
 274.660004,
 282.26001,
 266.769989,
 267.869995,
 267.200012,
 265.410004,
 253.00999500000003,
 264.820007,
 263.820007,
 266.790009,
 266.149994,
 259.98999,
 266.27999900000003,
 270.130005,
 246.13000499999998,
 242.50999500000003,
 241.13999900000002,
 237.36999500000002,
 238.169998,
 242.50999500000003,
 243.149994,
 254.99000499999997,
 260.72000099999997,
 255.25,
 242.17999300000002,
 230.770004,
 218.86999500000002,
 220.02999900000003,
 224.83999599999999,
 242.99000499999997,
 248.479996,
 249.059998,
 238.63000499999998,
 247.690002,
 245.57000699999998,
 241.92999300000002,
 248.169998,
 248.91000400000001,
 248.479996,
 250.24000499999997,
 253.190002,
 253.57000699999998,
 262.25,
 262.070007,
 260.619995,
 264.200012,
 260.940002,
 261.059998,
 263.119995,
 256.910004,
 248.42999300000002,
 246.649994,
 248.399994,
 239.88000499999998,
 247.57000699999998,
 246.149994,
 241.460007,
 231.960007,
 226.72000099999997,
 220.690002,
 215.580002,
 219.25,
 216.88000499999998,
 221.309998,
 227.00999500000003,
 228.100006,
 213.02999900000003,
 210.08999599999999,
 211.72000099999997,
 209.08999599999999,
 215.25999500000003,
 210.350006,
 212.960007,
 211.63000499999998,
 206.929993,
 213.789993,
 208.350006,
 231.63000499999998,
 231.770004,
 232.36000099999998,
 225.330002,
 216.5,
 219.080002,
 212.940002,
 207.190002,
 214.309998,
 214.0,
 221.07000699999998,
 221.80000299999998,
 220.00999500000003,
 217.75,
 218.25,
 229.63999900000002,
 231.61000099999998,
 230.25999500000003,
 237.190002,
 231.99000499999997,
 232.710007,
 230.38000499999998,
 231.13000499999998,
 226.72000099999997,
 224.520004,
 227.07000699999998,
 217.020004,
 218.580002,
 221.08999599999999,
 234.50999500000003,
 233.38999900000002,
 230.460007,
 232.559998,
 229.94999700000002,
 ...]

In [25]:
gs


Out[25]:
Open High Low Close Volume Adj Close
Date
2012-01-03 652.939982 668.150037 652.369996 665.409982 7345600 333.038029
2012-01-04 665.029992 670.249986 660.620038 668.280034 5722200 334.474492
2012-01-05 662.130001 663.970017 656.230023 659.010017 6559200 329.834843
2012-01-06 659.150013 659.999992 649.789998 650.019992 5380400 325.335331
2012-01-09 646.500017 647.000005 621.230024 622.459994 11633500 311.541538
2012-01-10 629.749999 633.800022 616.910007 623.140038 8782400 311.881901
2012-01-11 623.500029 629.390008 621.120026 625.960030 4795200 313.293308
2012-01-12 631.220024 632.889983 626.500017 629.640002 3746600 315.135136
2012-01-13 626.260023 626.950006 621.060028 624.989993 4609900 312.807804
2012-01-17 631.980005 631.980005 625.680037 628.580027 3814700 314.604618
2012-01-18 626.630014 634.000017 622.120002 632.909983 5517800 316.771763
2012-01-19 640.990029 640.990029 631.460018 639.570003 12597900 320.105107
2012-01-20 590.529980 591.000030 581.700013 585.990030 21131400 293.288303
2012-01-23 586.000030 588.660026 583.159977 585.519981 6818900 293.053043
2012-01-24 586.320022 587.679989 577.999981 580.930032 6105400 290.755772
2012-01-25 577.509993 578.710025 566.380021 569.490006 9965400 285.030033
2012-01-26 571.980006 574.480006 564.550004 568.099979 6445900 284.334324
2012-01-27 570.780035 580.319986 569.330010 579.979994 7227700 290.280277
2012-01-30 578.049980 579.999993 573.400032 577.689989 4656300 289.134128
2012-01-31 582.999981 584.000018 575.149990 580.109991 4280500 290.345341
2012-02-01 584.939995 585.499981 579.140014 580.830034 4636700 290.705723
2012-02-02 584.869996 586.410020 582.080004 585.109991 4824500 292.847843
2012-02-03 590.660038 597.070004 588.049980 596.330022 6330600 298.463474
2012-02-06 595.009993 610.830034 594.010017 609.090015 7351800 304.849857
2012-02-07 607.150002 609.390008 603.760023 606.770011 4180000 303.688694
2012-02-08 608.640026 611.350021 604.739999 609.849997 3669100 305.230229
2012-02-09 612.020005 614.500005 609.000017 611.460018 4524800 306.036045
2012-02-10 607.879984 608.129978 604.000017 605.910032 4645700 303.258274
2012-02-13 610.499981 613.840021 610.019992 612.200000 3628900 306.406407
2012-02-14 611.540016 612.000005 604.759999 609.759999 3603700 305.185185
... ... ... ... ... ... ...
2016-03-30 768.210022 777.309998 767.580017 768.340027 2017200 768.340027
2016-03-31 768.340027 769.080017 758.250000 762.900024 1623800 762.900024
2016-04-01 757.159973 770.039978 755.200012 769.669983 1581200 769.669983
2016-04-04 769.510010 772.440002 761.789978 765.119995 1346200 765.119995
2016-04-05 758.130005 762.869995 755.599976 758.570007 1222100 758.570007
2016-04-06 757.840027 768.419983 756.299988 768.070007 1257100 768.070007
2016-04-07 765.320007 769.359985 757.500000 760.119995 1254000 760.119995
2016-04-08 765.869995 767.130005 755.770020 759.469971 1171700 759.469971
2016-04-11 765.450012 767.219971 757.340027 757.539978 1584000 757.539978
2016-04-12 758.429993 764.919983 751.570007 764.320007 1366600 764.320007
2016-04-13 770.309998 775.750000 764.590027 771.909973 1769000 771.909973
2016-04-14 775.359985 779.609985 773.219971 775.390015 1348000 775.390015
2016-04-15 775.500000 780.929993 774.929993 780.000000 1555900 780.000000
2016-04-18 780.190002 788.549988 777.609985 787.679993 1669700 787.679993
2016-04-19 790.500000 790.950012 770.270020 776.250000 2191400 776.250000
2016-04-20 779.159973 779.659973 771.270020 774.919983 1706200 774.919983
2016-04-21 777.309998 781.679993 771.549988 780.000000 3326100 780.000000
2016-04-22 743.909973 753.919983 730.369995 737.770020 6978500 737.770020
2016-04-25 735.349976 744.880005 735.099976 742.210022 2469200 742.210022
2016-04-26 744.419983 745.590027 720.320007 725.369995 2754300 725.369995
2016-04-27 725.320007 727.150024 709.080017 721.460022 3289500 721.460022
2016-04-28 723.289978 729.260010 703.200012 705.059998 3114200 705.059998
2016-04-29 704.119995 712.109985 703.780029 707.880005 2906400 707.880005
2016-05-02 711.919983 715.409973 706.359985 714.409973 1672300 714.409973
2016-05-03 712.500000 713.369995 707.330017 708.440002 1922800 708.440002
2016-05-04 706.770020 715.049988 704.049988 711.369995 1610200 711.369995
2016-05-05 715.000000 717.549988 709.450012 714.710022 1479800 714.710022
2016-05-06 712.200012 725.989990 711.950012 725.179993 1982500 725.179993
2016-05-09 726.700012 734.289978 723.500000 729.130005 1898900 729.130005
2016-05-10 734.960022 740.000000 731.609985 739.380005 1627900 739.380005

1095 rows × 6 columns


In [36]:
'day'+',day'.join([`num+1` for num in xrange(maxSeqLen)])


Out[36]:
'day1,day2,day3,day4,day5,day6,day7,day8,day9,day10,day11,day12,day13,day14,day15,day16,day17,day18,day19,day20,day21,day22,day23,day24,day25'

In [30]:
%alias_magic --line whereami pwd


Created `%whereami` as an alias for `%pwd`.

In [32]:
%pwd


Out[32]:
u'D:\\Work\\data\\stockprices'

In [ ]: