03 Monitor tables


In [154]:
#%matplotlib inline
import sqlite3
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import pandas as pd

In [155]:
in_db = 'in.db'
data_db = 'data.db'
view_db = 'view.db'

input table


In [156]:
conn = sqlite3.connect(in_db)
c = conn.cursor()
for row in c.execute('SELECT * FROM iPrice'):
    print row
conn.close()


(1, u'2015-05-30 09:15:39.485955', u'done', u'2015-05-30 13:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(2, u'2015-05-30 09:15:48.069422', u'done', u'2015-05-30 13:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(3, u'2015-05-30 09:15:55.417848', u'done', u'2015-05-30 13:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(4, u'2015-05-30 09:16:02.850010', u'done', u'2015-05-30 13:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(5, u'2015-05-30 09:16:10.257276', u'done', u'2015-05-30 13:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(6, u'2015-05-30 09:16:17.711932', u'done', u'2015-05-30 13:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(7, u'2015-05-30 09:16:25.004063', u'done', u'2015-05-30 13:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(8, u'2015-05-30 09:16:42.124534', u'done', u'2015-05-30 13:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(9, u'2015-05-30 09:17:01.656726', u'done', u'2015-05-30 13:17:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(10, u'2015-05-30 09:17:08.906095', u'done', u'2015-05-30 13:17:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(11, u'2015-05-30 09:22:54.787782', u'done', u'2015-05-30 13:21:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(12, u'2015-05-30 09:23:02.034814', u'done', u'2015-05-30 13:23:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(13, u'2015-05-30 09:23:09.305855', u'done', u'2015-05-30 13:23:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(14, u'2015-05-30 09:23:18.193639', u'done', u'2015-05-30 13:23:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(15, u'2015-05-30 09:23:25.822885', u'done', u'2015-05-30 13:23:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(16, u'2015-05-30 09:23:33.119151', u'done', u'2015-05-30 13:23:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(17, u'2015-05-30 09:23:41.924820', u'done', u'2015-05-30 13:23:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(18, u'2015-05-30 09:23:49.815168', u'done', u'2015-05-30 13:23:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(19, u'2015-05-30 09:23:57.143688', u'done', u'2015-05-30 13:23:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(20, u'2015-05-30 09:24:04.340398', u'done', u'2015-05-30 13:23:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(21, u'2015-05-30 11:15:42.775625', u'done', u'2015-05-30 15:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(22, u'2015-05-30 11:15:51.429303', u'done', u'2015-05-30 15:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(23, u'2015-05-30 11:15:58.712359', u'done', u'2015-05-30 15:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(24, u'2015-05-30 11:16:09.155449', u'done', u'2015-05-30 15:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(25, u'2015-05-30 11:16:16.865008', u'done', u'2015-05-30 15:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(26, u'2015-05-30 11:16:24.171908', u'done', u'2015-05-30 15:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(27, u'2015-05-30 11:16:31.859444', u'done', u'2015-05-30 15:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(28, u'2015-05-30 11:16:39.179710', u'done', u'2015-05-30 15:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(29, u'2015-05-30 11:16:46.792799', u'done', u'2015-05-30 15:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(30, u'2015-05-30 11:16:54.023519', u'done', u'2015-05-30 15:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(31, u'2015-05-30 13:46:54.273525', u'done', u'2015-05-30 16:55:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(32, u'2015-05-30 13:47:01.472458', u'done', u'2015-05-30 16:55:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(33, u'2015-05-30 13:47:08.713723', u'done', u'2015-05-30 16:55:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(34, u'2015-05-30 13:47:15.938801', u'done', u'2015-05-30 16:55:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(35, u'2015-05-30 13:47:23.146648', u'done', u'2015-05-30 16:55:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(36, u'2015-05-30 13:47:33.785998', u'wait', u'2015-05-30 16:55:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(37, u'2015-05-30 13:47:40.990189', u'wait', u'2015-05-30 16:55:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(38, u'2015-05-30 13:47:48.197351', u'wait', u'2015-05-30 16:55:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(39, u'2015-05-30 13:47:55.403796', u'wait', u'2015-05-30 16:55:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(40, u'2015-05-30 13:48:02.596469', u'wait', u'2015-05-30 16:55:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)

dPrice


In [157]:
conn = sqlite3.connect(data_db)
c = conn.cursor()
for row in c.execute('SELECT * FROM dPrice'):
    print row
conn.close()


(1, 1, u'2015-05-30 09:15:39.485955', u'2015-05-30 09:21:47.405673', u'2015-05-30 09:21:47.441443', u'2015-05-30 13:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.52975, 1.53)
(2, 2, u'2015-05-30 09:15:48.069422', u'2015-05-30 09:24:21.990715', u'2015-05-30 09:24:22.025171', u'2015-05-30 13:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.52975, 1.53)
(3, 3, u'2015-05-30 09:15:55.417848', u'2015-05-30 09:24:33.167984', u'2015-05-30 09:24:33.201830', u'2015-05-30 13:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.52975, 1.53)
(4, 4, u'2015-05-30 09:16:02.850010', u'2015-05-30 09:24:35.259689', u'2015-05-30 09:24:35.295610', u'2015-05-30 13:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.52975, 1.53)
(5, 5, u'2015-05-30 09:16:10.257276', u'2015-05-30 11:16:50.834372', u'2015-05-30 11:16:50.871380', u'2015-05-30 13:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.52975, 1.53)
(6, 6, u'2015-05-30 09:16:17.711932', u'2015-05-30 11:17:12.909723', u'2015-05-30 11:17:12.943839', u'2015-05-30 13:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.52975, 1.53)
(7, 7, u'2015-05-30 09:16:25.004063', u'2015-05-30 11:17:25.092175', u'2015-05-30 11:17:25.129221', u'2015-05-30 13:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.52975, 1.53)
(8, 8, u'2015-05-30 09:16:42.124534', u'2015-05-30 11:17:25.192964', u'2015-05-30 11:17:25.227434', u'2015-05-30 13:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.52975, 1.53)
(9, 9, u'2015-05-30 09:17:01.656726', u'2015-05-30 11:17:25.259118', u'2015-05-30 11:17:25.295682', u'2015-05-30 13:17:00 UTC+0000', u'GBPUSD', 1.5289, 1.52975, 1.53)
(10, 10, u'2015-05-30 09:17:08.906095', u'2015-05-30 11:17:25.302716', u'2015-05-30 11:17:25.337022', u'2015-05-30 13:17:00 UTC+0000', u'GBPUSD', 1.5289, 1.52975, 1.53)
(11, 11, u'2015-05-30 09:22:54.787782', u'2015-05-30 11:17:25.343416', u'2015-05-30 11:17:25.379316', u'2015-05-30 13:21:00 UTC+0000', u'GBPUSD', 1.5289, 1.52975, 1.53)
(12, 12, u'2015-05-30 09:23:02.034814', u'2015-05-30 11:17:25.534196', u'2015-05-30 11:17:25.571887', u'2015-05-30 13:23:00 UTC+0000', u'GBPUSD', 1.5289, 1.52975, 1.53)
(13, 13, u'2015-05-30 09:23:09.305855', u'2015-05-30 11:17:25.650274', u'2015-05-30 11:17:25.686878', u'2015-05-30 13:23:00 UTC+0000', u'GBPUSD', 1.5289, 1.52975, 1.53)
(14, 14, u'2015-05-30 09:23:18.193639', u'2015-05-30 11:17:25.756251', u'2015-05-30 11:17:25.793845', u'2015-05-30 13:23:00 UTC+0000', u'GBPUSD', 1.5289, 1.52975, 1.53)
(15, 15, u'2015-05-30 09:23:25.822885', u'2015-05-30 11:17:25.803364', u'2015-05-30 11:17:25.840687', u'2015-05-30 13:23:00 UTC+0000', u'GBPUSD', 1.5289, 1.52975, 1.53)
(16, 16, u'2015-05-30 09:23:33.119151', u'2015-05-30 11:17:25.849542', u'2015-05-30 11:17:25.886881', u'2015-05-30 13:23:00 UTC+0000', u'GBPUSD', 1.5289, 1.52975, 1.53)
(17, 17, u'2015-05-30 09:23:41.924820', u'2015-05-30 11:18:30.643189', u'2015-05-30 11:18:30.677631', u'2015-05-30 13:23:00 UTC+0000', u'GBPUSD', 1.5289, 1.52975, 1.53)
(18, 18, u'2015-05-30 09:23:49.815168', u'2015-05-30 11:18:30.688438', u'2015-05-30 11:18:30.721973', u'2015-05-30 13:23:00 UTC+0000', u'GBPUSD', 1.5289, 1.52975, 1.53)
(19, 19, u'2015-05-30 09:23:57.143688', u'2015-05-30 11:18:30.731422', u'2015-05-30 11:18:30.769322', u'2015-05-30 13:23:00 UTC+0000', u'GBPUSD', 1.5289, 1.52975, 1.53)
(20, 20, u'2015-05-30 09:24:04.340398', u'2015-05-30 11:18:30.780588', u'2015-05-30 11:18:30.818271', u'2015-05-30 13:23:00 UTC+0000', u'GBPUSD', 1.5289, 1.52975, 1.53)
(21, 21, u'2015-05-30 11:15:42.775625', u'2015-05-30 11:18:30.831061', u'2015-05-30 11:18:30.867483', u'2015-05-30 15:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.52975, 1.53)
(22, 22, u'2015-05-30 11:15:51.429303', u'2015-05-30 11:18:30.878806', u'2015-05-30 11:18:30.916033', u'2015-05-30 15:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.52975, 1.53)
(23, 23, u'2015-05-30 11:15:58.712359', u'2015-05-30 11:18:30.927366', u'2015-05-30 11:18:30.960813', u'2015-05-30 15:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.52975, 1.53)
(24, 24, u'2015-05-30 11:16:09.155449', u'2015-05-30 11:18:30.995412', u'2015-05-30 11:18:31.033735', u'2015-05-30 15:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.52975, 1.53)
(25, 25, u'2015-05-30 11:16:16.865008', u'2015-05-30 11:18:31.042703', u'2015-05-30 11:18:31.078253', u'2015-05-30 15:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.52975, 1.53)
(26, 26, u'2015-05-30 11:16:24.171908', u'2015-05-30 11:18:31.090301', u'2015-05-30 11:18:31.129290', u'2015-05-30 15:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.52975, 1.53)
(27, 27, u'2015-05-30 11:16:31.859444', u'2015-05-30 13:47:24.611251', u'2015-05-30 13:47:24.647299', u'2015-05-30 15:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.52975, 1.53)
(28, 28, u'2015-05-30 11:16:39.179710', u'2015-05-30 13:47:24.665876', u'2015-05-30 13:47:24.702168', u'2015-05-30 15:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.52975, 1.53)
(29, 29, u'2015-05-30 11:16:46.792799', u'2015-05-30 13:47:24.709966', u'2015-05-30 13:47:24.748211', u'2015-05-30 15:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.52975, 1.53)
(30, 30, u'2015-05-30 11:16:54.023519', u'2015-05-30 13:47:24.761220', u'2015-05-30 13:47:24.799526', u'2015-05-30 15:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.52975, 1.53)
(31, 31, u'2015-05-30 13:46:54.273525', u'2015-05-30 13:47:24.817246', u'2015-05-30 13:47:24.855604', u'2015-05-30 16:55:00 UTC+0000', u'GBPUSD', 1.5289, 1.52975, 1.53)
(32, 32, u'2015-05-30 13:47:01.472458', u'2015-05-30 13:47:24.874352', u'2015-05-30 13:47:24.912724', u'2015-05-30 16:55:00 UTC+0000', u'GBPUSD', 1.5289, 1.52975, 1.53)
(33, 33, u'2015-05-30 13:47:08.713723', u'2015-05-30 13:47:24.946890', u'2015-05-30 13:47:24.981546', u'2015-05-30 16:55:00 UTC+0000', u'GBPUSD', 1.5289, 1.52975, 1.53)
(34, 34, u'2015-05-30 13:47:15.938801', u'2015-05-30 13:47:24.993072', u'2015-05-30 13:47:25.030498', u'2015-05-30 16:55:00 UTC+0000', u'GBPUSD', 1.5289, 1.52975, 1.53)
(35, 35, u'2015-05-30 13:47:23.146648', u'2015-05-30 13:47:25.045241', u'2015-05-30 13:47:25.081338', u'2015-05-30 16:55:00 UTC+0000', u'GBPUSD', 1.5289, 1.52975, 1.53)

pPrice


In [167]:
conn = sqlite3.connect(data_db)
c = conn.cursor()
for row in c.execute('SELECT * FROM pPrice'):
    print row
conn.close()


(1, 1, u'2015-05-30 09:15:39.485955', u'2015-05-30 09:21:47.405673', u'2015-05-30 09:21:47.441443', u'good', u'2015-05-30 13:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(2, 2, u'2015-05-30 09:15:48.069422', u'2015-05-30 09:24:21.990715', u'2015-05-30 09:24:22.025171', u'good', u'2015-05-30 13:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(3, 3, u'2015-05-30 09:15:55.417848', u'2015-05-30 09:24:33.167984', u'2015-05-30 09:24:33.201830', u'good', u'2015-05-30 13:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(4, 4, u'2015-05-30 09:16:02.850010', u'2015-05-30 09:24:35.259689', u'2015-05-30 09:24:35.295610', u'good', u'2015-05-30 13:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(5, 5, u'2015-05-30 09:16:10.257276', u'2015-05-30 11:16:50.834372', u'2015-05-30 11:16:50.871380', u'good', u'2015-05-30 13:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(6, 6, u'2015-05-30 09:16:17.711932', u'2015-05-30 11:17:12.909723', u'2015-05-30 11:17:12.943839', u'good', u'2015-05-30 13:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(7, 7, u'2015-05-30 09:16:25.004063', u'2015-05-30 11:17:25.092175', u'2015-05-30 11:17:25.129221', u'good', u'2015-05-30 13:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(8, 8, u'2015-05-30 09:16:42.124534', u'2015-05-30 11:17:25.192964', u'2015-05-30 11:17:25.227434', u'good', u'2015-05-30 13:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(9, 9, u'2015-05-30 09:17:01.656726', u'2015-05-30 11:17:25.259118', u'2015-05-30 11:17:25.295682', u'good', u'2015-05-30 13:17:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(10, 10, u'2015-05-30 09:17:08.906095', u'2015-05-30 11:17:25.302716', u'2015-05-30 11:17:25.337022', u'good', u'2015-05-30 13:17:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(11, 11, u'2015-05-30 09:22:54.787782', u'2015-05-30 11:17:25.343416', u'2015-05-30 11:17:25.379316', u'good', u'2015-05-30 13:21:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(12, 12, u'2015-05-30 09:23:02.034814', u'2015-05-30 11:17:25.534196', u'2015-05-30 11:17:25.571887', u'good', u'2015-05-30 13:23:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(13, 13, u'2015-05-30 09:23:09.305855', u'2015-05-30 11:17:25.650274', u'2015-05-30 11:17:25.686878', u'good', u'2015-05-30 13:23:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(14, 14, u'2015-05-30 09:23:18.193639', u'2015-05-30 11:17:25.756251', u'2015-05-30 11:17:25.793845', u'good', u'2015-05-30 13:23:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(15, 15, u'2015-05-30 09:23:25.822885', u'2015-05-30 11:17:25.803364', u'2015-05-30 11:17:25.840687', u'good', u'2015-05-30 13:23:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(16, 16, u'2015-05-30 09:23:33.119151', u'2015-05-30 11:17:25.849542', u'2015-05-30 11:17:25.886881', u'good', u'2015-05-30 13:23:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(17, 17, u'2015-05-30 09:23:41.924820', u'2015-05-30 11:18:30.643189', u'2015-05-30 11:18:30.677631', u'good', u'2015-05-30 13:23:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(18, 18, u'2015-05-30 09:23:49.815168', u'2015-05-30 11:18:30.688438', u'2015-05-30 11:18:30.721973', u'good', u'2015-05-30 13:23:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(19, 19, u'2015-05-30 09:23:57.143688', u'2015-05-30 11:18:30.731422', u'2015-05-30 11:18:30.769322', u'good', u'2015-05-30 13:23:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(20, 20, u'2015-05-30 09:24:04.340398', u'2015-05-30 11:18:30.780588', u'2015-05-30 11:18:30.818271', u'good', u'2015-05-30 13:23:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(21, 21, u'2015-05-30 11:15:42.775625', u'2015-05-30 11:18:30.831061', u'2015-05-30 11:18:30.867483', u'good', u'2015-05-30 15:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(22, 22, u'2015-05-30 11:15:51.429303', u'2015-05-30 11:18:30.878806', u'2015-05-30 11:18:30.916033', u'good', u'2015-05-30 15:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(23, 23, u'2015-05-30 11:15:58.712359', u'2015-05-30 11:18:30.927366', u'2015-05-30 11:18:30.960813', u'good', u'2015-05-30 15:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(24, 24, u'2015-05-30 11:16:09.155449', u'2015-05-30 11:18:30.995412', u'2015-05-30 11:18:31.033735', u'good', u'2015-05-30 15:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(25, 25, u'2015-05-30 11:16:16.865008', u'2015-05-30 11:18:31.042703', u'2015-05-30 11:18:31.078253', u'good', u'2015-05-30 15:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(26, 26, u'2015-05-30 11:16:24.171908', u'2015-05-30 11:18:31.090301', u'2015-05-30 11:18:31.129290', u'good', u'2015-05-30 15:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(27, 27, u'2015-05-30 11:16:31.859444', u'2015-05-30 13:47:24.611251', u'2015-05-30 13:47:24.647299', u'good', u'2015-05-30 15:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(28, 28, u'2015-05-30 11:16:39.179710', u'2015-05-30 13:47:24.665876', u'2015-05-30 13:47:24.702168', u'good', u'2015-05-30 15:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(29, 29, u'2015-05-30 11:16:46.792799', u'2015-05-30 13:47:24.709966', u'2015-05-30 13:47:24.748211', u'good', u'2015-05-30 15:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(30, 30, u'2015-05-30 11:16:54.023519', u'2015-05-30 13:47:24.761220', u'2015-05-30 13:47:24.799526', u'good', u'2015-05-30 15:15:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(31, 31, u'2015-05-30 13:46:54.273525', u'2015-05-30 13:47:24.817246', u'2015-05-30 13:47:24.855604', u'good', u'2015-05-30 16:55:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(32, 32, u'2015-05-30 13:47:01.472458', u'2015-05-30 13:47:24.874352', u'2015-05-30 13:47:24.912724', u'good', u'2015-05-30 16:55:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(33, 33, u'2015-05-30 13:47:08.713723', u'2015-05-30 13:47:24.946890', u'2015-05-30 13:47:24.981546', u'good', u'2015-05-30 16:55:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(34, 34, u'2015-05-30 13:47:15.938801', u'2015-05-30 13:47:24.993072', u'2015-05-30 13:47:25.030498', u'good', u'2015-05-30 16:55:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)
(35, 35, u'2015-05-30 13:47:23.146648', u'2015-05-30 13:47:25.045241', u'2015-05-30 13:47:25.081338', u'good', u'2015-05-30 16:55:00 UTC+0000', u'GBPUSD', 1.5289, 1.5295, 1.53)

vViewpoint


In [168]:
conn = sqlite3.connect(view_db)
c = conn.cursor()
for row in c.execute('SELECT * FROM vViewpoint'):
    print row
conn.close()


(1, u'dPrice', 26)
(2, u'dPrice', 26)

view


In [169]:
conn = sqlite3.connect(view_db)
c = conn.cursor()
for row in c.execute('SELECT * FROM vPrice'):
    print row
conn.close()


(1, u'2015-05-30 09:15:39.485955', u'GBPUSD', 1.52975)
(2, u'2015-05-30 09:15:48.069422', u'GBPUSD', 1.52975)
(3, u'2015-05-30 09:15:55.417848', u'GBPUSD', 1.52975)
(4, u'2015-05-30 09:16:02.850010', u'GBPUSD', 1.52975)
(5, u'2015-05-30 09:16:10.257276', u'GBPUSD', 1.52975)
(6, u'2015-05-30 09:16:17.711932', u'GBPUSD', 1.52975)
(7, u'2015-05-30 09:16:25.004063', u'GBPUSD', 1.52975)
(8, u'2015-05-30 09:16:42.124534', u'GBPUSD', 1.52975)
(9, u'2015-05-30 09:17:01.656726', u'GBPUSD', 1.52975)
(10, u'2015-05-30 09:17:08.906095', u'GBPUSD', 1.52975)
(11, u'2015-05-30 09:22:54.787782', u'GBPUSD', 1.52975)
(12, u'2015-05-30 09:23:02.034814', u'GBPUSD', 1.52975)
(13, u'2015-05-30 09:23:09.305855', u'GBPUSD', 1.52975)
(14, u'2015-05-30 09:23:18.193639', u'GBPUSD', 1.52975)
(15, u'2015-05-30 09:23:25.822885', u'GBPUSD', 1.52975)
(16, u'2015-05-30 09:23:33.119151', u'GBPUSD', 1.52975)
(17, u'2015-05-30 09:23:41.924820', u'GBPUSD', 1.52975)
(18, u'2015-05-30 09:23:49.815168', u'GBPUSD', 1.52975)
(19, u'2015-05-30 09:23:57.143688', u'GBPUSD', 1.52975)
(20, u'2015-05-30 09:24:04.340398', u'GBPUSD', 1.52975)
(21, u'2015-05-30 11:15:42.775625', u'GBPUSD', 1.52975)
(22, u'2015-05-30 11:15:51.429303', u'GBPUSD', 1.52975)
(23, u'2015-05-30 11:15:58.712359', u'GBPUSD', 1.52975)
(24, u'2015-05-30 11:16:09.155449', u'GBPUSD', 1.52975)
(25, u'2015-05-30 11:16:16.865008', u'GBPUSD', 1.52975)
(26, u'2015-05-30 11:16:24.171908', u'GBPUSD', 1.52975)

In [170]:
def get_iPrice_details():
    conn = sqlite3.connect(in_db)
    c = conn.cursor()
    #df = pd.read_sql("SELECT count(*), status from iPrice group by status",conn) #,conn,parse_dates={'date':'%Y-%m-%d'})
    results = c.execute("SELECT count(*), status from iPrice group by status") #,conn,parse_dates={'date':'%Y-%m-%d'})
    
    rtn = {}
    for row in results:
        #print row
        rtn[str(row[1])] = row[0]
    conn.close()

    return rtn

In [171]:
print get_iPrice_details()


{'done': 35, 'wait': 5}

Show chart of iPrice processing


In [172]:
def get_vPrice_details():
    conn = sqlite3.connect(view_db)
    c = conn.cursor()
    #df = pd.read_sql("SELECT count(*), status from iPrice group by status",conn) #,conn,parse_dates={'date':'%Y-%m-%d'})
    results = c.execute("SELECT * from vViewpoint where dtable = 'dPrice' ") 
    #print results
    for row in results:
        #print row
        vpoint = row[2]
    conn.close()

    
    conn = sqlite3.connect(data_db)
    c = conn.cursor()
    #df = pd.read_sql("SELECT count(*), status from iPrice group by status",conn) #,conn,parse_dates={'date':'%Y-%m-%d'})
    results = c.execute("SELECT max(dPriceId) from dPrice ")
    #print results
    for row in results:
        #print row
        max_dPrice = row[0]
    conn.close()
    
    return vpoint, max_dPrice

In [ ]:
Show plot of delays

In [174]:
fig1 = plt.figure()
ax1 = fig1.add_subplot(2,1,1)
ax2 = fig1.add_subplot(2,1,2)

#global d
count_wait = [0,]
count_process = [0,]
count_done =[0,]
count_total = [0,]

count_vpoint = [0,]
count_max_dPrice = [0,]
count_vbehind = [0,]
#yahoo = Share('YHOO')

def animate1(i):
    iPrice_details = get_iPrice_details()
    wait = iPrice_details.get('wait',0)
    process = iPrice_details.get('process',0)
    done = iPrice_details.get('done',0)
    total = wait + process + done
    
    count_wait.append(wait)
    count_process.append(process)
    count_done.append(done)
    count_total.append(total)
    
    ax1.clear()
    ax1.plot(range(len(count_wait)),count_wait, label = 'wait')
    ax1.plot(range(len(count_process)),count_process, label = 'processing')
    ax1.plot(range(len(count_done)),count_done, label = 'done')
    ax1.plot(range(len(count_total)),count_total, label = 'total')
    ax1.legend(loc='upper left')
    
    vpoint, max_dPrice = get_vPrice_details()
    vbehind = max_dPrice - vpoint
    
    count_vpoint.append(vpoint)
    count_max_dPrice.append(max_dPrice)
    count_vbehind.append(vbehind)
  
    
    ax2.clear()
    ax2.plot(range(len(count_vpoint)),count_vpoint,label = 'vpoint' )
    ax2.plot(range(len(count_max_dPrice)),count_max_dPrice, label = 'max')
    ax2.plot(range(len(count_vbehind)),count_vbehind, label = 'behind')
    ax2.legend(loc='upper left')
    
ani1 = animation.FuncAnimation(fig1,animate1, interval=1000)

plt.show()

show chart for vPrice monitoring


In [165]:
print get_vPrice_details()


(26, 35)

In [166]:
fig1 = plt.figure()
ax1 = fig1.add_subplot(1,1,1)

#global d
count_vpoint = [0,]
count_max_dPrice = [0,]
count_vbehind = [0,]

#yahoo = Share('YHOO')

def animate1(i):
    vpoint, max_dPrice = get_vPrice_details()
    vbehind = max_dPrice - vpoint
    
    count_vpoint.append(vpoint)
    count_max_dPrice.append(max_dPrice)
    count_vbehind.append(vbehind)
  
    
    ax1.clear()
    ax1.plot(range(len(count_vpoint)),count_vpoint)
    ax1.plot(range(len(count_max_dPrice)),count_max_dPrice)
    ax1.plot(range(len(count_vbehind)),count_vbehind)


ani1 = animation.FuncAnimation(fig1,animate1, interval=1000)

plt.show()

In [ ]:


In [ ]:


In [ ]: