-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_h5.py
52 lines (37 loc) · 1.34 KB
/
create_h5.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import unittest
import tables as ta
import numpy as np
import os
import sys
TEST_DATABASE = "test_historical_option_data.h5"
def create_database(file_name):
h5file = ta.openFile(TEST_DATABASE, 'w')
# create our class / column descriptor
class Option(ta.IsDescription):
underlying_symbol = ta.StringCol(20, pos=0)
underlying_price = ta.Float32Col(pos=1)
exchange = ta.StringCol(5, pos=2)
option_symbol = ta.StringCol(30, pos=3)
option_ext = ta.StringCol(5, pos=4)
type = ta.StringCol(10, pos=5)
Expiration = ta.StringCol(10, pos=6)
DataDate = ta.StringCol(15, pos=7)
Strike = ta.StringCol(15, pos=8)
Last = ta.Float32Col(pos=9)
Bid = ta.Float32Col(pos=10)
Ask = ta.Float32Col(pos=11)
Volume = ta.IntCol(pos=12)
OpenInterest = ta.IntCol(pos=13)
IV = ta.Float32Col(pos=14)
Delta = ta.Float32Col(pos=15)
Gamma = ta.Float32Col(pos=16)
Theta = ta.Float32Col(pos=17)
Vega = ta.Float32Col(pos=18)
AKA = ta.StringCol(15, pos=19)
# group = h5file.createGroup('/', 'options', "Option Database")
# h5file.createTable(group, 'date', Option)
h5file.createTable('/', 'options', Option)
print h5file
h5file.close()
if __name__ == '__main__':
create_database(TEST_DATABASE)