In [4]:
import numpy as np
import pandas as pd
import seaborn as sns
sns.set_context('talk')
In [5]:
import matplotlib.pyplot as plt
%matplotlib inline
In [6]:
hft = pd.read_hdf('HFT_SR_RM_MA_TA.hdf')
In [7]:
hft.head
Out[7]:
In [8]:
hft.items
Out[8]:
In [9]:
# output cols to csv
cols = hft.items
cols = np.array(cols).astype(str)
np.savetxt('cols.csv', cols, delimiter=',', fmt='%s')
In [10]:
hft.major_axis
Out[10]:
In [11]:
hft.minor_axis
Out[11]:
In [113]:
night_len = int(4*3600*2.5)
mor_len = int(4*3600*2.25)
aftn_len = int(4*3600*1.5)
In [29]:
mor_len
Out[29]:
In [14]:
rm = hft.minor_xs('RM0001')
type(rm)
Out[14]:
In [15]:
rm.iloc[:5, :12]
Out[15]:
In [16]:
rm.iloc[:5, 12:24]
Out[16]:
In [17]:
rm.iloc[:5, 24:]
Out[17]:
In [18]:
for col, ser in rm.iteritems():
print col, ser.dtype, ser.std(axis=0)
#ser.plot(marker='*', linestyle='-')
#plt.show()
In [22]:
rm_20 = rm.ix[night_len + mor_len + aftn_len + 1: night_len + mor_len + aftn_len +night_len + mor_len + aftn_len, :]
for col, ser in rm_20.iteritems():
print col, ser.dtype, ser.std(axis=0)
print ser.mean(axis=0)
#ser.plot(marker='*', linestyle='-')
#plt.show()
In [24]:
rm_20['last'].plot()
Out[24]:
In [28]:
rm.ix[night_len + mor_len, :]
Out[28]:
In [120]:
rm.ix['2015-11-20 14:59:00': '2015-11-23 09:01:00', 'last'].plot()
Out[120]:
In [122]:
rm_23 = rm.ix['2015-11-22 21:00:00': '2015-11-23 15:00:00', :]
rm_23.describe()
Out[122]:
In [95]:
rm_1min = rm.ix[::240, :]
rm_1min.head()
Out[95]:
In [128]:
rm_1min_last = rm_1min.ix[:, 'last']
rm_1min_lastd = rm_1min_last.diff()
rm_1min_lastd
Out[128]:
In [133]:
rm_23_1min_lastd = rm_1min_lastd.ix['2015-11-22 21:00:00': '2015-11-23 15:00:00']
rm_23_1min_lastd.hist(bins=50)
Out[133]:
In [68]:
for i in xrange(len(inde) - 1):
if (inde[i + 1] - inde[i] != pd.Timedelta(250, 'ms')
and inde[i].strftime('%T') != '23:30:00'
and inde[i].strftime('%T') != '10:15:00'
and inde[i].strftime('%T') != '11:30:00'
and inde[i].strftime('%T') != '15:00:00'):
print inde[i], inde[i+1]
In [83]:
np.where(np.array(inde) == np.datetime64('2015-11-20T11:30:00.000000000+0000'))
Out[83]:
In [89]:
suspect1 = rm.ix['2015-11-20 09:00:00.000000': '2015-11-20 10:15:00.000000', :]
suspect2 = rm.ix['2015-11-20 10:30:00.000000': '2015-11-20 11:30:00.000000', :]
In [90]:
suspect1.index
Out[90]:
In [91]:
suspect2.index
Out[91]:
In [ ]: