In [1]:
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
# import matplotlib.finance as mf
from matplotlib.widgets import MultiCursor
import statsmodels.tsa.stattools as stt
# import scipy.signal as sgn
import statsmodels.api as sm
# from statsmodels.sandbox.regression.predstd import wls_prediction_std
# from matplotlib.mlab import PCA

In [2]:
%matplotlib inline

In [3]:
# Style. 1
sns.set_context('paper')
sns.set_style("darkgrid")

In [4]:
# Style. 2
sns.set_context('paper')
sns.set_style("dark", 
    rc={'axes.facecolor': 'black', 
    'grid.color': 'red', 
    'grid.linestyle': '--', 
    'figure.facecolor': 'grey'})

In [5]:
hft = pd.read_hdf('/home/bingnan/HFT_SR_RM_MA_TA.hdf')


/usr/lib/python2.7/dist-packages/tables/leaf.py:392: PerformanceWarning: The Leaf ``/HFT/block0_values`` is exceeding the maximum recommended rowsize (104857600 bytes);
be ready to see PyTables asking for *lots* of memory and possibly slow
I/O.  You may want to reduce the rowsize by trimming the value of
dimensions that are orthogonal (and preferably close) to the *main*
dimension of this leave.  Alternatively, in case you have specified a
very small/large chunksize, you may want to increase/decrease it.
  PerformanceWarning)

In [6]:
ta = hft.minor_xs('TA0001').copy()

In [7]:
#------------------------------------------------
'''Some time length'''
night_len = int(4*3600*2.5)
mor_len = int(4*3600*2.25)
aftn_len = int(4*3600*1.5)
day_len = night_len + mor_len + aftn_len + 4

In [26]:
ta.ix[:, ['bidPrc_0', 'bidPrc_1', 'bidPrc_2', 'askPrc_3', 'bidPrc_4', 
          'askPrc_1', 'askPrc_2', 'askPrc_3', 'askPrc_4']].any(axis=0) == 0


Out[26]:
bidPrc_0    False
bidPrc_1    False
bidPrc_2    False
askPrc_3    False
bidPrc_4    False
askPrc_1    False
askPrc_2    False
askPrc_3    False
askPrc_4    False
dtype: bool

In [8]:
#-----------------------------------------------
'''add columns'''
def AddCol(df):
    vol = df.ix[:, 'volume'].diff()
    # this addition is for the convenience of Log y scale plot
    # vol +=1
    vol = vol.rename('vol_diff')

    openint = df.ix[:, 'openInterest'].diff()
    # this addition is for the convenience of Log y scale plot
    # openint += 1
    openint = openint.rename('openInt_diff')

    mid = (df.ix[:, 'askPrc_0'] + df.ix[:, 'bidPrc_0']) / 2.
    mid = mid.rename('midPrc')
    ret = df.join([vol, openint, mid])
    return ret


# -------------------------------------------------
def ForwardDiff(df, n=1):
    '''
    The reverse of pandas' function 'DataFrame.diff()'
    '''
    ret = df.diff(periods=n)
    ret = ret.shift(periods= -1 * n)
    ret = ret.dropna()
    return ret

def CutHighVar(df, length=200):
    '''
    Purpose: Cut a small period after opening in the morning and at night.
    Because this time range, the var of price is high, which harmd our model.

    df: pd.DataFrame or pd.Series. With datetime index
    length: int. the length you want to cut, counted in ticks. Cannot be larger than 240
    '''
    ret = df
    bool_arr1 = np.logical_or(ret.index.hour == 21, ret.index.hour == 9)

    bool_arr = np.logical_and.reduce([bool_arr1, 
        ret.index.minute == 0, 
        ret.index.second <= int(length//4) - 1])

    ret = ret[np.logical_not(bool_arr)]
    return ret

def CutTail(df, length=60):
    '''
    Purpose: Cut a small period before market close.

    df: pd.DataFrame or pd.Series. With datetime index
    length: int. the length you want to cut, counted in ticks. Cannot be larger than 240
    '''
    ret = df
    last_boolean1 = np.logical_and.reduce(
                                          [ret.index.hour == 14, 
                                           ret.index.minute == 59, 
                                           ret.index.second >= 60 - int(length//4)])  
    # this is the last tick
    last_boolean2 = ret.index.hour == 15
    ret = ret[np.logical_not(np.logical_or(last_boolean1, last_boolean2))]
    return ret

def DayChangeNum(ser, distance=7):
    '''
    ser is price move series after process.
    distance counting in hours
    '''
    h = ser.index.hour
    h_diff = np.diff(h)
    h_diff = np.insert(h_diff, 1, 0)
    ret = np.where(np.abs(h_diff) > distance)[0]
    return ret

def NormPriceMove(ser, daychgnum):
    ret = ser.copy()
    for i in range(len(daychgnum) - 1):
        mysamp = ret.iloc[daychgnum[i]: daychgnum[i+1]]
        #print mysamp
        mystd = mysamp.std()
        print mystd
        ret.iloc[daychgnum[i]: daychgnum[i+1]] /= mystd
    return ret

def CuthlLimit(df, how='all', depth=0):
    s1 = 'bidQty_' + str(depth)
    s2 = 'askQty_' + str(depth)
    if how == 'all':
        arr1 = df.ix[:, s1] == 0
        arr2 = df[s2] == 0
        bool_arr = np.logical_or(arr1, arr2)
        #bool_arr = np.logical_or(df[s1] == 0, df[s2] == 0)
    elif how == 'bid':
        bool_arr = (df[s1] == 0)
    elif how == 'ask':
        bool_arr = (df[s2] == 0)
    else:
        print 'ERROR!'
    return df[np.logical_not(bool_arr)]

def GiveMePM(df, n=44, lim=[0, 20], cutdepth=0, norm=False, high_var_length=200):
    '''
    Purpose: from original DataFrame calculate price move Series. Including CutTail and CutHighVar.
    df: the pinzhong DataFrame.
    n: forward_ticks
    lim: can be like (0, 20), counting in days, or an int array of index.
    norm: if True, normalize the price move using every day std.
    Return (last) price move series.
    '''
    global day_len
    samp = CuthlLimit(df, how='all', depth=cutdepth)
    if len(lim) == 2:
        samp = samp.ix[day_len*lim[0]: day_len*lim[1], 'midPrc']
    else:
        samp = samp.ix[lim, 'midPrc']
    #print samp.index[0], samp.index[-1]
    ret = ForwardDiff(samp, n)
    ret = CutTail(ret, n)
    ret = CutHighVar(ret, length=high_var_length)
    if norm:
        ret_daychangenum = DayChangeNum(ret)
        ret = NormPriceMove(ret, ret_daychangenum)
    return ret

In [9]:
ta.columns


Out[9]:
Index([u'AveragePrice', u'LifeHigh', u'LifeLow', u'TotalAskLot',
       u'TotalBidLot', u'askPrc_0', u'askPrc_1', u'askPrc_2', u'askPrc_3',
       u'askPrc_4', u'askQty_0', u'askQty_1', u'askQty_2', u'askQty_3',
       u'askQty_4', u'bidPrc_0', u'bidPrc_1', u'bidPrc_2', u'bidPrc_3',
       u'bidPrc_4', u'bidQty_0', u'bidQty_1', u'bidQty_2', u'bidQty_3',
       u'bidQty_4', u'close', u'high', u'highLimit', u'last', u'low',
       u'lowLimit', u'open', u'openInterest', u'prevClose',
       u'prevOpenInterest', u'prevSettle', u'settle', u'volume'],
      dtype='object')

In [10]:
ta = AddCol(ta)
#------------------------------------------------ '''training dataset and outsample dataset''' ta_in = ta.ix[: day_len*20, :] ta_out = ta.ix[day_len*20: day_len*25: , :]
forward_ticks = 45 ta_in_pm = ForwardDiff(ta_in.ix[:, 'last'], forward_ticks) ta_out_pm = ForwardDiff(ta_out.ix[:, 'last'], forward_ticks) ta_in_pm = CutTail(ta_in_pm, forward_ticks) ta_out_pm = CutTail(ta_out_pm, forward_ticks) ta_in_pm = CutHighVar(ta_in_pm) ta_out_pm = CutHighVar(ta_out_pm) # ta_in_daychangenum = DayChangeNum(ta_in_pm) # ta_out_daychangenum = DayChangeNum(ta_out_pm) # ta_in_pm_norm = NormPriceMove(ta_in_pm, ta_in_daychangenum) # ta_out_pm_norm = NormPriceMove(ta_out_pm, ta_out_daychangenum)

In [24]:
def myols(ser, pm, norm=False):
    '''
    ser is indicator Series
    pm is Price move Series
    sm is satatsmodel module
    this function also automatically align index of df and pm
    '''
    global sm
    ser = ser[pm.index]
    ser = ser.dropna()
    if norm:
        ser = (ser - ser.mean()) / ser.std()
    X = sm.add_constant(ser)
    Y = pm[X.index]
    #print Y[211000:211070]
    #print X[211000:211070]
    model = sm.OLS(Y, X)
    ret = model.fit()
    return ret

def Rsquare(y, yhat):
    ret = 1 - (y-yhat).var() / y.var()
    return ret
def Rsquare2(y, yhat):
    ret = 1 - ((y-yhat)**2).mean() / y.var()
    return ret
def PredictedRsquare(res, xnew, pm):
    '''
    pm: outsample price move Series
    xnew: indicator Series (or DataFrame)
    res: insample regression results (comes from statsmodel's model.fit() )
    '''
    # first we need to align xnew with outsample
    xnew = xnew[pm.index]
    xnew = xnew.dropna()
    y = pm[xnew.index]
    
    xnew = sm.add_constant(xnew)
    ynew = res.predict(xnew)
    rsq = Rsquare(y, ynew)
    return rsq
def PredictedRsquare2(res, xnew, pm):
    '''
    pm: outsample price move Series
    xnew: indicator Series (or DataFrame)
    res: insample regression results (comes from statsmodel's model.fit() )
    '''
    # first we need to align xnew with outsample
    xnew = xnew[pm.index]
    xnew = xnew.dropna()
    y = pm[xnew.index]
    
    xnew = sm.add_constant(xnew)
    ynew = res.predict(xnew)
    rsq = Rsquare2(y, ynew)
    return rsq

===========================================================================

Advanced Plot


In [189]:
%matplotlib auto


Using matplotlib backend: TkAgg

In [187]:
def prc_total(df, t1, t2, fs=(15,10)):
    fig = plt.figure(figsize=fs)
    ax1 = fig.add_subplot(311)
    
    ax1.plot(df.ix[t1: t2, 'last'], color='#f5f112', marker='*')
    ax1.plot(df.ix[t1: t2, 'askPrc_0'], color='lightgreen')
    ax1.plot(df.ix[t1: t2, 'bidPrc_0'], color='lightcoral')

    ax3 = fig.add_subplot(312, sharex=ax1)
    ax3.plot(df.ix[t1: t2, 'vol_diff'], color='white', lw=0.4, marker='*')
    
    ax4 = fig.add_subplot(313, sharex=ax1)
    ax4.plot(df.ix[t1: t2, 'openInt_diff'],
             color='red', marker='*')
    return fig

In [191]:
# --------------------------------------------
'''this is for macroly searching for patterns'''
t11, t22 = '2015-12-05 21:00:01', '2015-12-08 15:00:00'
# samp = ta_10day.ix[pm_index, :]
thefig = prc_total(ta, t11, t22, (15,10))
multi = MultiCursor(thefig.canvas, thefig.axes, color='c', lw=1)
thefig.show()

In [137]:
vwap_indicator = VWAPIndicator(ta, 50)

In [147]:
ta.ix[120:190, 'last']


Out[147]:
2015-11-19 21:00:30.000    1827.0
2015-11-19 21:00:30.250    1827.0
2015-11-19 21:00:30.500    1827.0
2015-11-19 21:00:30.750    1827.0
2015-11-19 21:00:31.000    1827.0
2015-11-19 21:00:31.250    1828.0
2015-11-19 21:00:31.500    1828.0
2015-11-19 21:00:31.750    1827.0
2015-11-19 21:00:32.000    1828.0
2015-11-19 21:00:32.250    1827.0
2015-11-19 21:00:32.500    1828.0
2015-11-19 21:00:32.750    1827.0
2015-11-19 21:00:33.000    1827.0
2015-11-19 21:00:33.250    1828.0
2015-11-19 21:00:33.500    1828.0
2015-11-19 21:00:33.750    1827.0
2015-11-19 21:00:34.000    1828.0
2015-11-19 21:00:34.250    1828.0
2015-11-19 21:00:34.500    1828.0
2015-11-19 21:00:34.750    1828.0
2015-11-19 21:00:35.000    1829.0
2015-11-19 21:00:35.250    1828.0
2015-11-19 21:00:35.500    1828.0
2015-11-19 21:00:35.750    1828.0
2015-11-19 21:00:36.000    1828.0
2015-11-19 21:00:36.250    1829.0
2015-11-19 21:00:36.500    1829.0
2015-11-19 21:00:36.750    1829.0
2015-11-19 21:00:37.000    1829.0
2015-11-19 21:00:37.250    1829.0
                            ...  
2015-11-19 21:00:40.000    1829.0
2015-11-19 21:00:40.250    1830.0
2015-11-19 21:00:40.500    1830.0
2015-11-19 21:00:40.750    1829.0
2015-11-19 21:00:41.000    1829.0
2015-11-19 21:00:41.250    1830.0
2015-11-19 21:00:41.500    1829.0
2015-11-19 21:00:41.750    1830.0
2015-11-19 21:00:42.000    1830.0
2015-11-19 21:00:42.250    1830.0
2015-11-19 21:00:42.500    1830.0
2015-11-19 21:00:42.750    1829.0
2015-11-19 21:00:43.000    1830.0
2015-11-19 21:00:43.250    1830.0
2015-11-19 21:00:43.500    1829.0
2015-11-19 21:00:43.750    1830.0
2015-11-19 21:00:44.000    1830.0
2015-11-19 21:00:44.250    1829.0
2015-11-19 21:00:44.500    1829.0
2015-11-19 21:00:44.750    1829.0
2015-11-19 21:00:45.000    1829.0
2015-11-19 21:00:45.250    1829.0
2015-11-19 21:00:45.500    1829.0
2015-11-19 21:00:45.750    1829.0
2015-11-19 21:00:46.000    1829.0
2015-11-19 21:00:46.250    1830.0
2015-11-19 21:00:46.500    1829.0
2015-11-19 21:00:46.750    1829.0
2015-11-19 21:00:47.000    1829.0
2015-11-19 21:00:47.250    1829.0
Name: last, dtype: float64

In [142]:
ta_in_pm


Out[142]:
2015-11-19 21:00:32.000    1.0
2015-11-19 21:00:32.250    2.0
2015-11-19 21:00:32.500    1.0
2015-11-19 21:00:32.750    2.0
2015-11-19 21:00:33.000    2.0
2015-11-19 21:00:33.250    1.0
2015-11-19 21:00:33.500    1.0
2015-11-19 21:00:33.750    3.0
2015-11-19 21:00:34.000    1.0
2015-11-19 21:00:34.250    1.0
2015-11-19 21:00:34.500    1.0
2015-11-19 21:00:34.750    1.0
2015-11-19 21:00:35.000    0.0
2015-11-19 21:00:35.250    1.0
2015-11-19 21:00:35.500    0.0
2015-11-19 21:00:35.750    0.0
2015-11-19 21:00:36.000    1.0
2015-11-19 21:00:36.250    0.0
2015-11-19 21:00:36.500    0.0
2015-11-19 21:00:36.750    0.0
2015-11-19 21:00:37.000    0.0
2015-11-19 21:00:37.250   -1.0
2015-11-19 21:00:37.500    1.0
2015-11-19 21:00:37.750    1.0
2015-11-19 21:00:38.000   -1.0
2015-11-19 21:00:38.250    0.0
2015-11-19 21:00:38.500    0.0
2015-11-19 21:00:38.750    0.0
2015-11-19 21:00:39.000   -1.0
2015-11-19 21:00:39.250    0.0
                          ... 
2015-12-17 14:59:39.500   -1.0
2015-12-17 14:59:39.750    0.0
2015-12-17 14:59:40.000   -1.0
2015-12-17 14:59:40.250    1.0
2015-12-17 14:59:40.500    0.0
2015-12-17 14:59:40.750    1.0
2015-12-17 14:59:41.000    0.0
2015-12-17 14:59:41.250    0.0
2015-12-17 14:59:41.500    0.0
2015-12-17 14:59:41.750    0.0
2015-12-17 14:59:42.000    0.0
2015-12-17 14:59:42.250    0.0
2015-12-17 14:59:42.500   -1.0
2015-12-17 14:59:42.750   -1.0
2015-12-17 14:59:43.000    0.0
2015-12-17 14:59:43.250    1.0
2015-12-17 14:59:43.500   -1.0
2015-12-17 14:59:43.750    0.0
2015-12-17 14:59:44.000    0.0
2015-12-17 14:59:44.250    1.0
2015-12-17 14:59:44.500    0.0
2015-12-17 14:59:44.750   -1.0
2015-12-17 14:59:45.000    0.0
2015-12-17 14:59:45.250    0.0
2015-12-17 14:59:45.500    0.0
2015-12-17 14:59:45.750    0.0
2015-12-17 14:59:46.000    1.0
2015-12-17 14:59:46.250    0.0
2015-12-17 14:59:46.500    0.0
2015-12-17 14:59:46.750    1.0
Name: last, dtype: float64

In [12]:
def VWAPIndicator4(df, mywindow=50):
    '''
    use both openInt and volume to calculate 'real' new position.
    '''
    #TODO: ewm
    last = df.ix[:, 'midPrc']
    new_position = df.ix[:, ['vol_diff', 'openInt_diff']].sum(axis=1)
    new_position += .1
    last_multiply_newpos = last * new_position

    multiply_roll = last_multiply_newpos.rolling(window=mywindow)
    newpos_roll = new_position.rolling(window=mywindow)
    
    vwap = multiply_roll.sum()*1. / newpos_roll.sum()
    #print vwap[:15]
    #print last[:15]
    ret = vwap - last
    ret.name = 'vwap_indicator2'
    vwap.name = 'vwaPrc2'
    return vwap, ret

In [13]:
def VWAPIndicator3(df, mywindow=50):
    #TODO: ewm
    last = df.ix[:, 'midPrc']
    #print (last.isnull()).sum()
    vol = df.ix[:, 'vol_diff']
    vol += 1.
    #print (vol.isnull()).sum()
    last_multiply_vol = last * vol
    #print (last_multiply_vol.isnull()).sum()

    multiply_roll = last_multiply_vol.rolling(window=mywindow)
    vol_roll = vol.rolling(window=mywindow)
    
    vwap = multiply_roll.sum()*1. / vol_roll.sum()
    #print (vwap.isnull()).sum()
    #print vwap[:15]
    #print last[:15]
    ret = vwap - last
    ret.name = 'vwap_indicator'
    vwap.name = 'vwaPrc'
    return vwap, ret

TEST!!!


In [14]:
def GiveMeIndex(arri, arro):
    '''
    Generate integer index
    arr is a two dim ndarray, with each element being a time range(counting in days).
    '''
    global day_len
    index_in = list()
    for k in arri:
        index_in = index_in + list(range(day_len * k[0], day_len * k[1]))
    index_out = list()
    for k in arro:
        index_out = index_out + list(range(day_len * k[0], day_len * k[1]))
    return index_in, index_out

In [15]:
insample_index0, outsample_index0 = GiveMeIndex([[0,2], [4, 6], [8, 10], [14, 16], [18,20], [22, 24], [26,28]],
                                               [[2, 4], [6, 8], [12, 14], [16, 18], [20,22], [24, 26], [28,30]])
insample_index1, outsample_index1 = GiveMeIndex([[0, 20]], [[20, 25]])
insample_index2, outsample_index2 = GiveMeIndex([[5, 25]], [[0, 5]])
insample_index3, outsample_index3 = GiveMeIndex([[0, 5], [10, 25]], [[5, 10]])
insample_index4, outsample_index4 = GiveMeIndex([[0, 10], [15, 25]], [[10, 15]])
insample_index5, outsample_index5 = GiveMeIndex([[0, 13]], [[13, 25]])
insample_index6, outsample_index6 = GiveMeIndex([[0, 18]], [[18, 25]])
# different_io_index = ((insample_index0, outsample_index0), (insample_index1, outsample_index1), 
#                       (insample_index2, outsample_index2), (insample_index3, outsample_index3),
#                       (insample_index4, outsample_index4), (insample_index5, outsample_index5))
insample_index00, outsample_index00 = GiveMeIndex([[0, 20]],
                                               [[25, 30]])

In [26]:
#-------------------------------------------------------------------------------
'''
Automatically generate in and out sample data, then calculate Qty_indicator,
then regression under different parameters
'''
for mywind in [10, 30, 100, 240, 1000, 2400]:
    vwap, vwap_indicator = VWAPIndicator4(ta, mywind)
    #print pd.concat([ta[['last','vol_diff']],vwap,vwap_indicator],axis=1)
    for forward_ticks in range(44, 45, 1):
        ta_in_pm = GiveMePM(ta, n=forward_ticks, lim=insample_index1)
        #print pd.concat([ta_in_pm,ta['last']],axis=1).dropna()
        ta_out_pm = GiveMePM(ta, n=forward_ticks, lim=outsample_index1)
        #df = pd.concat([vwap_indicator, ta_in_pm],axis=1)
        #df.dropna(inplace=True)
        res = myols(vwap_indicator, ta_in_pm)
        print ('\n\n\n------------------------------X length: %d, Y length: %d ------------------------------' 
               %(mywind, forward_ticks))
        print ('In sample time range: %s to %s \nOut sample time range: %s to %s.\n' %(ta_in_pm.index[0], 
                                                                                       ta_in_pm.index[-1],
                                                                                       ta_out_pm.index[0],
                                                                                       ta_out_pm.index[-1]))
        print res.summary()
        #print ta_in_pm.describe()
        #print ta_out_pm.describe()
        print '\n[OutSample R_SQUARE: %f]' % PredictedRsquare(res, vwap_indicator, ta_out_pm)
        print '\n[OutSample R_SQUARE: %f]' % PredictedRsquare2(res, vwap_indicator, ta_out_pm)




------------------------------X length: 10, Y length: 44 ------------------------------
In sample time range: 2015-11-19 21:00:50 to 2015-12-17 21:15:53.250000 
Out sample time range: 2015-12-17 21:16:04.500000 to 2015-12-24 21:15:53.250000.

                            OLS Regression Results                            
==============================================================================
Dep. Variable:                 midPrc   R-squared:                       0.000
Model:                            OLS   Adj. R-squared:                  0.000
Method:                 Least Squares   F-statistic:                     3.764
Date:                Sun, 17 Jul 2016   Prob (F-statistic):             0.0524
Time:                        04:26:26   Log-Likelihood:            -3.1137e+06
No. Observations:             1790936   AIC:                         6.227e+06
Df Residuals:                 1790934   BIC:                         6.227e+06
Df Model:                           1                                         
===================================================================================
                      coef    std err          t      P>|t|      [95.0% Conf. Int.]
-----------------------------------------------------------------------------------
const               0.0037      0.001      3.634      0.000         0.002     0.006
vwap_indicator2     0.0002      0.000      1.940      0.052     -2.04e-06     0.000
==============================================================================
Omnibus:                   644865.163   Durbin-Watson:                   0.083
Prob(Omnibus):                  0.000   Jarque-Bera (JB):        134740837.563
Skew:                           0.553   Prob(JB):                         0.00
Kurtosis:                      45.478   Cond. No.                         10.0
==============================================================================

[OutSample R_SQUARE: 0.000012]

[OutSample R_SQUARE: -0.000010]



------------------------------X length: 30, Y length: 44 ------------------------------
In sample time range: 2015-11-19 21:00:50 to 2015-12-17 21:15:53.250000 
Out sample time range: 2015-12-17 21:16:04.500000 to 2015-12-24 21:15:53.250000.

                            OLS Regression Results                            
==============================================================================
Dep. Variable:                 midPrc   R-squared:                       0.000
Model:                            OLS   Adj. R-squared:                 -0.000
Method:                 Least Squares   F-statistic:                   0.08203
Date:                Sun, 17 Jul 2016   Prob (F-statistic):              0.775
Time:                        04:26:31   Log-Likelihood:            -3.1137e+06
No. Observations:             1790936   AIC:                         6.227e+06
Df Residuals:                 1790934   BIC:                         6.227e+06
Df Model:                           1                                         
===================================================================================
                      coef    std err          t      P>|t|      [95.0% Conf. Int.]
-----------------------------------------------------------------------------------
const               0.0037      0.001      3.624      0.000         0.002     0.006
vwap_indicator2  1.726e-05   6.03e-05      0.286      0.775        -0.000     0.000
==============================================================================
Omnibus:                   644857.802   Durbin-Watson:                   0.084
Prob(Omnibus):                  0.000   Jarque-Bera (JB):        134737775.005
Skew:                           0.553   Prob(JB):                         0.00
Kurtosis:                      45.478   Cond. No.                         17.1
==============================================================================

[OutSample R_SQUARE: 0.000002]

[OutSample R_SQUARE: -0.000020]



------------------------------X length: 100, Y length: 44 ------------------------------
In sample time range: 2015-11-19 21:00:50 to 2015-12-17 21:15:53.250000 
Out sample time range: 2015-12-17 21:16:04.500000 to 2015-12-24 21:15:53.250000.

                            OLS Regression Results                            
==============================================================================
Dep. Variable:                 midPrc   R-squared:                       0.000
Model:                            OLS   Adj. R-squared:                  0.000
Method:                 Least Squares   F-statistic:                     32.92
Date:                Sun, 17 Jul 2016   Prob (F-statistic):           9.62e-09
Time:                        04:26:36   Log-Likelihood:            -3.1137e+06
No. Observations:             1790936   AIC:                         6.227e+06
Df Residuals:                 1790934   BIC:                         6.227e+06
Df Model:                           1                                         
===================================================================================
                      coef    std err          t      P>|t|      [95.0% Conf. Int.]
-----------------------------------------------------------------------------------
const               0.0036      0.001      3.510      0.000         0.002     0.006
vwap_indicator2    -0.0002   4.17e-05     -5.737      0.000        -0.000    -0.000
==============================================================================
Omnibus:                   644789.252   Durbin-Watson:                   0.084
Prob(Omnibus):                  0.000   Jarque-Bera (JB):        134724711.407
Skew:                           0.553   Prob(JB):                         0.00
Kurtosis:                      45.476   Cond. No.                         24.7
==============================================================================

[OutSample R_SQUARE: -0.000047]

[OutSample R_SQUARE: -0.000070]



------------------------------X length: 240, Y length: 44 ------------------------------
In sample time range: 2015-11-19 21:00:50 to 2015-12-17 21:15:53.250000 
Out sample time range: 2015-12-17 21:16:04.500000 to 2015-12-24 21:15:53.250000.

                            OLS Regression Results                            
==============================================================================
Dep. Variable:                 midPrc   R-squared:                       0.000
Model:                            OLS   Adj. R-squared:                  0.000
Method:                 Least Squares   F-statistic:                     36.77
Date:                Sun, 17 Jul 2016   Prob (F-statistic):           1.33e-09
Time:                        04:26:41   Log-Likelihood:            -3.1133e+06
No. Observations:             1790896   AIC:                         6.227e+06
Df Residuals:                 1790894   BIC:                         6.227e+06
Df Model:                           1                                         
===================================================================================
                      coef    std err          t      P>|t|      [95.0% Conf. Int.]
-----------------------------------------------------------------------------------
const               0.0037      0.001      3.595      0.000         0.002     0.006
vwap_indicator2    -0.0002   3.44e-05     -6.064      0.000        -0.000    -0.000
==============================================================================
Omnibus:                   645479.661   Durbin-Watson:                   0.084
Prob(Omnibus):                  0.000   Jarque-Bera (JB):        134872204.819
Skew:                           0.555   Prob(JB):                         0.00
Kurtosis:                      45.499   Cond. No.                         29.9
==============================================================================

[OutSample R_SQUARE: -0.000047]

[OutSample R_SQUARE: -0.000069]



------------------------------X length: 1000, Y length: 44 ------------------------------
In sample time range: 2015-11-19 21:00:50 to 2015-12-17 21:15:53.250000 
Out sample time range: 2015-12-17 21:16:04.500000 to 2015-12-24 21:15:53.250000.

                            OLS Regression Results                            
==============================================================================
Dep. Variable:                 midPrc   R-squared:                       0.000
Model:                            OLS   Adj. R-squared:                  0.000
Method:                 Least Squares   F-statistic:                     68.01
Date:                Sun, 17 Jul 2016   Prob (F-statistic):           1.63e-16
Time:                        04:26:47   Log-Likelihood:            -3.1109e+06
No. Observations:             1790136   AIC:                         6.222e+06
Df Residuals:                 1790134   BIC:                         6.222e+06
Df Model:                           1                                         
===================================================================================
                      coef    std err          t      P>|t|      [95.0% Conf. Int.]
-----------------------------------------------------------------------------------
const               0.0037      0.001      3.597      0.000         0.002     0.006
vwap_indicator2    -0.0003   3.32e-05     -8.247      0.000        -0.000    -0.000
==============================================================================
Omnibus:                   646241.117   Durbin-Watson:                   0.084
Prob(Omnibus):                  0.000   Jarque-Bera (JB):        135452805.439
Skew:                           0.558   Prob(JB):                         0.00
Kurtosis:                      45.600   Cond. No.                         31.0
==============================================================================

[OutSample R_SQUARE: -0.000080]

[OutSample R_SQUARE: -0.000101]



------------------------------X length: 2400, Y length: 44 ------------------------------
In sample time range: 2015-11-19 21:00:50 to 2015-12-17 21:15:53.250000 
Out sample time range: 2015-12-17 21:16:04.500000 to 2015-12-24 21:15:53.250000.

                            OLS Regression Results                            
==============================================================================
Dep. Variable:                 midPrc   R-squared:                       0.000
Model:                            OLS   Adj. R-squared:                  0.000
Method:                 Least Squares   F-statistic:                     21.98
Date:                Sun, 17 Jul 2016   Prob (F-statistic):           2.76e-06
Time:                        04:26:52   Log-Likelihood:            -3.1083e+06
No. Observations:             1788736   AIC:                         6.217e+06
Df Residuals:                 1788734   BIC:                         6.217e+06
Df Model:                           1                                         
===================================================================================
                      coef    std err          t      P>|t|      [95.0% Conf. Int.]
-----------------------------------------------------------------------------------
const               0.0038      0.001      3.668      0.000         0.002     0.006
vwap_indicator2    -0.0002   3.52e-05     -4.688      0.000        -0.000 -9.61e-05
==============================================================================
Omnibus:                   646138.873   Durbin-Watson:                   0.084
Prob(Omnibus):                  0.000   Jarque-Bera (JB):        135685503.581
Skew:                           0.559   Prob(JB):                         0.00
Kurtosis:                      45.653   Cond. No.                         29.2
==============================================================================

[OutSample R_SQUARE: -0.000052]

[OutSample R_SQUARE: -0.000073]

In [66]:
TEMP1 = pd.concat([ta1,vwap_indicator,vwap],axis=1)

In [69]:
vwap.ix['2015-11-23 23:13:40': '2015-11-23 23:13:50']


Out[69]:
2015-11-23 23:13:40.000    4416.0
2015-11-23 23:13:40.250    4416.0
2015-11-23 23:13:40.500    4416.0
2015-11-23 23:13:40.750    4416.0
2015-11-23 23:13:41.000    4416.0
2015-11-23 23:13:41.250    4416.0
2015-11-23 23:13:41.500    4416.0
2015-11-23 23:13:41.750    4416.0
2015-11-23 23:13:42.000    4416.0
2015-11-23 23:13:42.250    4416.0
2015-11-23 23:13:42.500    4416.0
2015-11-23 23:13:42.750    4416.0
2015-11-23 23:13:43.000    4416.0
2015-11-23 23:13:43.250    4416.0
2015-11-23 23:13:43.500    4418.0
2015-11-23 23:13:43.750    4418.0
2015-11-23 23:13:44.000    4418.0
2015-11-23 23:13:44.250    4418.0
2015-11-23 23:13:44.500    4418.0
2015-11-23 23:13:44.750    4418.0
2015-11-23 23:13:45.000    4418.0
2015-11-23 23:13:45.250    4418.0
2015-11-23 23:13:45.500    4416.0
2015-11-23 23:13:45.750    4416.0
2015-11-23 23:13:46.000    4418.0
2015-11-23 23:13:46.250    4416.0
2015-11-23 23:13:46.500    4418.0
2015-11-23 23:13:46.750    4418.0
2015-11-23 23:13:47.000    4418.0
2015-11-23 23:13:47.250    4418.0
2015-11-23 23:13:47.500    4418.0
2015-11-23 23:13:47.750    4418.0
2015-11-23 23:13:48.000    4418.0
2015-11-23 23:13:48.250    4418.0
2015-11-23 23:13:48.500    4418.0
2015-11-23 23:13:48.750    4418.0
2015-11-23 23:13:49.000    4418.0
2015-11-23 23:13:49.250    4418.0
2015-11-23 23:13:49.500    4418.0
2015-11-23 23:13:49.750    4420.0
2015-11-23 23:13:50.000    4420.0
2015-11-23 23:13:50.250    4418.0
2015-11-23 23:13:50.500    4418.0
2015-11-23 23:13:50.750    4418.0
Name: vwaPrc, dtype: float64
Out[69]:
2015-11-23 23:13:40.000    4416.0
2015-11-23 23:13:40.250    4416.0
2015-11-23 23:13:40.500    4416.0
2015-11-23 23:13:40.750    4416.0
2015-11-23 23:13:41.000    4416.0
2015-11-23 23:13:41.250    4416.0
2015-11-23 23:13:41.500    4416.0
2015-11-23 23:13:41.750    4416.0
2015-11-23 23:13:42.000    4416.0
2015-11-23 23:13:42.250    4416.0
2015-11-23 23:13:42.500    4416.0
2015-11-23 23:13:42.750    4416.0
2015-11-23 23:13:43.000    4416.0
2015-11-23 23:13:43.250    4416.0
2015-11-23 23:13:43.500    4418.0
2015-11-23 23:13:43.750    4418.0
2015-11-23 23:13:44.000    4418.0
2015-11-23 23:13:44.250    4418.0
2015-11-23 23:13:44.500    4418.0
2015-11-23 23:13:44.750    4418.0
2015-11-23 23:13:45.000    4418.0
2015-11-23 23:13:45.250    4418.0
2015-11-23 23:13:45.500    4416.0
2015-11-23 23:13:45.750    4416.0
2015-11-23 23:13:46.000    4418.0
2015-11-23 23:13:46.250    4416.0
2015-11-23 23:13:46.500    4418.0
2015-11-23 23:13:46.750    4418.0
2015-11-23 23:13:47.000    4418.0
2015-11-23 23:13:47.250    4418.0
2015-11-23 23:13:47.500    4418.0
2015-11-23 23:13:47.750    4418.0
2015-11-23 23:13:48.000    4418.0
2015-11-23 23:13:48.250    4418.0
2015-11-23 23:13:48.500    4418.0
2015-11-23 23:13:48.750    4418.0
2015-11-23 23:13:49.000    4418.0
2015-11-23 23:13:49.250    4418.0
2015-11-23 23:13:49.500    4418.0
2015-11-23 23:13:49.750    4420.0
2015-11-23 23:13:50.000    4420.0
2015-11-23 23:13:50.250    4418.0
2015-11-23 23:13:50.500    4418.0
2015-11-23 23:13:50.750    4418.0
Name: vwaPrc, dtype: float64
Out[69]:
2015-11-23 23:13:40.000    4416.0
2015-11-23 23:13:40.250    4416.0
2015-11-23 23:13:40.500    4416.0
2015-11-23 23:13:40.750    4416.0
2015-11-23 23:13:41.000    4416.0
2015-11-23 23:13:41.250    4416.0
2015-11-23 23:13:41.500    4416.0
2015-11-23 23:13:41.750    4416.0
2015-11-23 23:13:42.000    4416.0
2015-11-23 23:13:42.250    4416.0
2015-11-23 23:13:42.500    4416.0
2015-11-23 23:13:42.750    4416.0
2015-11-23 23:13:43.000    4416.0
2015-11-23 23:13:43.250    4416.0
2015-11-23 23:13:43.500    4418.0
2015-11-23 23:13:43.750    4418.0
2015-11-23 23:13:44.000    4418.0
2015-11-23 23:13:44.250    4418.0
2015-11-23 23:13:44.500    4418.0
2015-11-23 23:13:44.750    4418.0
2015-11-23 23:13:45.000    4418.0
2015-11-23 23:13:45.250    4418.0
2015-11-23 23:13:45.500    4416.0
2015-11-23 23:13:45.750    4416.0
2015-11-23 23:13:46.000    4418.0
2015-11-23 23:13:46.250    4416.0
2015-11-23 23:13:46.500    4418.0
2015-11-23 23:13:46.750    4418.0
2015-11-23 23:13:47.000    4418.0
2015-11-23 23:13:47.250    4418.0
2015-11-23 23:13:47.500    4418.0
2015-11-23 23:13:47.750    4418.0
2015-11-23 23:13:48.000    4418.0
2015-11-23 23:13:48.250    4418.0
2015-11-23 23:13:48.500    4418.0
2015-11-23 23:13:48.750    4418.0
2015-11-23 23:13:49.000    4418.0
2015-11-23 23:13:49.250    4418.0
2015-11-23 23:13:49.500    4418.0
2015-11-23 23:13:49.750    4420.0
2015-11-23 23:13:50.000    4420.0
2015-11-23 23:13:50.250    4418.0
2015-11-23 23:13:50.500    4418.0
2015-11-23 23:13:50.750    4418.0
Name: vwaPrc, dtype: float64

In [71]:
TEMP1.ix['2015-11-23 23:13:40': '2015-11-23 23:13:50', ['last', 'volume', 'vol_diff', 'vwap', 'vwap_indicator']]


Out[71]:
last volume vol_diff vwap vwap_indicator
2015-11-23 23:13:40.000 4416.0 559906.0 4.0 NaN 0.0
2015-11-23 23:13:40.250 4416.0 559914.0 8.0 NaN 0.0
2015-11-23 23:13:40.500 4416.0 559914.0 0.0 NaN 0.0
2015-11-23 23:13:40.750 4416.0 559914.0 0.0 NaN 0.0
2015-11-23 23:13:41.000 4416.0 559914.0 0.0 NaN 0.0
2015-11-23 23:13:41.250 4416.0 559914.0 0.0 NaN 0.0
2015-11-23 23:13:41.500 4416.0 559914.0 0.0 NaN 0.0
2015-11-23 23:13:41.750 4416.0 559914.0 0.0 NaN 0.0
2015-11-23 23:13:42.000 4416.0 559914.0 0.0 NaN 0.0
2015-11-23 23:13:42.250 4416.0 559914.0 0.0 NaN 0.0
2015-11-23 23:13:42.500 4416.0 559916.0 2.0 NaN 0.0
2015-11-23 23:13:42.750 4416.0 559916.0 0.0 NaN 0.0
2015-11-23 23:13:43.000 4416.0 559916.0 0.0 NaN 0.0
2015-11-23 23:13:43.250 4416.0 559916.0 0.0 NaN 0.0
2015-11-23 23:13:43.500 4418.0 559918.0 2.0 NaN 0.0
2015-11-23 23:13:43.750 4418.0 559918.0 0.0 NaN 0.0
2015-11-23 23:13:44.000 4418.0 559924.0 6.0 NaN 0.0
2015-11-23 23:13:44.250 4418.0 559924.0 0.0 NaN 0.0
2015-11-23 23:13:44.500 4418.0 559924.0 0.0 NaN 0.0
2015-11-23 23:13:44.750 4418.0 559924.0 0.0 NaN 0.0
2015-11-23 23:13:45.000 4418.0 559924.0 0.0 NaN 0.0
2015-11-23 23:13:45.250 4418.0 559924.0 0.0 NaN 0.0
2015-11-23 23:13:45.500 4416.0 559934.0 10.0 NaN 0.0
2015-11-23 23:13:45.750 4416.0 559934.0 0.0 NaN 0.0
2015-11-23 23:13:46.000 4418.0 559940.0 6.0 NaN 0.0
2015-11-23 23:13:46.250 4416.0 559942.0 2.0 NaN 0.0
2015-11-23 23:13:46.500 4418.0 560542.0 600.0 NaN 0.0
2015-11-23 23:13:46.750 4418.0 560542.0 0.0 NaN 0.0
2015-11-23 23:13:47.000 4418.0 560542.0 0.0 NaN 0.0
2015-11-23 23:13:47.250 4418.0 560576.0 34.0 NaN 0.0
2015-11-23 23:13:47.500 4418.0 560594.0 18.0 NaN 0.0
2015-11-23 23:13:47.750 4418.0 560610.0 16.0 NaN 0.0
2015-11-23 23:13:48.000 4418.0 560610.0 0.0 NaN 0.0
2015-11-23 23:13:48.250 4418.0 560610.0 0.0 NaN 0.0
2015-11-23 23:13:48.500 4418.0 560610.0 0.0 NaN 0.0
2015-11-23 23:13:48.750 4418.0 560612.0 2.0 NaN 0.0
2015-11-23 23:13:49.000 4418.0 560612.0 0.0 NaN 0.0
2015-11-23 23:13:49.250 4418.0 560612.0 0.0 NaN 0.0
2015-11-23 23:13:49.500 4418.0 560612.0 0.0 NaN 0.0
2015-11-23 23:13:49.750 4420.0 560692.0 80.0 NaN 0.0
2015-11-23 23:13:50.000 4420.0 560736.0 44.0 NaN 0.0
2015-11-23 23:13:50.250 4418.0 560738.0 2.0 NaN 0.0
2015-11-23 23:13:50.500 4418.0 560738.0 0.0 NaN 0.0
2015-11-23 23:13:50.750 4418.0 560738.0 0.0 NaN 0.0

In [50]:
ta1.ix['2015-11-23 23:13:40': '2015-11-23 23:13:50', ['last', 'volume', 'vol_diff']]


Out[50]:
last volume vol_diff
2015-11-23 23:13:40.000 4416.0 559906.0 4.0
2015-11-23 23:13:40.250 4416.0 559914.0 8.0
2015-11-23 23:13:40.500 4416.0 559914.0 0.0
2015-11-23 23:13:40.750 4416.0 559914.0 0.0
2015-11-23 23:13:41.000 4416.0 559914.0 0.0
2015-11-23 23:13:41.250 4416.0 559914.0 0.0
2015-11-23 23:13:41.500 4416.0 559914.0 0.0
2015-11-23 23:13:41.750 4416.0 559914.0 0.0
2015-11-23 23:13:42.000 4416.0 559914.0 0.0
2015-11-23 23:13:42.250 4416.0 559914.0 0.0
2015-11-23 23:13:42.500 4416.0 559916.0 2.0
2015-11-23 23:13:42.750 4416.0 559916.0 0.0
2015-11-23 23:13:43.000 4416.0 559916.0 0.0
2015-11-23 23:13:43.250 4416.0 559916.0 0.0
2015-11-23 23:13:43.500 4418.0 559918.0 2.0
2015-11-23 23:13:43.750 4418.0 559918.0 0.0
2015-11-23 23:13:44.000 4418.0 559924.0 6.0
2015-11-23 23:13:44.250 4418.0 559924.0 0.0
2015-11-23 23:13:44.500 4418.0 559924.0 0.0
2015-11-23 23:13:44.750 4418.0 559924.0 0.0
2015-11-23 23:13:45.000 4418.0 559924.0 0.0
2015-11-23 23:13:45.250 4418.0 559924.0 0.0
2015-11-23 23:13:45.500 4416.0 559934.0 10.0
2015-11-23 23:13:45.750 4416.0 559934.0 0.0
2015-11-23 23:13:46.000 4418.0 559940.0 6.0
2015-11-23 23:13:46.250 4416.0 559942.0 2.0
2015-11-23 23:13:46.500 4418.0 560542.0 600.0
2015-11-23 23:13:46.750 4418.0 560542.0 0.0
2015-11-23 23:13:47.000 4418.0 560542.0 0.0
2015-11-23 23:13:47.250 4418.0 560576.0 34.0
2015-11-23 23:13:47.500 4418.0 560594.0 18.0
2015-11-23 23:13:47.750 4418.0 560610.0 16.0
2015-11-23 23:13:48.000 4418.0 560610.0 0.0
2015-11-23 23:13:48.250 4418.0 560610.0 0.0
2015-11-23 23:13:48.500 4418.0 560610.0 0.0
2015-11-23 23:13:48.750 4418.0 560612.0 2.0
2015-11-23 23:13:49.000 4418.0 560612.0 0.0
2015-11-23 23:13:49.250 4418.0 560612.0 0.0
2015-11-23 23:13:49.500 4418.0 560612.0 0.0
2015-11-23 23:13:49.750 4420.0 560692.0 80.0
2015-11-23 23:13:50.000 4420.0 560736.0 44.0
2015-11-23 23:13:50.250 4418.0 560738.0 2.0
2015-11-23 23:13:50.500 4418.0 560738.0 0.0
2015-11-23 23:13:50.750 4418.0 560738.0 0.0

In [27]:
ta1.ix['2015-11-23 23:13:50': '2015-11-23 23:14:04', ['last', 'volume', 'vol_diff']]


Out[27]:
last volume vol_diff
2015-11-23 23:13:50.000 4420.0 560736.0 44.0
2015-11-23 23:13:50.250 4418.0 560738.0 2.0
2015-11-23 23:13:50.500 4418.0 560738.0 0.0
2015-11-23 23:13:50.750 4418.0 560738.0 0.0
2015-11-23 23:13:51.000 4418.0 560740.0 2.0
2015-11-23 23:13:51.250 4418.0 560740.0 0.0
2015-11-23 23:13:51.500 4420.0 560840.0 100.0
2015-11-23 23:13:51.750 4420.0 560840.0 0.0
2015-11-23 23:13:52.000 4420.0 560850.0 10.0
2015-11-23 23:13:52.250 4420.0 560850.0 0.0
2015-11-23 23:13:52.500 4418.0 560860.0 10.0
2015-11-23 23:13:52.750 4418.0 560860.0 0.0
2015-11-23 23:13:53.000 4418.0 560860.0 0.0
2015-11-23 23:13:53.250 4418.0 560860.0 0.0
2015-11-23 23:13:53.500 4418.0 560860.0 0.0
2015-11-23 23:13:53.750 4418.0 560860.0 0.0
2015-11-23 23:13:54.000 4420.0 560880.0 20.0
2015-11-23 23:13:54.250 4420.0 560880.0 0.0
2015-11-23 23:13:54.500 4418.0 560890.0 10.0
2015-11-23 23:13:54.750 4418.0 560890.0 0.0
2015-11-23 23:13:55.000 4420.0 560994.0 104.0
2015-11-23 23:13:55.250 4420.0 560994.0 0.0
2015-11-23 23:13:55.500 4420.0 560994.0 0.0
2015-11-23 23:13:55.750 4420.0 560994.0 0.0
2015-11-23 23:13:56.000 4420.0 561196.0 202.0
2015-11-23 23:13:56.250 4420.0 561196.0 0.0
2015-11-23 23:13:56.500 4420.0 561278.0 82.0
2015-11-23 23:13:56.750 4420.0 561284.0 6.0
2015-11-23 23:13:57.000 4420.0 561288.0 4.0
2015-11-23 23:13:57.250 4420.0 561288.0 0.0
2015-11-23 23:13:57.500 4420.0 561288.0 0.0
2015-11-23 23:13:57.750 4420.0 561288.0 0.0
2015-11-23 23:13:58.000 4420.0 561296.0 8.0
2015-11-23 23:13:58.250 4420.0 561296.0 0.0
2015-11-23 23:13:58.500 4420.0 561296.0 0.0
2015-11-23 23:13:58.750 4420.0 561296.0 0.0
2015-11-23 23:13:59.000 4420.0 561304.0 8.0
2015-11-23 23:13:59.250 4420.0 561528.0 224.0
2015-11-23 23:13:59.500 4420.0 561528.0 0.0
2015-11-23 23:13:59.750 4422.0 561530.0 2.0
2015-11-23 23:14:00.000 4420.0 561550.0 20.0
2015-11-23 23:14:00.250 4420.0 561550.0 0.0
2015-11-23 23:14:00.500 4420.0 561552.0 2.0
2015-11-23 23:14:00.750 4420.0 561552.0 0.0
2015-11-23 23:14:01.000 4420.0 561552.0 0.0
2015-11-23 23:14:01.250 4422.0 561692.0 140.0
2015-11-23 23:14:01.500 4422.0 561692.0 0.0
2015-11-23 23:14:01.750 4422.0 561692.0 0.0
2015-11-23 23:14:02.000 4422.0 561692.0 0.0
2015-11-23 23:14:02.250 4422.0 561694.0 2.0
2015-11-23 23:14:02.500 4422.0 561694.0 0.0
2015-11-23 23:14:02.750 4422.0 561694.0 0.0
2015-11-23 23:14:03.000 4422.0 561714.0 20.0
2015-11-23 23:14:03.250 4420.0 561724.0 10.0
2015-11-23 23:14:03.500 4420.0 561736.0 12.0
2015-11-23 23:14:03.750 4420.0 561736.0 0.0
2015-11-23 23:14:04.000 4420.0 561736.0 0.0
2015-11-23 23:14:04.250 4420.0 561736.0 0.0
2015-11-23 23:14:04.500 4420.0 561736.0 0.0
2015-11-23 23:14:04.750 4420.0 561738.0 2.0

In [345]:
%matplotlib inline

In [297]:
plt.plot(vwap.index, ta.ix[vwap.index, 'last'])
plt.plot(vwap.index, vwap)


Out[297]:
[<matplotlib.lines.Line2D at 0x7fe8fc3b1dd0>]

In [270]:
len(vwap_indicator)


Out[270]:
2700120

In [271]:
len(ta_in_pm)


Out[271]:
1791180

In [272]:
day_len*20


Out[272]:
1800080

In [310]:
day_len*20 - len(ta_in_pm)


Out[310]:
8900

In [242]:
(200+44)*20


Out[242]:
4880

In [303]:
temp = vwap_indicator[ta_in_pm.index]

In [307]:
temp = temp.dropna()

In [309]:
(vwap_indicator.isnull()).sum()


Out[309]:
40

In [308]:
len(temp)


Out[308]:
1791180

In [284]:
vwap, vwap_indicator = VWAPIndicator3(ta, 40)


0
1
1
40

In [ ]:
y = pm[xnew.index]

In [321]:
%matplotlib inline

In [48]:
# --------------------------------------------
'''plot fit'''
fig, ax = plt.subplots()
fig = sm.graphics.plot_fit(res, res.model.exog_names[1], ax=ax)



In [54]:
vwap_indicator.hist(bins=np.arange(-10.25, 10.25, .5))


Out[54]:
<matplotlib.axes.AxesSubplot at 0x7fcbc57f8b10>

In [35]:
ta_pm = GiveMePM(ta, n=44, lim=[0, 30])

In [53]:
vwap, vwap_indicator = VWAPIndicator4(ta, 240)
vwap_indicator = vwap_indicator[ta_pm.index]

In [57]:
ta_pm.hist(bins=np.arange(-50.5, 50.5, 1))


Out[57]:
<matplotlib.axes.AxesSubplot at 0x7fcbc518f550>

Re check!


In [185]:
t11, t22 = '2015-11-25 23:03:06.000', '2015-11-25 23:03:12.000'

In [186]:
plt.plot(ta.ix[t11: t22, 'vol_diff'])
#plt.ylim([0,3000])


Out[186]:
[<matplotlib.lines.Line2D at 0x7fe8f4638790>]

In [183]:
ta.ix[t11: t22, ['last', 'volume', 'vol_diff']]


Out[183]:
last volume vol_diff
2015-11-25 22:03:06.000 1775.0 148528.0 0.0
2015-11-25 22:03:06.250 1775.0 148528.0 0.0
2015-11-25 22:03:06.500 1775.0 148528.0 0.0
2015-11-25 22:03:06.750 1775.0 148528.0 0.0
2015-11-25 22:03:07.000 1775.0 148528.0 0.0
2015-11-25 22:03:07.250 1775.0 148528.0 0.0
2015-11-25 22:03:07.500 1775.0 148528.0 0.0
2015-11-25 22:03:07.750 1775.0 148528.0 0.0
2015-11-25 22:03:08.000 1775.0 148528.0 0.0
2015-11-25 22:03:08.250 1775.0 148528.0 0.0
2015-11-25 22:03:08.500 1775.0 148528.0 0.0
2015-11-25 22:03:08.750 1775.0 148528.0 0.0
2015-11-25 22:03:09.000 1775.0 148528.0 0.0
2015-11-25 22:03:09.250 1775.0 148528.0 0.0
2015-11-25 22:03:09.500 1775.0 148528.0 0.0
2015-11-25 22:03:09.750 1775.0 148530.0 2.0
2015-11-25 22:03:10.000 1775.0 148530.0 0.0
2015-11-25 22:03:10.250 1775.0 148530.0 0.0
2015-11-25 22:03:10.500 1775.0 148530.0 0.0
2015-11-25 22:03:10.750 1775.0 148530.0 0.0
2015-11-25 22:03:11.000 1775.0 148530.0 0.0
2015-11-25 22:03:11.250 1775.0 148530.0 0.0
2015-11-25 22:03:11.500 1775.0 148530.0 0.0
2015-11-25 22:03:11.750 1775.0 148530.0 0.0
2015-11-25 22:03:12.000 1775.0 148530.0 0.0
2015-11-25 22:03:12.250 1775.0 148530.0 0.0
2015-11-25 22:03:12.500 1775.0 148530.0 0.0
2015-11-25 22:03:12.750 1775.0 148532.0 2.0

In [170]:
vwap_indicator[t11: t22]


Out[170]:
2015-12-01 11:03:06.000    0.0
2015-12-01 11:03:06.250    0.0
2015-12-01 11:03:06.500    0.0
2015-12-01 11:03:06.750    0.0
2015-12-01 11:03:07.000    0.0
2015-12-01 11:03:07.250    0.0
2015-12-01 11:03:07.500    0.0
2015-12-01 11:03:07.750    0.0
2015-12-01 11:03:08.000    0.0
2015-12-01 11:03:08.250    0.0
2015-12-01 11:03:08.500    0.0
2015-12-01 11:03:08.750    0.0
2015-12-01 11:03:09.000    0.0
2015-12-01 11:03:09.250    0.0
2015-12-01 11:03:09.500    0.0
2015-12-01 11:03:09.750    0.0
2015-12-01 11:03:10.000    0.0
2015-12-01 11:03:10.250    0.0
2015-12-01 11:03:10.500    0.0
2015-12-01 11:03:10.750    0.0
2015-12-01 11:03:11.000    0.0
2015-12-01 11:03:11.250    0.0
2015-12-01 11:03:11.500    0.0
2015-12-01 11:03:11.750    0.0
2015-12-01 11:03:12.000    0.0
2015-12-01 11:03:12.250    0.0
2015-12-01 11:03:12.500    0.0
2015-12-01 11:03:12.750    0.0
Name: vwap_indicator, dtype: float64

In [171]:
vwap[t11: t22]


Out[171]:
2015-12-01 11:03:06.000    1822.0
2015-12-01 11:03:06.250    1822.0
2015-12-01 11:03:06.500    1822.0
2015-12-01 11:03:06.750    1822.0
2015-12-01 11:03:07.000    1822.0
2015-12-01 11:03:07.250    1822.0
2015-12-01 11:03:07.500    1822.0
2015-12-01 11:03:07.750    1822.0
2015-12-01 11:03:08.000    1822.0
2015-12-01 11:03:08.250    1822.0
2015-12-01 11:03:08.500    1822.0
2015-12-01 11:03:08.750    1822.0
2015-12-01 11:03:09.000    1822.0
2015-12-01 11:03:09.250    1822.0
2015-12-01 11:03:09.500    1822.0
2015-12-01 11:03:09.750    1822.0
2015-12-01 11:03:10.000    1822.0
2015-12-01 11:03:10.250    1822.0
2015-12-01 11:03:10.500    1822.0
2015-12-01 11:03:10.750    1822.0
2015-12-01 11:03:11.000    1822.0
2015-12-01 11:03:11.250    1822.0
2015-12-01 11:03:11.500    1822.0
2015-12-01 11:03:11.750    1822.0
2015-12-01 11:03:12.000    1822.0
2015-12-01 11:03:12.250    1822.0
2015-12-01 11:03:12.500    1822.0
2015-12-01 11:03:12.750    1822.0
Name: vwaPrc, dtype: float64

In [247]:
ta.ix['2015-11-19 21:00:55.000': '2015-11-19 21:01:58.000', 'last'][:55]


Out[247]:
2015-11-19 21:00:55.000    4508.0
2015-11-19 21:00:55.250    4510.0
2015-11-19 21:00:55.500    4510.0
2015-11-19 21:00:55.750    4508.0
2015-11-19 21:00:56.000    4506.0
2015-11-19 21:00:56.250    4508.0
2015-11-19 21:00:56.500    4508.0
2015-11-19 21:00:56.750    4508.0
2015-11-19 21:00:57.000    4510.0
2015-11-19 21:00:57.250    4508.0
2015-11-19 21:00:57.500    4508.0
2015-11-19 21:00:57.750    4510.0
2015-11-19 21:00:58.000    4508.0
2015-11-19 21:00:58.250    4510.0
2015-11-19 21:00:58.500    4508.0
2015-11-19 21:00:58.750    4508.0
2015-11-19 21:00:59.000    4506.0
2015-11-19 21:00:59.250    4506.0
2015-11-19 21:00:59.500    4508.0
2015-11-19 21:00:59.750    4508.0
2015-11-19 21:01:00.000    4508.0
2015-11-19 21:01:00.250    4508.0
2015-11-19 21:01:00.500    4506.0
2015-11-19 21:01:00.750    4508.0
2015-11-19 21:01:01.000    4508.0
2015-11-19 21:01:01.250    4508.0
2015-11-19 21:01:01.500    4506.0
2015-11-19 21:01:01.750    4506.0
2015-11-19 21:01:02.000    4506.0
2015-11-19 21:01:02.250    4506.0
2015-11-19 21:01:02.500    4506.0
2015-11-19 21:01:02.750    4506.0
2015-11-19 21:01:03.000    4506.0
2015-11-19 21:01:03.250    4504.0
2015-11-19 21:01:03.500    4504.0
2015-11-19 21:01:03.750    4504.0
2015-11-19 21:01:04.000    4500.0
2015-11-19 21:01:04.250    4500.0
2015-11-19 21:01:04.500    4502.0
2015-11-19 21:01:04.750    4496.0
2015-11-19 21:01:05.000    4500.0
2015-11-19 21:01:05.250    4500.0
2015-11-19 21:01:05.500    4500.0
2015-11-19 21:01:05.750    4500.0
2015-11-19 21:01:06.000    4500.0
2015-11-19 21:01:06.250    4500.0
2015-11-19 21:01:06.500    4500.0
2015-11-19 21:01:06.750    4500.0
2015-11-19 21:01:07.000    4502.0
2015-11-19 21:01:07.250    4502.0
2015-11-19 21:01:07.500    4502.0
2015-11-19 21:01:07.750    4502.0
2015-11-19 21:01:08.000    4504.0
2015-11-19 21:01:08.250    4504.0
2015-11-19 21:01:08.500    4506.0
Name: last, dtype: float64

In [241]:
ta_in_pm.ix['2015-11-19 21:00:55.000': '2015-11-19 21:00:58.000']


Out[241]:
2015-11-19 21:00:55.000   -6.0
2015-11-19 21:00:55.250   -8.0
2015-11-19 21:00:55.500   -6.0
2015-11-19 21:00:55.750   -4.0
2015-11-19 21:00:56.000    0.0
2015-11-19 21:00:56.250   -4.0
2015-11-19 21:00:56.500   -4.0
2015-11-19 21:00:56.750    0.0
2015-11-19 21:00:57.000   -6.0
2015-11-19 21:00:57.250   -6.0
2015-11-19 21:00:57.500   -6.0
2015-11-19 21:00:57.750   -8.0
2015-11-19 21:00:58.000   -4.0
2015-11-19 21:00:58.250   -6.0
2015-11-19 21:00:58.500   -4.0
2015-11-19 21:00:58.750   -6.0
Name: last, dtype: float64

In [197]:
%matplotlib inline

In [ ]:
temp1

In [195]:
vwap_indicator


Out[195]:
2015-11-19 21:00:00.000         NaN
2015-11-19 21:00:00.250         NaN
2015-11-19 21:00:00.500         NaN
2015-11-19 21:00:00.750         NaN
2015-11-19 21:00:01.000         NaN
2015-11-19 21:00:01.250         NaN
2015-11-19 21:00:01.500         NaN
2015-11-19 21:00:01.750         NaN
2015-11-19 21:00:02.000         NaN
2015-11-19 21:00:02.250         NaN
2015-11-19 21:00:02.500         NaN
2015-11-19 21:00:02.750         NaN
2015-11-19 21:00:03.000         NaN
2015-11-19 21:00:03.250         NaN
2015-11-19 21:00:03.500         NaN
2015-11-19 21:00:03.750         NaN
2015-11-19 21:00:04.000   -0.937409
2015-11-19 21:00:04.250    0.060734
2015-11-19 21:00:04.500   -0.929339
2015-11-19 21:00:04.750   -0.714008
2015-11-19 21:00:05.000    0.297571
2015-11-19 21:00:05.250   -0.350000
2015-11-19 21:00:05.500   -0.332349
2015-11-19 21:00:05.750   -1.180602
2015-11-19 21:00:06.000   -0.941915
2015-11-19 21:00:06.250   -0.854938
2015-11-19 21:00:06.500   -0.824089
2015-11-19 21:00:06.750   -0.815873
2015-11-19 21:00:07.000    0.222222
2015-11-19 21:00:07.250   -0.748031
                             ...   
2015-12-31 14:59:52.750    0.930693
2015-12-31 14:59:53.000   -0.069307
2015-12-31 14:59:53.250   -0.060000
2015-12-31 14:59:53.500    0.824561
2015-12-31 14:59:53.750    0.800000
2015-12-31 14:59:54.000    0.781250
2015-12-31 14:59:54.250    0.592593
2015-12-31 14:59:54.500    0.584906
2015-12-31 14:59:54.750    0.584906
2015-12-31 14:59:55.000   -0.365385
2015-12-31 14:59:55.250    0.473684
2015-12-31 14:59:55.500    0.444444
2015-12-31 14:59:55.750   -0.869565
2015-12-31 14:59:56.000    0.115385
2015-12-31 14:59:56.250    0.056604
2015-12-31 14:59:56.500   -0.909091
2015-12-31 14:59:56.750   -0.857143
2015-12-31 14:59:57.000   -0.607595
2015-12-31 14:59:57.250   -0.369231
2015-12-31 14:59:57.500    0.666667
2015-12-31 14:59:57.750    0.645669
2015-12-31 14:59:58.000   -0.348837
2015-12-31 14:59:58.250    0.656250
2015-12-31 14:59:58.500    0.656250
2015-12-31 14:59:58.750    0.656250
2015-12-31 14:59:59.000    0.585714
2015-12-31 14:59:59.250   -0.382550
2015-12-31 14:59:59.500    0.613333
2015-12-31 14:59:59.750   -0.389262
2015-12-31 15:00:00.000   -0.376712
Name: vwap_indicator2, dtype: float64

In [133]:
ta_out_pm.plot()


Out[133]:
<matplotlib.axes.AxesSubplot at 0x7fda4ca77a10>

Black???


In [82]:
for mywindow in [10, 60, 200, 500, 1000, 2400, 5000, 10000, 24000]:
    print '\n\n\n---------------mywindow: %d ----------------------' %mywindow
    #mywindow = 2400 * 3
    vol_roll = ta.ix[:, 'volume'].rolling(window=mywindow)
    last_multiply_vol = ta.ix[:, 'last'] * ta.ix[:, 'volume']
    multi_roll = last_multiply_vol.rolling(window=mywindow)
    vwap = multi_roll.sum()*1. / vol_roll.sum()
    vwap_indicator = vwap - ta.ix[:, 'last']
#     vwap_indicator.dropna(inplace=True)
#-------------------------------------------------------------------------------
    '''
    Automatically generate in and out sample data, then calculate Qty_indicator,
    then regression under different parameters
    '''
    insample_index = list()
    for l in [[0,2], [4, 6], [8, 10], [14, 16], [18,20], [22, 24], [26,28]]:
        insample_index = insample_index + list(range(day_len*l[0], day_len*l[1]))
    outsample_index = list()
    for l in [[2, 4], [6, 8], [12, 14], [16, 18], [20,22], [24, 26], [28,30]]:
        outsample_index = outsample_index + list(range(day_len*l[0], day_len*l[1]))
    
    for forward_ticks in range(50, 52, 2):
        ta_in_pm = GiveMePM(ta, n=forward_ticks, lim=[0, 20])
        ta_out_pm = GiveMePM(ta, n=forward_ticks, lim=[25, 30])
    
        res = myols(vwap_indicator, ta_in_pm)
        print '\n\n\n--------------------- %d ----------------------' %forward_ticks
        print res.summary()
        print '\n[OutSample R_SQUARE: %f]' % (PredictedRsquare(res, vwap_indicator, ta_out_pm))[1]




---------------mywindow: 10 ----------------------



--------------------- 50 ----------------------
                            OLS Regression Results                            
==============================================================================
Dep. Variable:                   last   R-squared:                       0.106
Model:                            OLS   Adj. R-squared:                  0.106
Method:                 Least Squares   F-statistic:                 2.121e+05
Date:                Thu, 14 Jul 2016   Prob (F-statistic):               0.00
Time:                        07:41:41   Log-Likelihood:            -3.5288e+06
No. Observations:             1793900   AIC:                         7.058e+06
Df Residuals:                 1793898   BIC:                         7.058e+06
Df Model:                           1                                         
==============================================================================
                 coef    std err          t      P>|t|      [95.0% Conf. Int.]
------------------------------------------------------------------------------
const          0.0046      0.001      3.587      0.000         0.002     0.007
None           0.7456      0.002    460.545      0.000         0.742     0.749
==============================================================================
Omnibus:                   507024.499   Durbin-Watson:                   0.214
Prob(Omnibus):                  0.000   Jarque-Bera (JB):         39368879.141
Skew:                           0.415   Prob(JB):                         0.00
Kurtosis:                      25.935   Cond. No.                         1.25
==============================================================================

[OutSample R_SQUARE: 0.122631]



---------------mywindow: 60 ----------------------



--------------------- 50 ----------------------
                            OLS Regression Results                            
==============================================================================
Dep. Variable:                   last   R-squared:                       0.076
Model:                            OLS   Adj. R-squared:                  0.076
Method:                 Least Squares   F-statistic:                 1.472e+05
Date:                Thu, 14 Jul 2016   Prob (F-statistic):               0.00
Time:                        07:41:45   Log-Likelihood:            -3.5583e+06
No. Observations:             1793900   AIC:                         7.117e+06
Df Residuals:                 1793898   BIC:                         7.117e+06
Df Model:                           1                                         
==============================================================================
                 coef    std err          t      P>|t|      [95.0% Conf. Int.]
------------------------------------------------------------------------------
const          0.0057      0.001      4.365      0.000         0.003     0.008
None           0.4290      0.001    383.677      0.000         0.427     0.431
==============================================================================
Omnibus:                   520812.501   Durbin-Watson:                   0.250
Prob(Omnibus):                  0.000   Jarque-Bera (JB):         39272475.183
Skew:                           0.478   Prob(JB):                         0.00
Kurtosis:                      25.902   Cond. No.                         1.17
==============================================================================

[OutSample R_SQUARE: 0.081837]



---------------mywindow: 200 ----------------------



--------------------- 50 ----------------------
                            OLS Regression Results                            
==============================================================================
Dep. Variable:                   last   R-squared:                       0.023
Model:                            OLS   Adj. R-squared:                  0.023
Method:                 Least Squares   F-statistic:                 4.208e+04
Date:                Thu, 14 Jul 2016   Prob (F-statistic):               0.00
Time:                        07:41:49   Log-Likelihood:            -3.6080e+06
No. Observations:             1793829   AIC:                         7.216e+06
Df Residuals:                 1793827   BIC:                         7.216e+06
Df Model:                           1                                         
==============================================================================
                 coef    std err          t      P>|t|      [95.0% Conf. Int.]
------------------------------------------------------------------------------
const          0.0043      0.001      3.209      0.001         0.002     0.007
None           0.1336      0.001    205.131      0.000         0.132     0.135
==============================================================================
Omnibus:                   472450.178   Durbin-Watson:                   0.310
Prob(Omnibus):                  0.000   Jarque-Bera (JB):         31917539.398
Skew:                           0.334   Prob(JB):                         0.00
Kurtosis:                      23.654   Cond. No.                         2.07
==============================================================================

[OutSample R_SQUARE: 0.013947]



---------------mywindow: 500 ----------------------



--------------------- 50 ----------------------
                            OLS Regression Results                            
==============================================================================
Dep. Variable:                   last   R-squared:                       0.007
Model:                            OLS   Adj. R-squared:                  0.007
Method:                 Least Squares   F-statistic:                 1.320e+04
Date:                Thu, 14 Jul 2016   Prob (F-statistic):               0.00
Time:                        07:41:53   Log-Likelihood:            -3.6213e+06
No. Observations:             1793529   AIC:                         7.243e+06
Df Residuals:                 1793527   BIC:                         7.243e+06
Df Model:                           1                                         
==============================================================================
                 coef    std err          t      P>|t|      [95.0% Conf. Int.]
------------------------------------------------------------------------------
const          0.0031      0.001      2.247      0.025         0.000     0.006
None           0.0430      0.000    114.877      0.000         0.042     0.044
==============================================================================
Omnibus:                   450416.004   Durbin-Watson:                   0.334
Prob(Omnibus):                  0.000   Jarque-Bera (JB):         26258295.086
Skew:                           0.308   Prob(JB):                         0.00
Kurtosis:                      21.735   Cond. No.                         3.64
==============================================================================

[OutSample R_SQUARE: 0.002693]



---------------mywindow: 1000 ----------------------



--------------------- 50 ----------------------
                            OLS Regression Results                            
==============================================================================
Dep. Variable:                   last   R-squared:                       0.004
Model:                            OLS   Adj. R-squared:                  0.004
Method:                 Least Squares   F-statistic:                     7867.
Date:                Thu, 14 Jul 2016   Prob (F-statistic):               0.00
Time:                        07:41:58   Log-Likelihood:            -3.6223e+06
No. Observations:             1793029   AIC:                         7.245e+06
Df Residuals:                 1793027   BIC:                         7.245e+06
Df Model:                           1                                         
==============================================================================
                 coef    std err          t      P>|t|      [95.0% Conf. Int.]
------------------------------------------------------------------------------
const          0.0028      0.001      2.069      0.039         0.000     0.005
None           0.0230      0.000     88.698      0.000         0.022     0.023
==============================================================================
Omnibus:                   447160.915   Durbin-Watson:                   0.339
Prob(Omnibus):                  0.000   Jarque-Bera (JB):         24993957.951
Skew:                           0.316   Prob(JB):                         0.00
Kurtosis:                      21.280   Cond. No.                         5.26
==============================================================================

[OutSample R_SQUARE: 0.001277]



---------------mywindow: 2400 ----------------------



--------------------- 50 ----------------------
                            OLS Regression Results                            
==============================================================================
Dep. Variable:                   last   R-squared:                       0.002
Model:                            OLS   Adj. R-squared:                  0.002
Method:                 Least Squares   F-statistic:                     4191.
Date:                Thu, 14 Jul 2016   Prob (F-statistic):               0.00
Time:                        07:42:02   Log-Likelihood:            -3.6211e+06
No. Observations:             1791629   AIC:                         7.242e+06
Df Residuals:                 1791627   BIC:                         7.242e+06
Df Model:                           1                                         
==============================================================================
                 coef    std err          t      P>|t|      [95.0% Conf. Int.]
------------------------------------------------------------------------------
const          0.0023      0.001      1.703      0.089        -0.000     0.005
None           0.0111      0.000     64.737      0.000         0.011     0.011
==============================================================================
Omnibus:                   444553.349   Durbin-Watson:                   0.342
Prob(Omnibus):                  0.000   Jarque-Bera (JB):         24377265.848
Skew:                           0.315   Prob(JB):                         0.00
Kurtosis:                      21.060   Cond. No.                         7.97
==============================================================================

[OutSample R_SQUARE: 0.000621]



---------------mywindow: 5000 ----------------------



--------------------- 50 ----------------------
                            OLS Regression Results                            
==============================================================================
Dep. Variable:                   last   R-squared:                       0.001
Model:                            OLS   Adj. R-squared:                  0.001
Method:                 Least Squares   F-statistic:                     2268.
Date:                Thu, 14 Jul 2016   Prob (F-statistic):               0.00
Time:                        07:42:07   Log-Likelihood:            -3.6169e+06
No. Observations:             1789029   AIC:                         7.234e+06
Df Residuals:                 1789027   BIC:                         7.234e+06
Df Model:                           1                                         
==============================================================================
                 coef    std err          t      P>|t|      [95.0% Conf. Int.]
------------------------------------------------------------------------------
const          0.0025      0.001      1.792      0.073        -0.000     0.005
None           0.0058      0.000     47.620      0.000         0.006     0.006
==============================================================================
Omnibus:                   442249.583   Durbin-Watson:                   0.343
Prob(Omnibus):                  0.000   Jarque-Bera (JB):         23995176.643
Skew:                           0.313   Prob(JB):                         0.00
Kurtosis:                      20.931   Cond. No.                         11.3
==============================================================================

[OutSample R_SQUARE: 0.000328]



---------------mywindow: 10000 ----------------------



--------------------- 50 ----------------------
                            OLS Regression Results                            
==============================================================================
Dep. Variable:                   last   R-squared:                       0.000
Model:                            OLS   Adj. R-squared:                  0.000
Method:                 Least Squares   F-statistic:                     842.0
Date:                Thu, 14 Jul 2016   Prob (F-statistic):          4.43e-185
Time:                        07:42:11   Log-Likelihood:            -3.6082e+06
No. Observations:             1784029   AIC:                         7.216e+06
Df Residuals:                 1784027   BIC:                         7.216e+06
Df Model:                           1                                         
==============================================================================
                 coef    std err          t      P>|t|      [95.0% Conf. Int.]
------------------------------------------------------------------------------
const          0.0026      0.001      1.877      0.060        -0.000     0.005
None           0.0025    8.6e-05     29.017      0.000         0.002     0.003
==============================================================================
Omnibus:                   439920.805   Durbin-Watson:                   0.344
Prob(Omnibus):                  0.000   Jarque-Bera (JB):         23757886.879
Skew:                           0.310   Prob(JB):                         0.00
Kurtosis:                      20.867   Cond. No.                         16.0
==============================================================================

[OutSample R_SQUARE: 0.000128]



---------------mywindow: 24000 ----------------------



--------------------- 50 ----------------------
                            OLS Regression Results                            
==============================================================================
Dep. Variable:                   last   R-squared:                       0.000
Model:                            OLS   Adj. R-squared:                  0.000
Method:                 Least Squares   F-statistic:                     475.2
Date:                Thu, 14 Jul 2016   Prob (F-statistic):          2.44e-105
Time:                        07:42:15   Log-Likelihood:            -3.5825e+06
No. Observations:             1770029   AIC:                         7.165e+06
Df Residuals:                 1770027   BIC:                         7.165e+06
Df Model:                           1                                         
==============================================================================
                 coef    std err          t      P>|t|      [95.0% Conf. Int.]
------------------------------------------------------------------------------
const          0.0018      0.001      1.324      0.185        -0.001     0.005
None           0.0012   5.67e-05     21.799      0.000         0.001     0.001
==============================================================================
Omnibus:                   435736.170   Durbin-Watson:                   0.344
Prob(Omnibus):                  0.000   Jarque-Bera (JB):         23563592.016
Skew:                           0.306   Prob(JB):                         0.00
Kurtosis:                      20.864   Cond. No.                         24.4
==============================================================================

[OutSample R_SQUARE: 0.000081]

In [ ]: