In [1]:
# 啟動互動式繪圖環境
%pylab inline


Populating the interactive namespace from numpy and matplotlib

In [2]:
# 引入相依套件
import collections
import math
import numpy as np
import pandas as pd
from numpy import random
import matplotlib.pyplot as plt
# 引入檔案
# 資料來源 3008 大立光 2012-8/1 ~ 2014-12/09
# http://www.twse.com.tw/ch/trading/exchange/STOCK_DAY/genpage/Report201412/201412_F3_1_8_3008.php?STK_NO=3008&myear=2014&mmon=12
datapath = '/Users/wy/Desktop/2498.txt'
data = pd.read_csv(datapath)

In [3]:
data.head()


Out[3]:
Date Open High Low Close Volume Adj Close
0 2015-01-09 148.0 149.0 146.0 148 13119299 147.50
1 2015-01-08 145.5 149.0 145.5 146 19422441 146.00
2 2015-01-07 143.0 145.0 142.0 144 12009016 143.50
3 2015-01-06 141.5 144.0 141.0 141 8793568 141.00
4 2015-01-05 142.0 144.5 140.0 143 7991734 143.00

In [4]:
# data詳細資料 總數,平均數,標準差...
data.describe()


Out[4]:
Open High Low Close Volume
count 606.000000 606.000000 606.000000 606.000000 606.000000
mean 189.757426 192.472772 186.847360 189.207096 13312720.207921
std 62.105493 63.042512 61.103646 61.922282 8112484.807057
min 121.500000 124.500000 118.000000 121.500000 2000165.000000
25% 137.000000 139.000000 135.000000 136.625000 7418298.750000
50% 154.000000 156.000000 152.500000 153.500000 11224212.500000
75% 254.875000 258.375000 250.375000 254.000000 17196287.500000
max 320.000000 325.000000 311.000000 318.000000 52764106.000000

In [5]:
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.plot(data['Close'])
ax.set_title('Close')


Out[5]:
<matplotlib.text.Text at 0x10795d110>

In [6]:
# data[data['Close'] < 3]

In [7]:
# 技術分析資料來源
# http://hymar.myweb.hinet.net/study/stock/theory/

In [8]:
# Rise Ratio label
def RRlabel(data):
    # 由於 data 新到舊 0~xxx,遞增,因此需反轉陣列
    dataList = range(data['Date'].size-1)
    dataList.reverse()
    tmpList = []
    
    for item in dataList:
        # 防止 第一筆data沒有更舊的
        if item >=0:
            # (今日收盤價 - 昨日收盤價)/昨日收盤價
            tmp = (data['Close'][item]-data['Close'][item+1])/data['Close'][item+1]*100
            if tmp > 0:
                tmp = 1
            else:
                tmp = -1
#         if item >=0:
#             # (今日收盤價 - 昨日收盤價)/昨日收盤價
#             tmp = (data['Close'][item]-data['Close'][item+1])/data['Close'][item+1]*100
#             if tmp > 0. and tmp < 2.:
#                 tmp = 1
#             elif tmp >= 2.:
#                 tmp= 2
#             elif tmp > -2. and tmp < 0.:
#                 tmp = -1
#             elif tmp <= -2.:
#                 tmp = -2
#             else:
#                 tmp = 0
            tmpList.append(tmp)
        
    # 前day 沒data會出現NA
    tmpList.append('NaN')
    tmpList.reverse()
    tmpSeries = pd.Series(tmpList)
    
    # create  RR 欄位
    data['RRlabel']=tmpSeries

In [9]:
# Rise Ratio 漲幅比
def RR(data):
    # 由於 data 新到舊 0~xxx,遞增,因此需反轉陣列
    dataList = range(data['Date'].size)
    dataList.reverse()
    tmpList = []
    
    for item in dataList:
        # 防止 第一筆data沒有更舊的
        if item-1 >=0:
            # (今日收盤價 - 昨日收盤價)/昨日收盤價
            tmp = (data['Close'][item-1]-data['Close'][item])/data['Close'][item]*100
            tmpList.append(tmp)
        
    # 前day 沒data會出現NA
    tmpList.reverse()
    tmpSeries = pd.Series(tmpList)
    
    # create  RR 欄位
    data['RR']=tmpSeries

In [10]:
# 威廉指標(WMS%R或%R)
def WMS(data,day):
    # 由於 data 新到舊 0~xxx,遞增,因此需反轉陣列
    dataList = range(data['Date'].size)
    dataList.reverse()
    tmpList = []
    
    for item in dataList:
        # 防止前day沒有data
        if item-day+1 >= 0:
            # 9日WMS%R =(9日內最高價-第9日收盤價) / (9日內最高價-9日內最低價)*100
            # [item-day+1:item+1] 今日區間 [item-day+1] 第N日 583-9=574+1=575
            tmp = (data['High'][item-day+1:item+1].max()-data['Close'][item-day+1])/(data['High'][item-day+1:item+1].max()-data['Low'][item-day+1:item+1].min())*100
            tmpList.append(tmp)
        
    # 前day 沒data會出現NA
    tmpList.reverse()
    tmpSeries = pd.Series(tmpList)
    
    # create  WMS 欄位
    data['WMS'+str(day)]=tmpSeries

In [11]:
# 買賣意願指標 day 建議26
def BR(data,day):
    # 由於 data 新到舊 0~xxx,遞增,因此需反轉陣列
    dataList = range(data['Date'].size)
    dataList.reverse()
    tmpList = []
    
    for item in dataList:
        # 防止前day沒有data
        if item-day >= 0:
            # 26日BR = (今日最高價 - 昨日收盤價)26天累計總數 / (昨日收盤價 - 今日最低價)26天累計總數
            # [(item-day+1)-1:(item+1)-1] 有-1 今日區間 [(item-day+1):(item+1)] 昨日區間
            tmp = (data['High'][(item-day+1)-1:(item+1)-1].sum()-data['Close'][item-day+1:item+1].sum())/(data['Close'][item-day+1:item+1].sum()-data['Low'][(item-day+1)-1:(item+1)-1].sum())
            tmpList.append(tmp)
        
    # 前day 沒data會出現NA
    tmpList.reverse()
    tmpSeries = pd.Series(tmpList)
    
    # create  BR 欄位
    data['BR'+str(day)]=tmpSeries

In [12]:
# 買賣氣勢指標 day建議26
def AR(data,day):
    # 由於 data 新到舊 0~xxx,遞增,因此需反轉陣列
    dataList = range(data['Date'].size)
    dataList.reverse()
    tmpList = []
    
    for item in dataList:
        # 防止前day沒有data
        if item-day+1 >= 0:
            # 26日AR = (最高價 - 開盤價)26天累計總數 / (開盤價 - 最低價)26天累計總數
            # [item-day+1:item+1] 今日區間
            tmp = (data['High'][item-day+1:item+1].sum()-data['Open'][item-day+1:item+1].sum())/(data['Open'][item-day+1:item+1].sum()-data['Low'][item-day+1:item+1].sum())
            tmpList.append(tmp)
        
    # 前day 沒data會出現NA
    tmpList.reverse()
    tmpSeries = pd.Series(tmpList)
    
    # create  AR 欄位
    data['AR'+str(day)]=tmpSeries

In [13]:
# 平均成交量 mean volumn day建議 5 10 20 
def MV(data,day):
    # 由於 data 新到舊 0~xxx,遞增,因此需反轉陣列
    dataList = range(data['Date'].size)
    dataList.reverse()
    tmpList = []
    
    for item in dataList:
        # 防止前day沒有data
        if item-day+1 >= 0:
            # N日平均量 = N日內的成交量總和 / N
            # [item-day+1:item+1] 今日區間
            tmp = data['Volume'][item-day+1:item+1].mean()
            tmpList.append(tmp)
        
    # 前day 沒data會出現NA
    tmpList.reverse()
    tmpSeries = pd.Series(tmpList)
    
    # create  MV 欄位
    data['MV'+str(day)]=tmpSeries

In [14]:
# 移動平均線(MA,Moving Average) 建議 5 10 20 
def MA(data,day):
    # 由於 data 新到舊 0~xxx,遞增,因此需反轉陣列
    dataList = range(data['Date'].size)
    dataList.reverse()
    tmpList = []
    
    for item in dataList:
        # 防止前day沒有data
        if item-day+1 >= 0:
            # 移動平均數 = 採樣天數的股價合計 / 採樣天數
            # [item-day+1:item+1] 今日區間
            tmp = data['Close'][item-day+1:item+1].mean()
            tmpList.append(tmp)
        
    # 前day 沒data會出現NA
    tmpList.reverse()
    tmpSeries = pd.Series(tmpList)
    
    # create  MA 欄位
    data['MA'+str(day)]=tmpSeries

In [15]:
# 心理線(PSY) 建議13
def PSY(data,day):
    # 由於 data 新到舊 0~xxx,遞增,因此需反轉陣列
    dataList = range(data['Date'].size)
    dataList.reverse()
    tmpList = []
    
    for item in dataList:
        # 防止前day沒有data
        if item-day >= 0:
            # 13日PSY值 = ( 13日內之上漲天數 / 13 ) * 100
            # [item-day+1-1:item+1-1] 跳一天 最早的天沒有RR值
            count = 0
            for a in data['RR'][item-day+1-1:item+1-1]:
                if a > 0:
                    count+=1
            tmp = float(count)/float(13)*100
            tmpList.append(tmp)
        
    # 前day 沒data會出現NA
    tmpList.reverse()
    tmpSeries = pd.Series(tmpList)
    
    # create  PSY 欄位
    data['PSY'+str(day)]=tmpSeries

In [16]:
# 能量潮(OBV) 建議12
def OBV(data,day):
    # 由於 data 新到舊 0~xxx,遞增,因此需反轉陣列
    dataList = range(data['Date'].size)
    dataList.reverse()
    tmpList = []
    
    for item in dataList:
        # 防止前day沒有data
        if item-day >= 0:
            # 今日OBV值 = 最近12天股價上漲日成交量總和 - 最近12天股價下跌日成交量總和
            # 先由 ['RR'] 求出boolean值 > 0 True 套入['Volume']符合True全加起來
            bolRise = data['RR'][item-day+1-1:item+1-1]>0
            sumVolRise = data['Volume'][item-day+1-1:item+1-1][bolRise].sum() 
            bolDesc = data['RR'][item-day+1-1:item+1-1]<0
            sumVolDesc = data['Volume'][item-day+1-1:item+1-1][bolDesc].sum()   
            
            tmp = sumVolRise-sumVolDesc
#             可切換 OBV累積12日移動平均值 = (最近12天股價上漲日成交量總和 - 最近12天股價下跌日成交量總和) / 12
#             tmp = (sumVolRise-sumVolDesc)/12
            tmpList.append(tmp)
            
    # 前day 沒data會出現NA
    tmpList.reverse()
    tmpSeries = pd.Series(tmpList)
    
    # create  OBV 欄位
    data['OBV'+str(day)]=tmpSeries

In [17]:
# 數量指標(VR) 建議12
def VR(data,day):
    # 由於 data 新到舊 0~xxx,遞增,因此需反轉陣列
    dataList = range(data['Date'].size)
    dataList.reverse()
    tmpList = []
    
    for item in dataList:
        # 防止前day沒有data
        if item-day >= 0:
            # VR = ( N日內上漲日成交值總和 + 1/2*N日內平盤日成交值總和) / ( N日內下跌日成交值總和 + 1/2*N日內平盤日成交值總和)* 100%
            # 先由 ['RR'] 求出boolean值 > 0 True 套入['Volume']符合True全加起來
            bolRise = data['RR'][item-day+1-1:item+1-1]>0
            sumVolRise = data['Volume'][item-day+1-1:item+1-1][bolRise].sum()
            
            bolNorm = data['RR'][item-day+1-1:item+1-1] == 0
            sumVolNorm = data['Volume'][item-day+1-1:item+1-1][bolNorm].sum()
            
            bolDesc = data['RR'][item-day+1-1:item+1-1]<0
            sumVolDesc = data['Volume'][item-day+1-1:item+1-1][bolDesc].sum()   
            
            tmp = (sumVolRise+0.5*sumVolNorm)/(sumVolDesc+0.5*sumVolNorm)*100
            tmpList.append(tmp)
            
    # 前day 沒data會出現NA
    tmpList.reverse()
    tmpSeries = pd.Series(tmpList)
    
    # create  VR 欄位
    data['VR'+str(day)]=tmpSeries

In [18]:
# 相對強弱指標(RSI) 建議6 12 28
def RSI(data,day):
    # 由於 data 新到舊 0~xxx,遞增,因此需反轉陣列
    dataList = range(data['Date'].size)
    dataList.reverse()
    tmpList = []
    
    for item in dataList:
        # 防止前day沒有data
        if item-day >= 0:
            # 6日RSI=100*6日內收盤上漲總幅度平均值 / (6日內收盤上漲總幅度平均值 - 6日內收盤下跌總幅度平均值)
            # 先由 ['RR'] 求出boolean值 > 0 True 套入['Volume']符合True全加起來
            bolRise = data['RR'][item-day+1-1:item+1-1]>0
            if np.sum(bolRise) == 0:
                meanRise = 0
            else:
                meanRise = data['RR'][item-day+1-1:item+1-1][bolRise].mean()
                
            bolDesc = data['RR'][item-day+1-1:item+1-1]<0
            if np.sum(bolDesc) == 0:
                meanDesc = 0
            else:
                meanDesc = data['RR'][item-day+1-1:item+1-1][bolDesc].mean()
             
            if meanRise ==0 and meanDesc==0:
                tmp = 0
            else:
                tmp = 100*meanRise/(meanRise-meanDesc)
            tmpList.append(tmp)
            
    # 前day 沒data會出現NA
    tmpList.reverse()
    tmpSeries = pd.Series(tmpList)
    
    # create  RSI 欄位
    data['RSI'+str(day)]=tmpSeries

In [19]:
# 乖離率(BIAS) 10,20
def BIAS(data,day):
    # 由於 data 新到舊 0~xxx,遞增,因此需反轉陣列
    dataList = range(data['Date'].size)
    dataList.reverse()
    tmpList = []
    
    for item in dataList:
        # 防止前day沒有data
        if item-day+1 >= 0:
            # N日乖離率 = (當日股價 - N日股價移動平均數) / N日平均股價
            tmp = (data['Close'][item-day+1]-data['MA'+str(day)][item-day+1])/data['MA'+str(day)][item-day+1]*100
            tmpList.append(tmp)
        
    # 前day 沒data會出現NA
    tmpList.reverse()
    tmpSeries = pd.Series(tmpList)
    
    # create  BIAS 欄位
    data['BIAS'+str(day)]=tmpSeries

In [20]:
# RR漲幅比須先算出來,後續指標需用到此項
RR(data)
RRlabel(data)
WMS(data,9)
BR(data,26)
AR(data,26)
MV(data,5)
MV(data,10)
MV(data,20)
MA(data,5)
MA(data,10)
MA(data,20)
# 算BIAS須先求出MA值
BIAS(data,5)
BIAS(data,10)
BIAS(data,20)
PSY(data,13)
OBV(data,12)
VR(data,12)
VR(data,26)
RSI(data,6)
RSI(data,12)
RSI(data,28)

In [21]:
slicenum = 28
slicedata = data.head(data['Date'].size-slicenum)

In [22]:
slicedata.head()
slicedata = slicedata[1:]

In [23]:
tt = slicedata.describe()
datapath = '/Users/wy/Desktop/describe.csv'
tt.to_csv(datapath, encoding='utf-8')

In [24]:
# s19 = slicedata['RR']
# s20 = slicedata['RRlabel']
# s1 = slicedata['MV5']
# s2 = slicedata['MV10']
# s3 = slicedata['MV20']
# s4 = slicedata['MA5']
# s5 = slicedata['MA10']
# s6 = slicedata['MA20']
# s7 = slicedata['WMS9']
# s8 = slicedata['BR26']
# s9 = slicedata['AR26']
# s10 = slicedata['PSY13']
# s11 = slicedata['VR12']
# s12 = slicedata['BIAS5']
# s13 = slicedata['BIAS10']
# s14 = slicedata['BIAS20']
# s15 = slicedata['OBV12']
# s16 = slicedata['RSI6']
# s17 = slicedata['RSI12']
# s18 = slicedata['RSI28']
# tt = dict(MV5=s1,MV10=s2,MV20=s3,MA5=s4,MA10=s5,MA20=s6,WMS9=s7,BR26=s8,AR26=s9,PSY13=s10,VR12=s11,BIAS5=s12,BIAS10=s13,BIAS20=s14,OBV12=s15,RSI6=s16,RSI12=s17,RSI28=s18,RR=s19,RRlabel=s20)
# tt = pd.DataFrame(tt)
# alltmpList=[]
# for index, row in tt.iterrows():
#     tmpList=[]
#     row[1:] = map(float,row[1:])
#     stmin = row[1:].min()
#     stmax = float(row[1:].max())
#     for item in row[1:]:
#         tmp = (float(item) - stmin)/(stmax - stmin)
#         tmpList.append(tmp)
#     alltmpList.append(tmpList)
# pd.DataFrame(alltmpList)

In [25]:
# Min-max normalization
def minmax_normalization(slicedata,row):
    dataList = range(slicedata[row].size)
    tmpList = []
    
    for item in dataList:
        tmp = (slicedata[row][item] - slicedata[row].min())/(slicedata[row].max() - slicedata[row].min())
        tmpList.append(tmp)
        
    tmpSeries = pd.Series(tmpList)
    # create  'minmaxN'+row 欄位
    slicedata['minmaxN'+row]=tmpSeries

In [26]:
# z-score normalization
def zscore_normalization(slicedata,row):
    dataList = range(slicedata[row].size)
    tmpList = []
    
    for item in dataList:
        tmp = (slicedata[row][item] - slicedata[row].mean())/slicedata[row].std()
        tmpList.append(tmp)
        
    tmpSeries = pd.Series(tmpList)
    # create  'zscoreN'+row 欄位
    slicedata['zscoreN'+row]=tmpSeries

In [27]:
# log normalization
# data 皆大於0才可使用
def log_normalization(slicedata,row,base):
    dataList = range(slicedata[row].size)
    tmpList = []
    # +1預防取log時有0
    for item in dataList:
        tmp = math.log(slicedata[row][item]+1,base)/math.log(slicedata[row].max(),base)
        tmpList.append(tmp)
        
    tmpSeries = pd.Series(tmpList)
    # create  'logN'+row 欄位
    slicedata['logN'+row]=tmpSeries

In [28]:
tl=['MV5','MV10','MV20','MA5','MA10','MA20','WMS9','BR26','AR26','PSY13','VR12','VR26']
nologtl=['BIAS5','BIAS10','BIAS20','OBV12','RSI6','RSI12','RSI28','RR']
for a in tl:
    print(a)
    log_normalization(slicedata,a,10)
    zscore_normalization(slicedata,a)
    minmax_normalization(slicedata,a)
    minmaxN = 'minmaxN'+a
    zscoreN = 'zscoreN'+a
    logN = 'logN'+a
    s1 = slicedata['Date']
    s2 = slicedata['RRlabel']
    s3 = slicedata[a]
    s4 = slicedata[minmaxN]
    s5 = slicedata[zscoreN]
    s6 = slicedata[logN]
    c = 'c_'+a
    d_minmaxN = 'd_minmaxN'+a
    e_zscoreN = 'e_zscoreN'+a
    f_logN = 'f_logN'+a
    tt={}
    tt['a_Date']=s1
    tt['b_RR']=s2
    tt[c]=s3
    tt[d_minmaxN]=s4
    tt[e_zscoreN]=s5
    tt[f_logN]=s6
    od = collections.OrderedDict(sorted(tt.items()))
    tt = pd.DataFrame(od)
    tt=tt[1:]
    datapath = '/Users/wy/Desktop/2498_islig_stock2/'+a+'.csv'
    tt.to_csv(datapath, encoding='utf-8')
# for a in nologtl:
#     zscore_normalization(slicedata,a)
#     minmax_normalization(slicedata,a)
#     minmaxN = 'minmaxN'+a
#     zscoreN = 'zscoreN'+a
#     s1 = slicedata['Date']
#     s2 = slicedata['RRlabel']
#     s3 = slicedata[a]
#     s4 = slicedata[minmaxN]
#     s5 = slicedata[zscoreN]
#     c = 'c_'+a
#     d_minmaxN = 'd_minmaxN'+a
#     e_zscoreN = 'e_zscoreN'+a
#     tt={}
#     tt['a_Date']=s1
#     tt['b_RRlabel']=s2
#     tt[c]=s3
#     tt[d_minmaxN]=s4
#     tt[e_zscoreN]=s5
#     od = collections.OrderedDict(sorted(tt.items()))
#     tt = pd.DataFrame(od)
#     tt=tt[1:]
#     datapath = '/Users/wy/Desktop/3008stock2/'+a+'.csv'
#     tt.to_csv(datapath, encoding='utf-8')


MV5
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-28-233ea3442fda> in <module>()
      3 for a in tl:
      4     print(a)
----> 5     log_normalization(slicedata,a,10)
      6     zscore_normalization(slicedata,a)
      7     minmax_normalization(slicedata,a)

<ipython-input-27-57c5384d5319> in log_normalization(slicedata, row, base)
      6     # +1預防取log時有0
      7     for item in dataList:
----> 8         tmp = math.log(slicedata[row][item]+1,base)/math.log(slicedata[row].max(),base)
      9         tmpList.append(tmp)
     10 

/Users/wy/anaconda/envs/condapy2.7/lib/python2.7/site-packages/pandas/core/series.pyc in __getitem__(self, key)
    482     def __getitem__(self, key):
    483         try:
--> 484             result = self.index.get_value(self, key)
    485 
    486             if not np.isscalar(result):

/Users/wy/anaconda/envs/condapy2.7/lib/python2.7/site-packages/pandas/core/index.pyc in get_value(self, series, key)
   1194 
   1195         try:
-> 1196             return self._engine.get_value(s, k)
   1197         except KeyError as e1:
   1198             if len(self) > 0 and self.inferred_type in ['integer','boolean']:

/Users/wy/anaconda/envs/condapy2.7/lib/python2.7/site-packages/pandas/index.so in pandas.index.IndexEngine.get_value (pandas/index.c:2993)()

/Users/wy/anaconda/envs/condapy2.7/lib/python2.7/site-packages/pandas/index.so in pandas.index.IndexEngine.get_value (pandas/index.c:2808)()

/Users/wy/anaconda/envs/condapy2.7/lib/python2.7/site-packages/pandas/index.so in pandas.index.IndexEngine.get_loc (pandas/index.c:3534)()

/Users/wy/anaconda/envs/condapy2.7/lib/python2.7/site-packages/pandas/hashtable.so in pandas.hashtable.Int64HashTable.get_item (pandas/hashtable.c:7035)()

/Users/wy/anaconda/envs/condapy2.7/lib/python2.7/site-packages/pandas/hashtable.so in pandas.hashtable.Int64HashTable.get_item (pandas/hashtable.c:6976)()

KeyError: 0

In [21]:
slicedata


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-21-fa4620f84910> in <module>()
----> 1 slicedata

NameError: name 'slicedata' is not defined

In [27]:
log_normalization(slicedata,'MV5',10)

In [28]:
zscore_normalization(slicedata,'BIAS5')
zscore_normalization(slicedata,'MV5')

In [29]:
minmax_normalization(slicedata,'BIAS5')
minmax_normalization(slicedata,'MV5')

In [30]:
s1 = slicedata['Date']
s2 = slicedata['RR']
s3 = slicedata['BIAS5']
s4 = slicedata['minmaxNBIAS5']
s5 = slicedata['zscoreNBIAS5']
import collections
tt = dict( a_Date = s1, b_RR = s2 , c_BIAS5 = s3 , d_minmaxNBIAS5 = s4 , e_zscoreNBIAS5 = s5) 
od = collections.OrderedDict(sorted(tt.items()))
tt = pd.DataFrame(od)
datapath = '/Users/wy/Desktop/BIAS5.csv'
tt.to_csv(datapath, encoding='utf-8')

In [31]:
tt.head()


Out[31]:
a_Date b_RR c_BIAS5 d_minmaxNBIAS5 e_zscoreNBIAS5
0 2015-01-05 -1.063830 -0.357143 0.491023 -0.366640
1 2014-12-31 0.714286 0.786276 0.570816 0.404877
2 2014-12-30 -0.709220 0.574713 0.556052 0.262126
3 2014-12-29 1.805054 1.585014 0.626556 0.943823
4 2014-12-27 -0.359712 0.289645 0.536159 0.069778

In [32]:
s1 = slicedata['Date']
s2 = slicedata['RR']
s3 = slicedata['MV5']
s4 = slicedata['minmaxNMV5']
s5 = slicedata['zscoreNMV5']
s6 = slicedata['logNMV5']
import collections
tt = dict( a_Date = s1, b_RR = s2 , c_MV5 = s3 , d_minmaxNMV5 = s4 , e_zscoreNMV5 = s5 , f_logNMV5 = s6) 
od = collections.OrderedDict(sorted(tt.items()))
tt = pd.DataFrame(od)
datapath = '/Users/wy/Desktop/MV5.csv'
tt.to_csv(datapath, encoding='utf-8')

In [33]:
b = slicedata['WMS9']==0
numpy.sum(b)


Out[33]:
56

In [449]:
%reset


Once deleted, variables cannot be recovered. Proceed (y/[n])? y

In [353]:
slicedata[slicedata['RSI28']==0]


Out[353]:
Date Open High Low Close Volume Adj Close RR WMS9 BR26 ... minmaxNBR26 logNAR26 zscoreNAR26 minmaxNAR26 logNPSY13 zscoreNPSY13 minmaxNPSY13 logNVR12 zscoreNVR12 minmaxNVR12

0 rows × 64 columns


In [417]:
slicedata['minmaxNRSI6']


Out[417]:
0    NaN
1    NaN
2    NaN
3    NaN
4    NaN
5    NaN
6    NaN
7    NaN
8    NaN
9    NaN
10   NaN
11   NaN
12   NaN
13   NaN
14   NaN
...
557   NaN
558   NaN
559   NaN
560   NaN
561   NaN
562   NaN
563   NaN
564   NaN
565   NaN
566   NaN
567   NaN
568   NaN
569   NaN
570   NaN
571   NaN
Name: minmaxNRSI6, Length: 572, dtype: float64

In [294]:
# 判斷有無NAN
slicedata[pd.isnull(slicedata['RSI28'])]


Out[294]:
Date Open High Low Close Volume Adj Close RR WMS9 BR26 ... MA20 BIAS5 BIAS10 BIAS20 PSY13 OBV12 VR12 RSI6 RSI12 RSI28
572 2012-09-10 651 654 647 654 957356 652.00 1 10.416667 1.571429 ... 625.3 1.774043 3.138306 4.589797 38.461538 4444627 162.351409 57.142857 48.275862 NaN

1 rows × 26 columns


In [232]:
slicedata[550:565]


Out[232]:
Date Open High Low Close Volume Adj Close RR WMS9 BR26 ... OBV12 VR12 RSI6 RSI12 RSI28 logNMV5 zscoreNMV5 minmaxNMV5 zscoreNBIAS5 minmaxNBIAS5
550 2012-10-11 595 611 591 611 1319080 610.00 1 31.111111 1.129944 ... -3049341 74.163059 50.000000 51.020408 51.612903 0.933772 0.165286 0.289268 -0.232203 0.471618
551 2012-10-09 610 614 598 602 1616745 602.00 -1 51.111111 1.072222 ... -4368421 63.937456 60.000000 52.631579 52.071006 0.931193 0.077541 0.273540 -0.785547 0.395364
552 2012-10-08 622 622 606 612 1536570 612.00 -1 28.888889 1.239766 ... -2751676 75.220281 60.000000 51.612903 51.677852 0.933773 0.165311 0.289273 -0.280020 0.465029
553 2012-10-05 610 625 610 625 1839539 624.00 1 39.189189 1.354037 ... -1215106 87.684361 60.000000 50.000000 50.704225 0.938659 0.341279 0.320815 0.733441 0.604690
554 2012-10-04 612 614 601 610 1044653 610.00 0 61.038961 1.202381 ... -3054645 70.578217 60.000000 52.941176 48.734177 0.934614 0.194665 0.294534 0.046569 0.510035
555 2012-10-03 611 615 608 612 1036121 611.00 0 62.790698 1.257669 ... -3054645 70.388017 50.000000 52.941176 50.276243 0.942316 0.481847 0.346012 0.204823 0.531843
556 2012-10-02 596 615 595 610 1899785 610.00 2 65.116279 1.122222 ... -840165 91.424709 52.941176 50.000000 50.276243 0.958039 1.183618 0.471806 0.280152 0.542224
557 2012-10-01 600 604 580 593 2104028 592.00 -1 84.883721 1.193182 ... 529716 105.406639 42.857143 42.857143 48.734177 0.955662 1.066459 0.450805 -1.068673 0.356348
558 2012-09-28 607 618 605 607 1366741 607.00 0 77.631579 1.403846 ... 1290443 114.279894 40.000000 42.857143 47.826087 0.945410 0.607011 0.368448 -0.920851 0.376718
559 2012-09-27 590 608 590 607 1970750 607.00 1 78.481013 1.300000 ... 3107258 137.197469 40.000000 42.857143 47.826087 0.944269 0.560165 0.360051 -1.448650 0.303984
560 2012-09-26 618 625 596 596 3299177 596.00 -2 100.000000 1.187879 ... 175868 101.888201 NaN 44.444444 48.387097 0.932867 0.134097 0.283677 -2.606882 0.144373
561 2012-09-25 654 654 632 636 1521975 636.00 -1 89.189189 1.696000 ... 4432401 173.690652 NaN 50.000000 51.020408 0.908232 -0.569020 0.157642 -0.976223 0.369088
562 2012-09-24 655 657 650 652 622410 652.00 0 65.384615 2.009259 ... 5954376 213.129144 NaN 50.000000 49.438202 0.899646 -0.758395 0.123696 -0.329494 0.458211
563 2012-09-21 656 666 652 653 1215673 653.00 0 57.142857 1.981818 ... 5954376 192.883714 NaN 50.000000 50.458716 0.920040 -0.264696 0.212193 -0.362769 0.453626
564 2012-09-20 656 658 653 654 596773 654.00 0 53.571429 2.009346 ... 6915228 219.171894 50.000000 50.000000 50.000000 0.939482 0.372245 0.326366 -0.295489 0.462897

15 rows × 31 columns


In [236]:
item=561
day=6
bolRise = data['RR'][item-day+1-1:item+1-1]>0
meanRise = data['RR'][item-day+1-1:item+1-1][bolRise].mean() 
bolDesc = data['RR'][item-day+1-1:item+1-1]<0
meanDesc = data['RR'][item-day+1-1:item+1-1][bolDesc].mean()   

tmp = 100*meanRise/(meanRise-meanDesc)

In [237]:
tmp


Out[237]:
50.0

In [477]:
minmax_normalization(slicedata,'RSI6')


86.5245840315
-inf
inf
77.4804985222
-inf
inf
64.2879776396
-inf
inf
57.5976380835
-inf
inf
50.5106673074
-inf
inf
50.5106673074
-inf
inf
28.2862196089
-inf
inf
20.388092111
-inf
inf
20.388092111
-inf
inf
22.301087931
-inf
inf
31.1801605435
-inf
inf
26.5229893206
-inf
inf
26.7272482625
-inf
inf
34.1533656884
-inf
inf
32.4293945172
-inf
inf
16.6306942632
-inf
inf
13.01263226
-inf
inf
34.1676683597
-inf
inf
32.9919762583
-inf
inf
29.6958321579
-inf
inf
33.13848716
-inf
inf
43.8505376464
-inf
inf
57.1395886909
-inf
inf
61.0008544318
-inf
inf
77.1150518525
-inf
inf
83.1736600233
-inf
inf
82.206693945
-inf
inf
84.049085797
-inf
inf
88.5763911416
-inf
inf
84.1949807912
-inf
inf
54.664921756
-inf
inf
39.7036430989
-inf
inf
38.9401733031
-inf
inf
58.1012485742
-inf
inf
56.324826988
-inf
inf
57.3183305363
-inf
inf
56.4443390683
-inf
inf
65.5955815418
-inf
inf
56.5364854142
-inf
inf
50.7804664666
-inf
inf
51.5125502611
-inf
inf
67.0577865658
-inf
inf
57.7759310204
-inf
inf
51.2048402802
-inf
inf
58.2266849318
-inf
inf
47.3860653318
-inf
inf
57.9251420979
-inf
inf
10.726391213
-inf
inf
8.53468892789
-inf
inf
64.1761749135
-inf
inf
61.8035341437
-inf
inf
65.4773966518
-inf
inf
59.288144982
-inf
inf
49.8603668609
-inf
inf
70.648502427
-inf
inf
-100.0
-inf
inf
-100.0
-inf
inf
76.465969174
-inf
inf
71.089304802
-inf
inf
65.7678112524
-inf
inf
61.6975832114
-inf
inf
72.3038415393
-inf
inf
71.5887426169
-inf
inf
51.8161628119
-inf
inf
60.1678804964
-inf
inf
71.645302912
-inf
inf
71.2522981368
-inf
inf
38.5423359239
-inf
inf
25.2341680333
-inf
inf
52.5354405788
-inf
inf
50.6911919809
-inf
inf
51.5937764645
-inf
inf
34.2878800803
-inf
inf
39.3946880066
-inf
inf
38.4996358385
-inf
inf
21.8822614154
-inf
inf
21.281338564
-inf
inf
24.6330000806
-inf
inf
38.8183452666
-inf
inf
26.9860661972
-inf
inf
33.9172003567
-inf
inf
40.6248945306
-inf
inf
42.1695356969
-inf
inf
44.1688041503
-inf
inf
58.6589716421
-inf
inf
64.8796298936
-inf
inf
69.5984576998
-inf
inf
65.1668846855
-inf
inf
66.255468058
-inf
inf
60.7793593936
-inf
inf
53.3551426067
-inf
inf
59.5534270491
-inf
inf
60.1994058397
-inf
inf
69.06784548
-inf
inf
72.2243357715
-inf
inf
68.2557926948
-inf
inf
84.2175070397
-inf
inf
78.9175799754
-inf
inf
75.8167425084
-inf
inf
55.5328390916
-inf
inf
48.2043798932
-inf
inf
59.5879511525
-inf
inf
54.2357419175
-inf
inf
53.9324268068
-inf
inf
60.9287177567
-inf
inf
71.8662623527
-inf
inf
44.9294370832
-inf
inf
43.0055847453
-inf
inf
43.1041483503
-inf
inf
60.2200040063
-inf
inf
62.5271507477
-inf
inf
59.7524282226
-inf
inf
58.1274454095
-inf
inf
44.3649520608
-inf
inf
35.655893465
-inf
inf
23.6152438168
-inf
inf
35.555201462
-inf
inf
41.699161203
-inf
inf
37.1434110879
-inf
inf
41.7420876871
-inf
inf
50.5150446013
-inf
inf
56.2578218913
-inf
inf
41.9204288902
-inf
inf
46.9749663353
-inf
inf
62.8246266637
-inf
inf
58.5193182503
-inf
inf
46.7426879073
-inf
inf
40.3128130912
-inf
inf
46.8398067203
-inf
inf
51.9614144947
-inf
inf
51.7963638562
-inf
inf
71.5049281697
-inf
inf
72.8763817243
-inf
inf
76.1931291502
-inf
inf
82.5583750122
-inf
inf
85.6009507748
-inf
inf
82.8026742365
-inf
inf
62.272192728
-inf
inf
68.1305763255
-inf
inf
62.2615622753
-inf
inf
72.9583892608
-inf
inf
65.3680296194
-inf
inf
75.5075849223
-inf
inf
69.2900119472
-inf
inf
65.8415388204
-inf
inf
58.6119492618
-inf
inf
50.3754618767
-inf
inf
54.4203508335
-inf
inf
47.3892831433
-inf
inf
63.0879546466
-inf
inf
56.9804886833
-inf
inf
61.1976268672
-inf
inf
68.1858741495
-inf
inf
71.7670165611
-inf
inf
81.2792688718
-inf
inf
74.6568161535
-inf
inf
79.5306540861
-inf
inf
72.0738400337
-inf
inf
65.881843991
-inf
inf
57.4830051947
-inf
inf
55.6095084488
-inf
inf
31.6372538173
-inf
inf
36.4212040626
-inf
inf
41.918073244
-inf
inf
62.9857972633
-inf
inf
49.5924011191
-inf
inf
44.1635311778
-inf
inf
53.168848116
-inf
inf
62.6893578903
-inf
inf
66.0372999194
-inf
inf
71.1911981029
-inf
inf
74.6140437019
-inf
inf
76.6782228831
-inf
inf
75.3568981469
-inf
inf
71.5400384781
-inf
inf
64.9199712285
-inf
inf
300.0
-inf
inf
20.1235501017
-inf
inf
20.0863828716
-inf
inf
30.1224851582
-inf
inf
35.1937897335
-inf
inf
49.7577957627
-inf
inf
57.7347044566
-inf
inf
77.7863147796
-inf
inf
81.274860332
-inf
inf
79.4945961264
-inf
inf
77.8733386013
-inf
inf
70.5116041492
-inf
inf
67.1190809491
-inf
inf
69.541273171
-inf
inf
68.0175847327
-inf
inf
64.4973019853
-inf
inf
53.5895361094
-inf
inf
47.0232767132
-inf
inf
53.5619856513
-inf
inf
56.797192537
-inf
inf
56.3977013816
-inf
inf
49.0375313151
-inf
inf
45.9604081541
-inf
inf
54.2501502142
-inf
inf
46.4283470224
-inf
inf
40.3714168388
-inf
inf
44.5996855265
-inf
inf
48.4855392561
-inf
inf
51.8478311245
-inf
inf
44.6770338423
-inf
inf
48.4489371574
-inf
inf
54.7406270405
-inf
inf
300.0
-inf
inf
79.0232505108
-inf
inf
82.5241606183
-inf
inf
85.027650354
-inf
inf
89.4458786663
-inf
inf
88.4811602919
-inf
inf
84.0192401528
-inf
inf
83.7577333718
-inf
inf
85.161932132
-inf
inf
31.8102981932
-inf
inf
50.1964730979
-inf
inf
67.0666625106
-inf
inf
62.5717912591
-inf
inf
59.9054453431
-inf
inf
42.1215188127
-inf
inf
46.5886491937
-inf
inf
40.874120029
-inf
inf
27.4537192037
-inf
inf
13.0847004513
-inf
inf
16.0969023927
-inf
inf
31.2625935448
-inf
inf
33.6078312564
-inf
inf
46.057334354
-inf
inf
49.127966274
-inf
inf
79.6320856368
-inf
inf
60.1336458977
-inf
inf
63.7590847695
-inf
inf
63.9955946108
-inf
inf
72.8715557663
-inf
inf
63.5888500174
-inf
inf
31.0947848766
-inf
inf
30.3813380088
-inf
inf
28.6174503603
-inf
inf
23.0770685714
-inf
inf
21.5352139314
-inf
inf
41.3129497321
-inf
inf
48.3545982401
-inf
inf
55.0237605204
-inf
inf
60.38049729
-inf
inf
63.9981064346
-inf
inf
71.1521381253
-inf
inf
76.3785058164
-inf
inf
67.0728630939
-inf
inf
70.0269319842
-inf
inf
71.1752102935
-inf
inf
63.2939371313
-inf
inf
64.8196623353
-inf
inf
58.6043244915
-inf
inf
59.1041783214
-inf
inf
64.315871631
-inf
inf
60.9548434432
-inf
inf
63.1101215913
-inf
inf
55.6029487018
-inf
inf
50.6669239703
-inf
inf
47.8534843219
-inf
inf
44.1082722556
-inf
inf
600.0
-inf
inf
69.030837368
-inf
inf
72.6469385965
-inf
inf
78.665406773
-inf
inf
80.3233032062
-inf
inf
80.3233032062
-inf
inf
50.9186928499
-inf
inf
48.9855199327
-inf
inf
53.7820082675
-inf
inf
51.5621423057
-inf
inf
64.3567157457
-inf
inf
55.6561918832
-inf
inf
81.8089662241
-inf
inf
84.0687416962
-inf
inf
60.1782511364
-inf
inf
39.3264794819
-inf
inf
57.3854415389
-inf
inf
61.2136948405
-inf
inf
54.84521386
-inf
inf
60.2539774875
-inf
inf
65.6812743818
-inf
inf
65.6812743818
-inf
inf
64.919775836
-inf
inf
78.1675047088
-inf
inf
80.5379073934
-inf
inf
66.4977205508
-inf
inf
65.966697648
-inf
inf
69.8568675894
-inf
inf
72.4394498215
-inf
inf
73.0925567741
-inf
inf
67.1657978459
-inf
inf
79.0107823778
-inf
inf
42.6148407969
-inf
inf
43.2122688943
-inf
inf
31.4925189187
-inf
inf
29.8282596866
-inf
inf
43.1383398655
-inf
inf
52.8907846024
-inf
inf
54.5565441956
-inf
inf
33.1723081061
-inf
inf
54.0283465228
-inf
inf
59.9740657239
-inf
inf
43.8119114682
-inf
inf
37.4653311705
-inf
inf
61.5375365447
-inf
inf
37.0397813786
-inf
inf
16.6500587198
-inf
inf
17.4470745747
-inf
inf
21.8821982809
-inf
inf
36.4134305004
-inf
inf
42.0135106894
-inf
inf
76.8093212047
-inf
inf
82.30511104
-inf
inf
87.6300925376
-inf
inf
93.1234710755
-inf
inf
80.3560264384
-inf
inf
78.7639957413
-inf
inf
-200.0
-inf
inf
-200.0
-inf
inf
29.1595826097
-inf
inf
27.1373371888
-inf
inf
31.5184009161
-inf
inf
38.7474991103
-inf
inf
45.9598177098
-inf
inf
58.4001025145
-inf
inf
62.0026665603
-inf
inf
31.1015884476
-inf
inf
34.2604378232
-inf
inf
26.2016031603
-inf
inf
25.982130714
-inf
inf
33.9126458406
-inf
inf
33.3237773223
-inf
inf
34.9924840896
-inf
inf
35.0222083443
-inf
inf
42.0582195379
-inf
inf
52.9503470987
-inf
inf
58.2412226132
-inf
inf
62.8818107496
-inf
inf
67.6977087273
-inf
inf
71.3426059115
-inf
inf
68.7820735439
-inf
inf
64.6829216252
-inf
inf
65.1957862959
-inf
inf
55.0479822661
-inf
inf
41.9285114461
-inf
inf
52.5715093462
-inf
inf
54.911198739
-inf
inf
63.718953122
-inf
inf
54.9463403538
-inf
inf
56.4336341982
-inf
inf
inf
-inf
inf
inf
-inf
inf
29.5739816837
-inf
inf
26.8192223414
-inf
inf
17.7365129997
-inf
inf
11.8192832892
-inf
inf
14.2291278599
-inf
inf
15.7938533576
-inf
inf
43.2778063408
-inf
inf
51.0047947087
-inf
inf
46.5160605589
-inf
inf
46.3688940413
-inf
inf
52.9527594965
-inf
inf
44.981806712
-inf
inf
41.7481184119
-inf
inf
45.6694031152
-inf
inf
53.6577181227
-inf
inf
55.1939173894
-inf
inf
49.4966816283
-inf
inf
67.500607465
-inf
inf
69.8214454588
-inf
inf
67.2849175808
-inf
inf
45.281458114
-inf
inf
42.8655037942
-inf
inf
32.1183064314
-inf
inf
28.9667627629
-inf
inf
34.2752832319
-inf
inf
39.1987554542
-inf
inf
40.8519710675
-inf
inf
34.6691918861
-inf
inf
54.8860992333
-inf
inf
55.3357120798
-inf
inf
64.9830839479
-inf
inf
56.8014466771
-inf
inf
64.376660515
-inf
inf
77.4325183827
-inf
inf
62.8420704069
-inf
inf
67.1225442727
-inf
inf
69.6983043804
-inf
inf
81.6879893069
-inf
inf
61.3829357056
-inf
inf
150.0
-inf
inf
35.9094145194
-inf
inf
42.1901639632
-inf
inf
49.218401612
-inf
inf
57.3742810572
-inf
inf
66.5935593213
-inf
inf
75.4633195536
-inf
inf
83.8244442673
-inf
inf
88.2045852435
-inf
inf
81.5730736453
-inf
inf
80.8398759989
-inf
inf
74.5745471016
-inf
inf
64.7100907692
-inf
inf
57.3167165675
-inf
inf
63.4833217345
-inf
inf
82.7388927181
-inf
inf
85.8753211444
-inf
inf
88.3623977517
-inf
inf
93.5515664331
-inf
inf
94.4642716492
-inf
inf
75.319397515
-inf
inf
59.2060118455
-inf
inf
67.6562029008
-inf
inf
74.1034000819
-inf
inf
73.0978950777
-inf
inf
43.2924633932
-inf
inf
47.1497105746
-inf
inf
-inf
-inf
inf
-inf
-inf
inf
-inf
-inf
inf
48.0713270947
-inf
inf
47.0349657912
-inf
inf
41.1797750218
-inf
inf
39.9813517183
-inf
inf
39.7170018315
-inf
inf
48.9687613867
-inf
inf
46.1615035415
-inf
inf
42.2025248216
-inf
inf
51.8316153186
-inf
inf
58.8434173381
-inf
inf
65.2048834497
-inf
inf
69.4738596219
-inf
inf
83.382435598
-inf
inf
87.4687438148
-inf
inf
85.9970306768
-inf
inf
83.9052146343
-inf
inf
-200.0
-inf
inf
78.4787228401
-inf
inf
59.1301745573
-inf
inf
66.8857922435
-inf
inf
61.6603701452
-inf
inf
64.6753644306
-inf
inf
71.3485947831
-inf
inf
39.1982024158
-inf
inf
-500.0
-inf
inf
27.3634537794
-inf
inf
31.1042778881
-inf
inf
37.7029483121
-inf
inf
43.842006848
-inf
inf
31.9830605991
-inf
inf
54.6679745908
-inf
inf
51.5150850146
-inf
inf
61.3500822227
-inf
inf
23.5694867196
-inf
inf
21.1983743421
-inf
inf
65.3555192848
-inf
inf
71.2919762698
-inf
inf
80.7017504172
-inf
inf
73.7127200724
-inf
inf
84.7954638521
-inf
inf
87.1861136472
-inf
inf
81.06844224
-inf
inf
71.5657484146
-inf
inf
79.6288344397
-inf
inf
76.8569393005
-inf
inf
71.8984420938
-inf
inf
69.6877157774
-inf
inf
61.850251758
-inf
inf
69.144510073
-inf
inf
47.2561761709
-inf
inf
49.9193688303
-inf
inf
34.2224195278
-inf
inf
29.7000953223
-inf
inf
30.538713523
-inf
inf
25.0173035232
-inf
inf
30.906158639
-inf
inf
36.2593230639
-inf
inf
31.3315304388
-inf
inf
35.2542934778
-inf
inf
31.6108007088
-inf
inf
32.7685392953
-inf
inf
16.9232329619
-inf
inf
56.1522059208
-inf
inf
56.4944282022
-inf
inf
57.691973951
-inf
inf
76.0251532642
-inf
inf
82.4558744613
-inf
inf
77.8616764306
-inf
inf
53.5612110378
-inf
inf
48.8904237125
-inf
inf
44.7840983027
-inf
inf
48.0925331469
-inf
inf
46.5920913374
-inf
inf
31.6484380703
-inf
inf
32.6105607368
-inf
inf
33.6049576867
-inf
inf
43.6124696748
-inf
inf
36.2135682469
-inf
inf
39.8994428527
-inf
inf
32.428096344
-inf
inf
69.4015495413
-inf
inf
71.2347123325
-inf
inf
62.8030094571
-inf
inf
55.3404104102
-inf
inf
59.1882567001
-inf
inf
59.7224199169
-inf
inf
45.6782618205
-inf
inf
58.5628769931
-inf
inf
69.1632427761
-inf
inf
87.8889379369
-inf
inf
81.9115017054
-inf
inf
83.0249144422
-inf
inf
82.0636545376
-inf
inf
77.9099900911
-inf
inf
66.5093402151
-inf
inf
57.3740961756
-inf
inf
46.9335575857
-inf
inf
44.4775070207
-inf
inf
42.0857715255
-inf
inf
27.9400781877
-inf
inf
50.6218671746
-inf
inf
68.0488003542
-inf
inf
74.7040209642
-inf
inf
72.9292706772
-inf
inf
77.8675278817
-inf
inf
75.6110591529
-inf
inf
70.9745992365
-inf
inf
60.1498693143
-inf
inf
49.3698709367
-inf
inf
73.780296437
-inf
inf
61.460466514
-inf
inf
72.4108898488
-inf
inf
77.5181406883
-inf
inf
72.0361295101
-inf
inf
71.9849269137
-inf
inf
38.9027003474
-inf
inf
34.9084120539
-inf
inf
34.0877573208
-inf
inf
24.9989205954
-inf
inf
23.1811979279
-inf
inf
28.924270414
-inf
inf
28.5754177176
-inf
inf
24.9895382451
-inf
inf
36.5622308714
-inf
inf
50.4713793482
-inf
inf
51.4485560222
-inf
inf
58.3185752999
-inf
inf
54.5357971494
-inf
inf
58.8708858971
-inf
inf
56.0647243123
-inf
inf
28.1048162565
-inf
inf
39.0136330688
-inf
inf
39.7222879746
-inf
inf
44.9281852383
-inf
inf
49.6608873249
-inf
inf
-inf
-inf
inf
-inf
-inf
inf
83.4389745428
-inf
inf
81.2880711202
-inf
inf
71.6113482867
-inf
inf
70.8460351579
-inf
inf
56.0863562357
-inf
inf
49.5969181113
-inf
inf
44.1246276241
-inf
inf
40.4052696929
-inf
inf
32.2533033512
-inf
inf
32.5067088188
-inf
inf

In [478]:
# minmaxNMV5 
# slicedata['minmaxNRSI6']
slicedata['RSI6'].min()


Out[478]:
-inf

In [476]:
slicedata[slicedata['RSI6']<-40]['RSI6']


Out[476]:
55    -100.000000
56    -100.000000
321   -200.000000
322   -200.000000
422          -inf
423          -inf
424          -inf
441   -200.000000
449   -500.000000
560          -inf
561          -inf
Name: RSI6, dtype: float64

In [428]:
slicedata['RR'][420:425]


Out[428]:
420   -2
421    1
422   -1
423   -1
424   -1
Name: RR, dtype: float64

In [479]:
data['RR']


Out[479]:
0    -0.835073
1     3.679654
2    -0.215983
3     1.758242
4     0.000000
5    -0.219298
6    -1.935484
7     1.086957
8     1.545254
9     0.666667
10    0.000000
11   -3.640257
12    0.430108
13    1.086957
14    1.995565
...
585   -0.162602
586    0.000000
587    0.000000
588   -0.324149
589    1.480263
590   -0.977199
591    0.655738
592    1.497504
593   -1.313629
594    1.839465
595    0.167504
596    0.844595
597   -4.516129
598   -0.481541
599         NaN
Name: RR, Length: 600, dtype: float64

In [ ]: