# Path: kquant_data/xio/h5.py
# def write_dataframe_set_struct_keep_head(path, data, dtype, dateset_name):
#     """
#     保存DataFrame数据
#     保留表头
#     可以用来存K线，除权除息等信息
#     :param path:
#     :param data:
#     :param dtype:
#     :param dateset_name:
#     :return:
#     """
#     f = h5py.File(path, 'w')
# 
#     r = data.to_records(index=False)
#     d = np.array(r, dtype=dtype)
# 
#     f.create_dataset(dateset_name, data=d, compression="gzip", compression_opts=6)
#     f.close()
#     return


import urllib
import urllib.request
import numpy as np
from struct import *
from ..xio.h5 import write_dataframe_set_struct_keep_head
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
大智慧数据的处理
"""


dzh_h5_type = np.dtype([
    ('time', np.uint64),
    ('pre_day', np.float64),
    ('pre_close', np.float64),
    ('split', np.float64),
    ('purchase', np.float64),
    ('purchase_price', np.float64),
    ('dividend', np.float64),
    ('dr_pre_close', np.float64),
    ('dr_factor', np.float64),
    ('backward_factor', np.float64),
    ('forward_factor', np.float64),
])


def dividend_to_h5(input_path, data):

# Path: kquant_data/xio/h5.py
# def write_dataframe_set_struct_keep_head(path, data, dtype, dateset_name):
#     """
#     保存DataFrame数据
#     保留表头
#     可以用来存K线，除权除息等信息
#     :param path:
#     :param data:
#     :param dtype:
#     :param dateset_name:
#     :return:
#     """
#     f = h5py.File(path, 'w')
# 
#     r = data.to_records(index=False)
#     d = np.array(r, dtype=dtype)
# 
#     f.create_dataset(dateset_name, data=d, compression="gzip", compression_opts=6)
#     f.close()
#     return


# Path: kquant_data/stock/dzh.py
import urllib
import urllib.request
import numpy as np
from struct import *
from ..xio.h5 import write_dataframe_set_struct_keep_head

#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
大智慧数据的处理
"""


dzh_h5_type = np.dtype([
    ('time', np.uint64),
    ('pre_day', np.float64),
    ('pre_close', np.float64),
    ('split', np.float64),
    ('purchase', np.float64),
    ('purchase_price', np.float64),
    ('dividend', np.float64),
    ('dr_pre_close', np.float64),
    ('dr_factor', np.float64),
    ('backward_factor', np.float64),
    ('forward_factor', np.float64),
])


def dividend_to_h5(input_path, data):

    write_dataframe_set_struct_keep_head(input_path, data, dzh_h5_type, 'Dividend')