python - Numpy / Matplotlib - Transform tick data into OHLCV -


i have tick data wold transform in ohlcv(open, high, low, close, volume) daily, hourly, 15min, 5min, 1min.

the tick data have this:

array([[u'2011-08-18 13:37:25', u'10.9', u'0.48990826'],    [u'2011-08-19 13:19:24', u'11.85', u'0.08438819'],    [u'2011-08-19 16:45:01', u'11.5', u'0.4'],    ...,     [u'2013-08-24 01:29:27', u'107.97', u'0.18523664'],    [u'2013-08-24 01:29:35', u'107.98', u'4.61659567'],    [u'2013-08-24 01:30:56', u'107.98', u'0.09339562']],    dtype='<u19') 

the numpy array have (date, price, volume).

i got data nympy array code:

import matplotlib.pyplot plt import sqlite3 import numpy np  database = sqlite3.connect('database.db') cursor = database.cursor() # criar o cursor cursor.execute("select date, price, amount table order date asc")  ar=[[r[0], r[1], r[2]] r in cursor.fetchall()] database.close()  arnp = np.array(ar) plt.plot(arnp[:, 1]) plt.ylabel('some...') plt.show() 

i don't know best method transformation. i've data in sqlite database, easier transformation using sql or using python?

any clues?

best regards,


Comments

Popular posts from this blog

Line ending issue with Mercurial or Visual Studio -

java - Jtable duplicate Rows -

java - Run a .jar on Heroku -