Notebook
In [1]:
# Import Pipeline class and datasets
from quantopian.pipeline import Pipeline
from quantopian.pipeline.data import USEquityPricing
from quantopian.pipeline import CustomFactor
from quantopian.pipeline.data import morningstar as morningstar
from quantopian.pipeline.experimental import QTradableStocksUS
from quantopian.pipeline.data import Fundamentals  
from quantopian.pipeline.factors.fundamentals import MarketCap

# Import built-in moving average calculation
from quantopian.pipeline import factors, filters, classifiers
from quantopian.pipeline.factors import DailyReturns, SimpleMovingAverage

import numpy as np
import numpy
import pandas as pd
from statsmodels.tsa.stattools import coint
import statsmodels.api as sm
import statsmodels.tsa.stattools as ts
import datetime
import matplotlib.pyplot as plt

def hedging(long_date, short_date, execution_date):

    global df, df2, c_matrix, correl_matrix, sec_col, dt
    #class MarketCap(CustomFactor):   

        # Pre-declare inputs and window_length
    #    inputs = [USEquityPricing.close, morningstar.valuation.shares_outstanding] 
    #    window_length = 1

        # Compute market cap value
    #    def compute(self, today, assets, out, close, shares):       
    #        out[:] = close[-1] * shares[-1]

    #mkt_cap = MarketCap()

    #mkt_cap_rank = mkt_cap.rank(ascending=False)
    #russell_2000 = (1000 > mkt_cap_rank) & (mkt_cap_rank <= 3000)

    def make_pipeline():

        #calculate returns
        price = USEquityPricing.close.latest
        benchmark = morningstar.company_reference.primary_symbol.latest != 'SPY'
        market_cap =  Fundamentals.market_cap.latest 
        universe = (QTradableStocksUS()
                   & benchmark) #& russell_2000)

    # Return Pipeline containing close_price
        # and sentiment_score
        return Pipeline(
            columns={'price':price,
                     'Market_cap':market_cap
                },
            screen=universe
        )
    # Import run_pipeline method
    from quantopian.research import run_pipeline

    # Execute pipeline created by make_pipeline
    # between start_date and end_date
    pipeline_output = run_pipeline(
        make_pipeline(),
        start_date=long_date,
        end_date=execution_date
    )

    df = pipeline_output
    df = df.reset_index()
    df['level_1']=[e.symbol for e in df['level_1']]
    
    
    df1a=df[['level_0','level_1','price']]
    df1b =pd.pivot_table(df1a,index='level_0', columns=['level_1'],aggfunc = max)
    #remove top level of multiindex
    df1b.columns = df1b.columns.droplevel(0)
    df1b = df1b.reset_index()    
    
    recent = df1b.iloc[df1b.shape[0]-1,1:]
    recent = recent.dropna()
    recent = recent.reset_index()
    columns=np.array(recent['level_1'])
    df2=df1b[columns]
    
    #df2 has those securities still traded - now set all NaNs to 0 and calculate correlation matrix.

    df3 = df2.fillna(0)
    
    correl_matrix =  df3.corr(method='pearson')
    correl_matrix = correl_matrix.reset_index()
    
  #  def plot_price_series(df, ts1, ts2):
  #        # every month
  #      fig, ax = plt.subplots()
  #      ax.plot(df.index, df[ts1], label=ts1)
  #      ax.plot(df.index, df[ts2], label=ts2)
  #      ax.grid(True)
  #      fig.autofmt_xdate()

  #      plt.xlabel('Month/Year')
  #      plt.ylabel('Market Spread')
  #      plt.title('%s and %s Daily Prices' % (ts1, ts2))
  #      plt.legend()
  #      plt.show()


    def coint_testing (number,dset):
        col_names = pd.DataFrame(np.array(dset.columns).reshape(-1,len(dset.columns)), columns = list(dset.columns))
        col_names
        c_matrix =pd.DataFrame(dset.columns.transpose())
        for i in range (number,len(col_names.columns)):               
            sec_col = np.array
            dt=pd.DataFrame
            for j in range (0,len(col_names.columns)):
                d1 = dset[[col_names.iloc[0,i],col_names.iloc[0,j]]]
                d1=d1[~numpy.isnan(d1[col_names.iloc[0,i]])]
                d1=d1[~numpy.isnan(d1[col_names.iloc[0,j]])] 
                if d1.shape[0]<100:
                    cadf = 0
                elif i <> j:
                    if abs(correl_matrix.iat[i,j+1]) >0.7:
                        if coint(d1[col_names.iloc[0,i]], d1[col_names.iloc[0,j]])[1] <0.05:
                            cadf = correl_matrix.iloc[i,j+1]
                        else:
                            cadf=0
                    else:
                        cadf = 0
                elif i == j:
                    cadf = 0
                sec_col= numpy.append(sec_col,cadf)
                
            #print(sec_col)
            c_matrix[col_names.iloc[0,i]]=pd.DataFrame(sec_col[2:])
            #print(pd.DataFrame(sec_col[2:]))
                
            
        return c_matrix;

    c_matrix = coint_testing(0, df2)

    candidates = c_matrix.set_index('level_1').apply(lambda x: pd.Series(x.sort_values(ascending=False)
           .iloc[1:6].index, 
          index=['top1','top2','top3','top4','top5']), axis=1).reset_index()
    return candidates;
In [2]:
import time
from datetime import date
print(date.today())

from datetime import timedelta
year = timedelta(days=150)
long_d = date.today() - year
print(long_d)
short_d = date.today() - timedelta(days=90)
print(short_d)
#print(df2.shape[0])
2019-04-08
2018-11-09
2019-01-08
In [3]:
candidates = hedging(long_d,short_d,date.today())
candidates
Out[3]:
level_1 top1 top2 top3 top4 top5
0 A HSC SPN IMO NINE AIT
1 AA CGNX ACGL SRG GIL ADI
2 AABA FLXN ABC AXE SCI ARMK
3 AAL SCL KMPR PATK MGPI APTV
4 AAN PSTG CFX GPRO BCPC SCCO
5 AAON GPRE ATR ACN EE IT
6 AAPL ELS EXC BKH TRI AES
7 AAT JBHT DOOR HUBG BPOP FCF
8 AAWW KAMN BBBY DG SHOO MTH
9 AAXN HAE M CWEN LGND RVNC
10 ABBV RLJ PDCO GOOS GD AEL
11 ABC CBSH WBS BANC CJ AKS
12 ABCB EXTR EVRG EVRI EVTC EW
13 ABEO ALSN RBA MGA KRNY COWN
14 ABG LGIH USFD TOL WRLD DG
15 ABM ITRI BEAT MCK TSE EVTC
16 ABMD INXN NCLH ALXN JCI HASI
17 ABR CSCO TFX MXL ENV ZBRA
18 ABT PTLA BPMC ENPH AVY SSP
19 ACAD COLD NNN WCN SLGN TRI
20 ACC AXTA LCII ENVA SSD TXMD
21 ACCO TECH SRG CTAS CGNX NYT
22 ACGL TK WAIR SBH MTDR CLB
23 ACHC EXTR EVRG EVRI EVTC EW
24 ACHN RARE TTC ANET ENV CECO
25 ACIA CNMD ZBRA PAYX NMIH ALG
26 ACIW ORA CSOD LXP SAIL ARNA
27 ACLS SLB LNC NTRS EV MSM
28 ACM XOM ATR AKAM XHR SRCL
29 ACN EVH FOSL CTL LPI TVTY
... ... ... ... ... ... ...
2123 XHR EBAY PAYC AVY QTWO MRVL
2124 XLNX SBH ROL WAB RTRX ACHC
2125 XLRN LTRP_A TRIP ASMB GT MKL
2126 XNCR HZO DOX HRB CBOE WAIR
2127 XOG CMCS_A CSX AXP FDS IART
2128 XOM CDEV PGTI CI MD ORBC
2129 XON EGO WWE OKTA AEM CNP
2130 XPER NE PEI MKL CURO OAS
2131 XPO NZF TNDM IMAX YUM GOOG_L
2132 XRAY GPN RARE FND ACIW WEX
2133 XYL BRKL OC LUV JBHT ICUI
2134 Y ATKR TREX SGMS CSOD RESI
2135 YELP CSII BLD BIO SNBR AGO
2136 YEXT QTWO AVY XLNX BPMC SYF
2137 YNDX GOOG_L PLNT EVBG TWLO XRAY
2138 YUM SNPS MA RMBS PAYX PCTY
2139 YUMC TSEM GHC MMYT BSX VCEL
2140 Z PEGI ALNY TSN CB LNG
2141 ZAYO MMC LBRD_K EL VSAT SYK
2142 ZBH ECL ACIW EQIX EEFT CNMD
2143 ZBRA RPD NOW PRO TWLO PANW
2144 ZEN SHOP WM MAS SSTK TTD
2145 ZGNX IBKC STI CSFL MTB TCBI
2146 ZION EXTR EVRG EVRI EVTC EW
2147 ZIOP PANW RNG GTLS OR TEAM
2148 ZNGA EXTR EVRG EVRI EVTC EW
2149 ZS CMCS_A AAON PSTG BF_B WTTR
2150 ZTS CC DAN MTOR ENB JPS
2151 ZUMZ EXTR EVRG EVRI EVTC EW
2152 ZUO AA AABA AAL AAN AAON

2153 rows × 6 columns

In [5]:
from scipy.spatial.distance import mahalanobis
import scipy as sp
import math
import scipy.stats



def kurtosis_mnorm(data):
    global Sx,mean
    Sx = data.cov().values
    Sx = sp.linalg.inv(Sx)
    mean = data.mean().values
    m = []
    for i in range(data.shape[0]):
        m.append(mahalanobis(data.ix[i,:],mean,Sx) ** 2)
    kurtosis_test = ((((numpy.sum(np.power(m,2))))*0.0039)-(len(data.columns))*
                 ((len(data.columns))+2))*math.sqrt(((8*(len(data.columns))*
                                                      ((len(data.columns))+2))*0.0039))
    kurtosis_test = np.where(np.isnan(kurtosis_test), 100, kurtosis_test)#singluar cov matrix should be fail
    #print(kurtosis_test)
    return(kurtosis_test)


def skewness_mnorm(x,mean,IC):
    m = []
    for j in range(x.shape[0]):
        k_dons=[]
        for i in range(x.shape[0]):
            diff_j = x.ix[j,:]-mean
            diff_i = x.ix[i,:]-mean          
            k_dons.append(numpy.power(numpy.matmul(numpy.matmul(np.transpose(diff_j),Sx),diff_i),3))
        m.append(numpy.sum(k_dons))
    angle=numpy.sum(m)
    sk=  0.0039*angle
    skewness_test=(1 - scipy.stats.chi2.cdf(sk,  
                             df=round(0.1667*(len(x.columns))*(len(x.columns) + 1)*(len(x.columns) + 2))))
    skewness_test = np.where(np.isnan(skewness_test), 0, skewness_test)
    #print(skewness_test)
    return(skewness_test)
    
def multivariate_normal_testing(ds):
    sec_col = np.array
    for a in range (0,ds.shape[0]):
        for b in range (2,len(ds.columns)):
            kt=0
            sk=0
            if b==2:
                sample = df2[[ds.iloc[a,1],ds.iloc[a,2]]]
            elif b==3:
                sample = df2[[ds.iloc[a,1],ds.iloc[a,2],ds.iloc[a,3]]]
            elif b==4:
                sample = df2[[ds.iloc[a,1],ds.iloc[a,2],ds.iloc[a,3],ds.iloc[a,4]]]
            elif b==5:
                sample = df2[[ds.iloc[a,1],ds.iloc[a,2],ds.iloc[a,3],ds.iloc[a,4],ds.iloc[a,5]]]
            elif b==6:
                sample = df2[[ds.iloc[a,1],ds.iloc[a,2],ds.iloc[a,3],ds.iloc[a,4],ds.iloc[a,5],ds.iloc[a,6]]]
            if sample.iloc[:,:2].corr(method='pearson').iloc[1,0]<0.7:
                mult=b-1
                break
            else:
                kurtosis_test=kurtosis_mnorm(sample)
                skewness_test=skewness_mnorm(sample,mean,Sx)
            
            if np.logical_or((1-scipy.stats.norm.cdf(kurtosis_test))<0.1,
                             (1-scipy.stats.norm.cdf(kurtosis_test))<0.1):
                kt=1
            if skewness_test<0.01:
                sk=1
            if sk+kt==1:
                mult=b-0.5
                sec_col=np.append(sec_col,mult)
                #print(sec_col[1:])
                break
            elif  sk+kt>1:
                mult=b-1
                sec_col=np.append(sec_col,mult)
                #print(sec_col[1:])
                break
            elif b == 6:
                mult=6
                sec_col=np.append(sec_col,mult)
                #print(sec_col[1:])
                break;
            #print(mult)
       # ds['Mult']=pd.DataFrame(sec_col[2:])
    return(sec_col)

candidates_2=multivariate_normal_testing(ds=candidates)
candidates['mult']= pd.DataFrame(candidates_2[1:])
candidates
Out[5]:
level_1 top1 top2 top3 top4 top5 mult
0 A HSC SPN IMO NINE AIT 1.5
1 AA CGNX ACGL SRG GIL ADI 1.5
2 AABA FLXN ABC AXE SCI ARMK 1.5
3 AAL SCL KMPR PATK MGPI APTV 1.5
4 AAN PSTG CFX GPRO BCPC SCCO 2.5
5 AAON GPRE ATR ACN EE IT 1.5
6 AAPL ELS EXC BKH TRI AES 3.5
7 AAT JBHT DOOR HUBG BPOP FCF 1.5
8 AAWW KAMN BBBY DG SHOO MTH 1.5
9 AAXN HAE M CWEN LGND RVNC 1.5
10 ABBV RLJ PDCO GOOS GD AEL 1.5
11 ABC CBSH WBS BANC CJ AKS 1.5
12 ABCB EXTR EVRG EVRI EVTC EW 2.5
13 ABEO ALSN RBA MGA KRNY COWN 1.5
14 ABG LGIH USFD TOL WRLD DG 1.5
15 ABM ITRI BEAT MCK TSE EVTC 3.5
16 ABMD INXN NCLH ALXN JCI HASI 1.5
17 ABR CSCO TFX MXL ENV ZBRA 1.5
18 ABT PTLA BPMC ENPH AVY SSP 2.5
19 ACAD COLD NNN WCN SLGN TRI 1.5
20 ACC AXTA LCII ENVA SSD TXMD 2.5
21 ACCO TECH SRG CTAS CGNX NYT 1.5
22 ACGL TK WAIR SBH MTDR CLB 1.5
23 ACHC EXTR EVRG EVRI EVTC EW 1.5
24 ACHN RARE TTC ANET ENV CECO 2.5
25 ACIA CNMD ZBRA PAYX NMIH ALG 1.5
26 ACIW ORA CSOD LXP SAIL ARNA 1.5
27 ACLS SLB LNC NTRS EV MSM 1.5
28 ACM XOM ATR AKAM XHR SRCL 1.5
29 ACN EVH FOSL CTL LPI TVTY 3.5
... ... ... ... ... ... ... ...
2123 XHR EBAY PAYC AVY QTWO MRVL NaN
2124 XLNX SBH ROL WAB RTRX ACHC NaN
2125 XLRN LTRP_A TRIP ASMB GT MKL NaN
2126 XNCR HZO DOX HRB CBOE WAIR NaN
2127 XOG CMCS_A CSX AXP FDS IART NaN
2128 XOM CDEV PGTI CI MD ORBC NaN
2129 XON EGO WWE OKTA AEM CNP NaN
2130 XPER NE PEI MKL CURO OAS NaN
2131 XPO NZF TNDM IMAX YUM GOOG_L NaN
2132 XRAY GPN RARE FND ACIW WEX NaN
2133 XYL BRKL OC LUV JBHT ICUI NaN
2134 Y ATKR TREX SGMS CSOD RESI NaN
2135 YELP CSII BLD BIO SNBR AGO NaN
2136 YEXT QTWO AVY XLNX BPMC SYF NaN
2137 YNDX GOOG_L PLNT EVBG TWLO XRAY NaN
2138 YUM SNPS MA RMBS PAYX PCTY NaN
2139 YUMC TSEM GHC MMYT BSX VCEL NaN
2140 Z PEGI ALNY TSN CB LNG NaN
2141 ZAYO MMC LBRD_K EL VSAT SYK NaN
2142 ZBH ECL ACIW EQIX EEFT CNMD NaN
2143 ZBRA RPD NOW PRO TWLO PANW NaN
2144 ZEN SHOP WM MAS SSTK TTD NaN
2145 ZGNX IBKC STI CSFL MTB TCBI NaN
2146 ZION EXTR EVRG EVRI EVTC EW NaN
2147 ZIOP PANW RNG GTLS OR TEAM NaN
2148 ZNGA EXTR EVRG EVRI EVTC EW NaN
2149 ZS CMCS_A AAON PSTG BF_B WTTR NaN
2150 ZTS CC DAN MTOR ENB JPS NaN
2151 ZUMZ EXTR EVRG EVRI EVTC EW NaN
2152 ZUO AA AABA AAL AAN AAON NaN

2153 rows × 7 columns

In [9]:
mult_fun = candidates.loc[candidates['mult']>2]
mult_fun
    
Out[9]:
level_1 top1 top2 top3 top4 top5 mult
4 AAN PSTG CFX GPRO BCPC SCCO 2.5
6 AAPL ELS EXC BKH TRI AES 3.5
12 ABCB EXTR EVRG EVRI EVTC EW 2.5
15 ABM ITRI BEAT MCK TSE EVTC 3.5
18 ABT PTLA BPMC ENPH AVY SSP 2.5
20 ACC AXTA LCII ENVA SSD TXMD 2.5
24 ACHN RARE TTC ANET ENV CECO 2.5
29 ACN EVH FOSL CTL LPI TVTY 3.5
37 ADS CY HDS PKI VECO MRCY 2.5
38 ADSK DRH JBGS IR XOM ATR 2.5
40 ADT OFG RHI HPE RL SQ 2.5
45 AEL TEAM WDAY NRG EXPE EXPD 2.5
48 AEP DVA ADS TBI WLL WPG 2.5
50 AERI ARE DEI CTRE PSB BLL 2.5
56 AGCO EXTR EVRG EVRI EVTC EW 2.5
87 ALEX NOVT GPN PEGA SWM INTU 2.5
89 ALGN AX PRAH MFA LECO PGRE 4.5
91 ALK EXTR EVRG EVRI EVTC EW 2.5
97 ALNY SPLK SNX CNP IAC TECD 2.5
99 ALSN ACIW NMIH PAYX ALG ORCL 2.5
103 AMAG FAF GPK IBM QSR FISV 2.5
109 AMD ROP G HEI ECL MANH 2.5
117 AMP EXTR EVRG EVRI EVTC EW 2.5
125 ANET PLNT XRAY EVBG NZF GOOG_L 2.5
128 ANGO NCI DPZ PLAB CTB TIVO 2.5
137 APC FLT CPRT SNAP GRMN CYBR 2.5
139 APH CIT PLD DOV FBHS TRMB 2.5
147 APY VIAV PANW RNG GDDY IPAR 2.5
152 ARCH GDEN EXTR EXPO EXPE EXPD 2.5
165 ARW MAS UBNT INTC JCOM TNET 2.5
... ... ... ... ... ... ... ...
1731 SINA ZUO EXEL EXPO EXPE EXPD 3.5
1736 SIX ADSW UTX HLX PTEN APA 2.5
1739 SJR PLT PDCE CISN NBR VNTR 2.5
1745 SLAB ACM CJ ASGN OXY ASH 2.5
1756 SMPL KALU BYD CNHI LZB RETA 2.5
1782 SR FCAU EXPE EXPO EXR EXTR 2.5
1784 SRCI WTTR ACN FDS TRV COHR 2.5
1787 SRE TECH ANSS CBRE ARE DEI 2.5
1793 SSD INTU CYBR FSCT WK PRO 2.5
1801 ST HI CEIX MCFT GOLF VG 2.5
1808 STL SNDR SLB BCC CJ TCBI 2.5
1811 STMP MTCH GLOB COUP FGEN ALRM 2.5
1816 STWD IPHI GDI MPWR FTV RS 2.5
1817 STX CAG SBH DAL CMC SCHN 2.5
1820 SUI WHR JLL KLIC ECPG WMGI 2.5
1833 SYMC ZUO EXC EXPE EXPD EXP 2.5
1834 SYNA LTC KRG WIFI FTI ALDR 2.5
1836 SYY AMZN MCD EGHT DNKN MUSA 2.5
1851 TDG LM IBKC KNL ZION CMA 2.5
1852 TDOC NCI ARCB AMN PINC TBPH 2.5
1858 TECH ZUO EXAS EXPE EXPD EXP 2.5
1863 TER SNPS LII MSCI AMT TRI 2.5
1866 TEX PAYX MA MTD EEFT INTU 2.5
1879 TISI NKTR NTNX MDRX ANIK WLK 2.5
1880 TIVO CISN PSX ULTA GIS SPB 2.5
1881 TJX WAIR AA CF SITE MOV 3.5
1893 TOL EXTR EVRG EVRI EVTC EW 2.5
1905 TRHC COKE BAX SNPS EXC APPF 2.5
1914 TRP NTB ONB NBHC FLOW ABCB 3.5
1918 TRU DPLO USNA ARR UNIT GDOT 2.5

334 rows × 7 columns

In [74]:
from scipy.stats import mvn
def multivariate_cdf(ds):
    global sec_col, sl1, sl2, sl3, sl4, sl5
    mult_funny=ds
    mult_funny = mult_funny.reset_index()
    sec_col = np.array
    sl1=np.array
    sl2=np.array
    sl3=np.array
    sl4=np.array
    sl5=np.array
    for a in range (0,ds.shape[0]):
        if ds.iat[a,6]==2.5:        
            data =df2[[ds.iloc[a,1],ds.iloc[a,2],ds.iloc[a,3]]]
        elif ds.iat[a,6]==3.5:
            data =df2[[ds.iloc[a,1],ds.iloc[a,2],ds.iloc[a,3],ds.iloc[a,4]]]
        elif ds.iat[a,6]==4.5:
            data =df2[[ds.iloc[a,1],ds.iloc[a,2],ds.iloc[a,3],ds.iloc[a,4],ds.iloc[a,5]]]
        data=data.iloc[-30:]
        mu = np.array(data.mean().values)
        sigma = np.array(data.cov().values)
        #correl=np.array(data.corr().values)
        x=np.array(data.iloc[-1:])
        #print(mu[0])
        #print(x[0][0])
        lower_bounds = np.array([-9223372036854775808] * x.size)
        #mvn1 = mvndst(lower_bounds,x,0,correl)
        mvn=scipy.stats.mvn.mvnun(lower_bounds,x,mu,sigma)[0]  
        l1=x[0][0]-mu[0]
        l2=x[0][1]-mu[1]
        l3=x[0][2]-mu[2]
        if ds.iat[a,6]==2.5:
            l4=0
            l5=0
        elif ds.iat[a,6]==3.5:
            l4=x[0][3]-mu[3]
            l5=0
        elif ds.iat[a,6]==4.5:
            l4=x[0][3]-mu[3]
            l5=x[0][4]-mu[4]            
        sec_col=np.append(sec_col,mvn)
        sl1=np.append(sl1,l1)
        sl2=np.append(sl2,l2)
        sl3=np.append(sl3,l3)
        sl4=np.append(sl4,l4)
        sl5=np.append(sl5,l5)
    #print(sec_col)
    mult_funny['p_value']=pd.DataFrame(sec_col[1:])
    mult_funny['sec_1']=pd.DataFrame(sl1[1:])
    mult_funny['sec_2']=pd.DataFrame(sl2[1:])
    mult_funny['sec_3']=pd.DataFrame(sl3[1:])
    mult_funny['sec_4']=pd.DataFrame(sl4[1:])
    mult_funny['sec_5']=pd.DataFrame(sl5[1:]) 
    
    mult_funny['cond1']=np.where(((mult_funny['sec_1']<0) & (mult_funny['sec_2']<0) & (mult_funny['sec_3']<0)
                                  &(mult_funny['sec_4']<=0)&(mult_funny['sec_5']<=0))
                                 |((mult_funny['sec_1']>0) & (mult_funny['sec_2']>0) & (mult_funny['sec_3']>0)
                                  &(mult_funny['sec_4']>=0)&(mult_funny['sec_5']>=0)),1,0)

    

    return mult_funny;

mult_funny=multivariate_cdf(ds=mult_fun)
mult_funny
Out[74]:
index level_1 top1 top2 top3 top4 top5 mult p_value sec_1 sec_2 sec_3 sec_4 sec_5 cond1
0 4 AAN PSTG CFX GPRO BCPC SCCO 2.5 0.903121 1.95967 2.462 0.355667 0 0 1
1 6 AAPL ELS EXC BKH TRI AES 3.5 0.716647 3.82575 0.498167 1.26667 2.28433 0 1
2 12 ABCB EXTR EVRG EVRI EVTC EW 2.5 0.360011 0.101167 0.655167 1.09133 0 0 1
3 15 ABM ITRI BEAT MCK TSE EVTC 3.5 0.0788592 -2.08633 -4.74883 -2.0615 0.6015 0 0
4 18 ABT PTLA BPMC ENPH AVY SSP 2.5 0.660741 4.28393 1.29917 0.811667 0 0 1
5 20 ACC AXTA LCII ENVA SSD TXMD 2.5 0.230586 0.6415 4.03367 -0.830833 0 0 0
6 24 ACHN RARE TTC ANET ENV CECO 2.5 0.832174 7.23883 1.8825 14.594 0 0 1
7 29 ACN EVH FOSL CTL LPI TVTY 3.5 0.0398402 -0.632667 -1.006 0.266733 -0.216433 0 0
8 37 ADS CY HDS PKI VECO MRCY 2.5 0.908224 0.753833 1.15083 4.00333 0 0 1
9 38 ADSK DRH JBGS IR XOM ATR 2.5 0.975106 0.253833 1.59533 5.768 0 0 1
10 40 ADT OFG RHI HPE RL SQ 2.5 0.315087 -0.232667 1.415 0.28025 0 0 0
11 45 AEL TEAM WDAY NRG EXPE EXPD 2.5 0.144451 1.8151 -3.15967 -0.0916667 0 0 0
12 48 AEP DVA ADS TBI WLL WPG 2.5 0.771917 1.86333 5.36433 1.28067 0 0 1
13 50 AERI ARE DEI CTRE PSB BLL 2.5 0.756449 3.92433 1.451 0.366333 0 0 1
14 56 AGCO EXTR EVRG EVRI EVTC EW 2.5 0.359994 0.101167 0.655167 1.09133 0 0 1
15 87 ALEX NOVT GPN PEGA SWM INTU 2.5 0.877618 4.19317 3.76167 2.09733 0 0 1
16 89 ALGN AX PRAH MFA LECO PGRE 4.5 0.301101 0.494667 0.205167 0.0731667 4.09083 0.0926667 1
17 91 ALK EXTR EVRG EVRI EVTC EW 2.5 0.360045 0.101167 0.655167 1.09133 0 0 1
18 97 ALNY SPLK SNX CNP IAC TECD 2.5 0.531014 1.04067 7.4635 0.323 0 0 1
19 99 ALSN ACIW NMIH PAYX ALG ORCL 2.5 0.883323 1.23533 1.42783 2.26683 0 0 1
20 103 AMAG FAF GPK IBM QSR FISV 2.5 0.785874 2.71767 0.165833 3.63633 0 0 1
21 109 AMD ROP G HEI ECL MANH 2.5 0.934018 15.2308 1.34773 5.0015 0 0 1
22 117 AMP EXTR EVRG EVRI EVTC EW 2.5 0.360034 0.101167 0.655167 1.09133 0 0 1
23 125 ANET PLNT XRAY EVBG NZF GOOG_L 2.5 0.456981 5.72 2.10675 -0.0383333 0 0 0
24 128 ANGO NCI DPZ PLAB CTB TIVO 2.5 0.348154 -0.0511667 6.198 -0.00133333 0 0 0
25 137 APC FLT CPRT SNAP GRMN CYBR 2.5 0.953944 12.3327 4.2253 1.322 0 0 1
26 139 APH CIT PLD DOV FBHS TRMB 2.5 0.558028 0.351167 1.776 4.3865 0 0 1
27 147 APY VIAV PANW RNG GDDY IPAR 2.5 0.0938524 -0.0511667 -2.242 0.143333 0 0 0
28 152 ARCH GDEN EXTR EXPO EXPE EXPD 2.5 0.0516784 0.366167 0.101167 -0.382 0 0 0
29 165 ARW MAS UBNT INTC JCOM TNET 2.5 0.975025 1.68883 15.3805 1.85967 0 0 1
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
304 1731 SINA ZUO EXEL EXPO EXPE EXPD 3.5 0.00756979 -2.03127 0.956033 -0.382 -0.018 0 0
305 1736 SIX ADSW UTX HLX PTEN APA 2.5 0.899626 0.692 6.46533 0.6225 0 0 1
306 1739 SJR PLT PDCE CISN NBR VNTR 2.5 0.614184 1.62183 2.66633 0.319667 0 0 1
307 1745 SLAB ACM CJ ASGN OXY ASH 2.5 0.347017 0.872167 -0.300333 2.73233 0 0 0
308 1756 SMPL KALU BYD CNHI LZB RETA 2.5 0.61861 2.414 0.427833 0.3565 0 0 1
309 1782 SR FCAU EXPE EXPO EXR EXTR 2.5 0.062773 0.618833 -0.018 -0.382 0 0 0
310 1784 SRCI WTTR ACN FDS TRV COHR 2.5 0.921907 1.18767 11.1057 13.5693 0 0 1
311 1787 SRE TECH ANSS CBRE ARE DEI 2.5 0.780476 2.82583 5.3073 1.368 0 0 1
312 1793 SSD INTU CYBR FSCT WK PRO 2.5 0.192849 6.88433 2.044 -1.15317 0 0 0
313 1801 ST HI CEIX MCFT GOLF VG 2.5 0.106442 -0.0105 -2.18533 0.418233 0 0 0
314 1808 STL SNDR SLB BCC CJ TCBI 2.5 0.469124 0.006 1.3965 0.468667 0 0 1
315 1811 STMP MTCH GLOB COUP FGEN ALRM 2.5 0.0893206 -0.736333 3.681 -2.32417 0 0 0
316 1816 STWD IPHI GDI MPWR FTV RS 2.5 0.926644 1.819 0.96 6.24933 0 0 1
317 1817 STX CAG SBH DAL CMC SCHN 2.5 0.944981 3.574 1.38683 6.574 0 0 1
318 1820 SUI WHR JLL KLIC ECPG WMGI 2.5 0.283482 -0.284333 -2.66667 1.003 0 0 0
319 1833 SYMC ZUO EXC EXPE EXPD EXP 2.5 0.0195262 -2.03127 0.498167 -0.018 0 0 0
320 1834 SYNA LTC KRG WIFI FTI ALDR 2.5 0.819724 0.783 0.582583 3.1115 0 0 1
321 1836 SYY AMZN MCD EGHT DNKN MUSA 2.5 0.779306 110.022 5.887 0.586333 0 0 1
322 1851 TDG LM IBKC KNL ZION CMA 2.5 0.224174 1.14617 0.173833 -0.6085 0 0 0
323 1852 TDOC NCI ARCB AMN PINC TBPH 2.5 0.34399 -0.0511667 -0.0789333 1.45133 0 0 0
324 1858 TECH ZUO EXAS EXPE EXPD EXP 2.5 0.0922558 -2.03127 0.921667 -0.018 0 0 0
325 1863 TER SNPS LII MSCI AMT TRI 2.5 0.924885 7.6945 19.257 15.9185 0 0 1
326 1866 TEX PAYX MA MTD EEFT INTU 2.5 0.887104 2.26683 6.6483 30.9993 0 0 1
327 1879 TISI NKTR NTNX MDRX ANIK WLK 2.5 0.0725293 0.5955 -2.0652 -0.527 0 0 0
328 1880 TIVO CISN PSX ULTA GIS SPB 2.5 0.568399 0.319667 0.777333 25.8837 0 0 1
329 1881 TJX WAIR AA CF SITE MOV 3.5 0.306782 -0.102567 0.817333 1.76 5.487 0 0
330 1893 TOL EXTR EVRG EVRI EVTC EW 2.5 0.359979 0.101167 0.655167 1.09133 0 0 1
331 1905 TRHC COKE BAX SNPS EXC APPF 2.5 0.901695 36.548 3.3115 7.6945 0 0 1
332 1914 TRP NTB ONB NBHC FLOW ABCB 3.5 0.381152 -0.533333 0.0473667 0.215667 1.224 0 0
333 1918 TRU DPLO USNA ARR UNIT GDOT 2.5 0.0668625 -0.232 -7.04733 0.153667 0 0 0

334 rows × 15 columns

In [116]:
invest=mult_funny.query('p_value>=0.95 & cond1==0 | p_value<=0.05 & cond1==0')
print(invest.shape[0])
invest
13
Out[116]:
index level_1 top1 top2 top3 top4 top5 mult p_value sec_1 sec_2 sec_3 sec_4 sec_5 cond1
7 29 ACN EVH FOSL CTL LPI TVTY 3.5 0.0398402 -0.632667 -1.006 0.266733 -0.216433 0 0
44 273 BKU CVLT APPN OLN SGMS ATKR 3.5 0.013378 -2.13167 -2.33563 0.6425 -1.93067 0 0
55 329 CALM AKRX ESV NE GTHX UNT 3.5 0.0384572 -0.266167 -0.145667 0.0943333 0.527333 0 0
85 464 COMM ZUO EXC EXPO EXPE EXPD 2.5 0.00844479 -2.03127 0.498167 -0.382 0 0 0
95 533 CVCO JBT SPSC PSTG EXPO ZBRA 2.5 0.00917286 5.56217 -3.62383 1.95967 0 0 0
127 763 FIVE CHGG IAC NKE MRTX AFL 2.5 0.0110842 -2.19083 -4.68633 0.00483333 0 0 0
155 923 HL WDFC ZUO EXEL EXPO EXPE 2.5 0.0430847 -5.122 -2.03127 0.956033 0 0 0
224 1347 NG ZUO EXR EXPO EXPE EXPD 2.5 0.00945872 -2.03127 2.587 -0.382 0 0 0
226 1391 NUS SKY GMED JNJ ETH ALB 2.5 0.0235211 0.8125 0.771 -1.706 0 0 0
231 1403 NWL JNJ GMED MATX DK ALB 2.5 0.0490971 -1.706 0.771 1.78367 0 0 0
271 1563 PTC ZUO EXEL EXPO EXPE EXPD 2.5 0.0128242 -2.03127 0.956033 -0.382 0 0 0
304 1731 SINA ZUO EXEL EXPO EXPE EXPD 3.5 0.00756979 -2.03127 0.956033 -0.382 -0.018 0 0
319 1833 SYMC ZUO EXC EXPE EXPD EXP 2.5 0.0195262 -2.03127 0.498167 -0.018 0 0 0
In [95]:
short=np.array
longy=np.array
lg=np.array
sh=np.array
for a in range(0,invest.shape[0]):
    for b in range(1,5):
        if invest.iat[a,b+8]<0:
            short=np.append(short,invest.iat[a,b])
        elif invest.iat[a,b+8]>0:
            longy=np.append(longy,invest.iat[a,b])
                
print(short)
print(longy)
short1=list(set(short[1:]))
long1=list(set(longy[1:]))
print(short1)
print(long1)
[<built-in function array> u'ACN' u'EVH' u'CTL' u'BKU' u'CVLT' u'OLN'
 u'CALM' u'AKRX' u'COMM' u'EXC' u'JBT' u'FIVE' u'CHGG' u'HL' u'WDFC' u'NG'
 u'EXR' u'GMED' u'NWL' u'PTC' u'EXEL' u'SINA' u'EXEL' u'EXPO' u'SYMC'
 u'EXC']
[<built-in function array> u'FOSL' u'APPN' u'ESV' u'NE' u'ZUO' u'CVCO'
 u'SPSC' u'IAC' u'ZUO' u'ZUO' u'NUS' u'SKY' u'JNJ' u'GMED' u'ZUO' u'ZUO'
 u'ZUO']
[u'EVH', u'JBT', u'EXC', u'WDFC', u'ACN', u'CHGG', u'EXR', u'HL', u'CTL', u'SINA', u'CVLT', u'PTC', u'OLN', u'NG', u'BKU', u'EXPO', u'NWL', u'SYMC', u'AKRX', u'EXEL', u'COMM', u'GMED', u'CALM', u'FIVE']
[u'ESV', u'FOSL', u'CVCO', u'GMED', u'SKY', u'NE', u'IAC', u'NUS', u'APPN', u'JNJ', u'ZUO', u'SPSC']
In [114]:
#append a new row each day

def append_data():

    #calculate returns
    price = USEquityPricing.close.latest
    benchmark = morningstar.company_reference.primary_symbol.latest != 'SPY'
    market_cap =  Fundamentals.market_cap.latest 
    universe = (QTradableStocksUS()
               & benchmark) #& russell_2000)

    # Return Pipeline containing close_price
    # and sentiment_score
    return Pipeline(
        columns={'price':price,
                 'Market_cap':market_cap
            },
        screen=universe
    )

# Import run_pipeline method
from quantopian.research import run_pipeline
# Execute pipeline created by make_pipeline
# between start_date and end_date
pipeline_output = run_pipeline(
    append_data(),
    start_date=date.today(),
    end_date=date.today()
)

df = pipeline_output
df = df.reset_index()
df['level_1']=[e.symbol for e in df['level_1']]


df1a=df[['level_0','level_1','price']]
df1b =pd.pivot_table(df1a,index='level_0', columns=['level_1'],aggfunc = max)
#remove top level of multiindex
df1b.columns = df1b.columns.droplevel(0)
df1b = df1b.reset_index()    

recent = df1b.iloc[df1b.shape[0]-1,1:]
recent = recent.dropna()
recent = recent.reset_index()
columns=np.array(recent['level_1'])
new=df1b[columns]
df2=df2.append(new,ignore_index=True)
df2
Out[114]:
A AA AABA AAL AAN AAON AAPL AAT AAWW AAXN ... ZEN ZGNX ZION ZIOP ZNGA ZS ZTS ZUMZ ZUO index
0 67.750 36.390 62.450 36.870 50.650 43.840 208.50 39.050 56.160 50.66 ... 55.55 43.350 50.420 NaN 3.800 NaN 94.900 21.63 NaN 0.0
1 67.290 34.360 60.980 36.220 49.580 43.260 204.47 39.390 54.430 52.27 ... 54.39 40.750 50.140 NaN 3.620 NaN 95.260 21.08 NaN 1.0
2 64.500 33.730 59.930 36.875 49.060 42.950 194.20 39.230 53.230 50.00 ... 53.19 40.870 49.140 NaN 3.550 NaN 94.460 21.24 NaN 2.0
3 64.340 34.700 61.270 37.770 49.750 43.140 192.23 39.340 54.780 50.30 ... 52.56 39.970 48.900 NaN 3.530 NaN 94.180 21.04 NaN 3.0
4 63.480 35.150 62.310 38.100 48.970 41.500 186.80 39.250 54.320 49.62 ... 53.11 39.240 47.850 NaN 3.505 NaN 92.500 20.87 NaN 4.0
5 64.770 35.940 64.400 37.810 49.650 40.950 191.41 38.740 55.230 49.49 ... 55.99 39.870 48.340 NaN 3.570 NaN 91.630 20.92 NaN 5.0
6 64.990 35.940 63.590 36.740 50.160 39.260 193.52 39.220 54.170 49.95 ... 55.10 40.750 48.420 NaN 3.600 NaN 92.144 20.91 NaN 6.0
7 62.610 33.490 62.210 35.820 48.720 39.000 185.85 39.910 52.750 47.00 ... 48.36 40.290 48.510 NaN 3.440 NaN 90.090 19.98 NaN 7.0
8 67.500 32.680 60.900 35.590 48.080 36.550 176.94 39.530 50.370 45.19 ... 49.37 40.330 47.380 NaN 3.490 NaN 88.420 19.16 NaN 8.0
9 67.730 32.800 62.170 36.300 48.240 36.790 176.76 39.550 50.350 46.74 ... 51.76 41.590 47.120 3.310 3.500 NaN 88.680 19.67 NaN 9.0
10 68.240 32.300 62.390 37.940 48.530 37.410 172.29 39.410 50.686 46.59 ... 53.09 42.470 47.020 3.410 3.495 NaN 89.270 19.00 NaN 10.0
11 69.250 32.560 64.380 38.090 48.680 38.010 174.63 39.630 51.510 46.86 ... 54.15 42.150 48.070 3.530 3.540 NaN 89.540 19.46 NaN 11.0
12 69.380 31.210 64.160 38.290 47.160 37.430 174.25 40.100 51.220 46.52 ... 52.55 40.080 47.920 3.460 3.510 NaN 90.230 19.23 NaN 12.0
13 71.450 33.600 65.410 38.940 47.110 38.250 180.96 40.900 53.500 45.38 ... 57.44 40.540 48.310 3.620 3.600 NaN 92.810 19.25 NaN 13.0
14 71.570 30.990 64.380 38.410 47.540 38.090 179.55 40.760 52.650 44.07 ... 58.27 41.240 48.210 3.290 3.640 37.600 92.760 19.20 NaN 14.0
15 72.370 31.820 65.650 40.170 46.800 37.980 178.60 41.630 53.295 43.48 ... 59.43 41.100 48.660 3.345 3.620 39.260 93.860 19.72 NaN 15.0
16 74.670 32.060 66.820 39.640 47.120 38.790 184.82 41.910 54.545 45.13 ... 61.39 43.320 48.390 3.340 3.640 39.100 93.560 19.86 NaN 16.0
17 72.910 30.410 64.800 36.690 44.140 36.330 176.71 41.490 50.760 43.64 ... 58.45 43.870 45.890 3.155 3.540 37.210 90.630 19.22 NaN 17.0
18 71.890 29.640 63.810 36.940 44.490 35.680 174.76 42.810 51.830 44.50 ... 59.88 43.595 45.900 3.255 3.630 42.900 90.420 19.26 NaN 18.0
19 70.230 28.810 62.990 33.560 43.900 35.110 168.39 42.200 50.030 43.54 ... 58.43 42.510 45.110 3.100 3.610 40.390 88.060 18.32 NaN 19.0
20 70.570 28.310 62.220 33.840 43.770 35.050 169.61 41.640 48.570 44.30 ... 58.62 43.080 44.230 3.090 3.670 40.560 88.920 18.71 NaN 20.0
21 71.050 28.430 62.550 34.110 43.650 35.450 168.63 41.620 47.800 44.18 ... 58.50 43.670 43.450 3.180 3.650 39.740 89.830 18.71 NaN 21.0
22 71.740 29.240 62.850 34.350 43.480 35.900 169.09 41.140 48.570 45.59 ... 60.60 43.940 43.720 2.960 3.770 41.230 90.730 18.80 NaN 22.0
23 71.140 29.090 62.740 32.450 41.930 35.820 170.84 41.920 46.510 45.13 ... 61.14 41.870 42.490 2.910 3.725 41.840 90.940 18.32 NaN 23.0
24 69.380 28.610 61.970 32.410 41.295 35.300 165.40 41.710 45.260 44.64 ... 59.86 41.420 41.530 2.850 3.705 42.460 88.460 19.03 NaN 24.0
25 67.860 28.105 60.080 32.040 40.550 34.320 164.21 40.610 42.650 43.81 ... 55.89 39.850 41.200 2.655 3.710 38.270 84.930 19.18 NaN 25.0
26 67.990 28.250 59.080 33.560 42.915 34.650 165.89 41.060 42.110 44.45 ... 55.43 37.720 40.770 2.420 3.680 39.570 84.980 18.99 NaN 26.0
27 66.810 27.640 57.690 32.420 42.230 33.680 160.76 40.470 39.200 44.86 ... 55.81 37.350 40.130 2.270 3.690 39.320 83.410 18.63 NaN 27.0
28 65.150 27.335 56.710 31.890 41.960 33.930 156.90 40.350 38.760 41.37 ... 53.62 35.970 39.740 2.135 3.590 37.230 82.400 18.49 NaN 28.0
29 63.240 26.390 55.630 30.740 40.780 32.770 150.76 40.190 36.870 41.82 ... 51.28 34.130 39.040 1.990 3.630 34.920 81.670 17.96 NaN 29.0
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
73 79.420 30.970 74.706 35.690 54.360 41.550 174.88 43.320 54.540 55.46 ... 79.26 51.790 51.090 2.960 5.150 50.730 93.800 24.80 24.550 73.0
74 79.440 29.500 74.580 35.640 54.300 39.930 173.20 43.440 53.700 53.83 ... 78.99 52.740 51.100 2.940 5.210 49.680 94.240 24.71 23.760 74.0
75 81.260 29.665 74.980 34.640 54.850 41.250 174.97 43.810 54.000 54.45 ... 80.29 54.000 51.150 2.880 5.340 60.500 95.760 25.33 23.410 75.0
76 80.120 29.160 76.010 33.720 54.300 41.790 175.86 43.980 51.880 51.22 ... 77.00 52.010 50.860 2.710 5.200 58.030 95.890 24.56 22.810 76.0
77 79.720 29.200 75.100 33.220 54.140 42.370 175.51 44.210 51.290 51.44 ... 77.03 52.590 50.790 2.950 5.150 57.530 95.770 24.72 22.480 77.0
78 78.760 28.260 74.800 32.760 54.030 42.430 174.51 44.770 49.920 49.98 ... 75.23 50.980 49.670 2.910 5.140 58.270 94.170 24.97 22.400 78.0
79 78.720 27.370 72.520 32.210 53.760 41.940 172.47 44.770 49.010 48.45 ... 75.91 50.780 48.710 2.960 5.070 59.170 92.550 25.36 22.980 79.0
80 77.980 26.815 71.660 31.900 52.780 41.630 172.92 45.310 48.940 46.87 ... 77.20 50.950 48.700 2.890 5.120 60.530 92.410 24.62 23.040 80.0
81 79.310 27.530 73.480 32.050 53.260 41.360 178.98 45.580 49.140 47.97 ... 79.21 52.580 48.855 3.190 5.240 63.330 94.700 24.61 23.550 81.0
82 79.940 28.435 73.580 30.915 52.590 41.620 180.94 45.520 49.290 48.32 ... 81.41 53.890 48.930 3.330 5.200 63.640 95.750 24.58 23.525 82.0
83 80.120 28.985 73.650 31.850 53.100 41.970 181.72 46.230 49.810 47.60 ... 81.70 53.000 49.120 3.440 5.365 64.840 96.960 25.33 23.620 83.0
84 80.620 27.890 73.500 32.160 53.260 41.160 183.73 46.120 50.430 47.05 ... 82.95 52.620 49.090 3.490 5.390 66.940 96.190 23.63 23.500 84.0
85 81.110 27.825 73.710 31.430 51.625 41.970 186.21 45.675 49.590 47.98 ... 82.60 51.900 49.170 3.590 5.360 67.180 96.910 24.00 23.400 85.0
86 80.970 28.640 73.800 31.390 51.750 42.800 188.03 45.670 49.890 50.02 ... 82.91 52.650 50.070 3.830 5.350 67.240 97.770 24.56 23.050 86.0
87 81.200 28.630 73.960 31.600 50.990 42.880 186.54 45.120 49.060 52.06 ... 83.88 52.590 48.980 4.045 5.310 67.900 98.725 24.29 23.430 87.0
88 80.910 28.780 73.760 30.960 50.850 42.860 188.17 44.970 47.950 52.65 ... 84.00 52.360 47.100 4.140 5.340 67.490 98.500 23.38 23.740 88.0
89 82.010 29.410 73.710 31.460 51.140 44.300 195.05 45.740 49.040 54.55 ... 85.63 54.390 46.050 4.410 5.430 69.960 99.630 23.17 24.325 89.0
90 79.000 28.110 72.000 30.580 50.180 42.370 191.06 45.110 46.660 52.06 ... 82.81 52.680 43.630 4.070 5.290 66.010 97.930 22.52 20.900 90.0
91 79.530 28.020 72.770 30.210 50.730 43.195 188.77 45.330 46.500 52.93 ... 82.71 52.210 43.760 4.000 5.310 67.810 97.950 23.48 20.388 91.0
92 80.630 27.550 72.540 30.210 50.890 43.540 186.79 45.800 47.470 53.36 ... 84.18 54.320 44.980 4.040 5.335 71.030 98.830 23.45 19.480 92.0
93 78.990 27.915 72.350 30.950 51.220 44.950 188.47 45.720 47.710 52.54 ... 82.41 54.150 44.860 3.760 5.210 69.705 98.520 23.81 19.210 93.0
94 79.690 27.990 72.490 30.900 51.890 45.860 188.71 46.290 48.190 53.86 ... 83.32 54.540 45.375 3.760 5.260 71.020 99.360 24.16 19.510 94.0
95 80.256 28.170 74.150 31.760 52.610 46.190 189.94 45.870 50.530 54.38 ... 85.01 55.010 45.420 3.860 5.340 70.930 100.670 24.89 20.020 95.0
96 81.560 29.460 73.570 32.350 53.350 46.450 191.24 46.200 51.390 55.28 ... 85.33 54.970 46.730 3.980 5.330 70.730 101.540 25.35 19.670 96.0
97 81.140 28.540 73.940 33.000 52.410 45.290 194.04 46.390 50.500 54.38 ... 86.26 53.920 46.930 4.000 5.410 70.900 102.010 24.89 20.260 97.0
98 81.920 28.680 72.760 33.710 52.870 45.780 195.35 46.380 50.450 55.39 ... 85.43 52.690 47.160 4.130 5.450 69.340 102.110 24.85 20.540 98.0
99 80.850 29.290 73.250 33.930 53.020 45.810 195.72 46.410 50.860 55.10 ... 82.10 51.510 47.680 4.320 5.350 63.270 102.000 25.97 20.140 99.0
100 81.480 29.550 74.050 34.060 53.510 46.010 196.97 46.760 50.435 57.74 ... 81.70 51.970 47.580 4.425 5.350 63.130 102.120 26.30 20.160 100.0
101 81.450 29.110 75.620 33.330 52.900 44.810 199.50 45.520 49.110 58.67 ... 82.61 39.950 46.900 4.150 5.390 64.980 101.480 26.23 19.680 0.0
102 81.450 29.110 75.620 33.330 52.900 44.810 199.50 45.520 49.110 58.67 ... 82.61 39.950 46.900 4.150 5.390 64.980 101.480 26.23 19.680 NaN

103 rows × 2154 columns