# Path: kquant_data/wind/utils.py
# def asDateTime(v, asDate=False):
#     """
#     万得中读出来的时间总多5ms，覆写这部分
#     w.asDateTime = asDateTime
#     w.start()
#     :param v:
#     :param asDate:
#     :return:
#     """
#     # return datetime(1899, 12, 30, 0, 0, 0, 0) + timedelta(v + 0.005 / 3600 / 24)
#     return datetime(1899, 12, 30, 0, 0, 0, 0) + timedelta(v)


import os
import pandas as pd
from .utils import asDateTime
    param = 'exchange=%s' % exchange
    param += ';windcode=%s' % windcode
    param += ';status=%s' % status
    if field:
        param += ';field=%s' % field

    w.asDateTime = asDateTime
    w_wset_data = w.wset("optioncontractbasicinfo", param)
    df = pd.DataFrame(w_wset_data.Data)
    df = df.T
    df.columns = w_wset_data.Fields
    return df


def download_optionchain(w, date='2017-11-28', us_code='510050.SH',
                         field='option_code,option_name,strike_price,multiplier'):
    """
    下载指定日期期权数据

w_wset_data = vba_wset("optionchain","date=2017-11-28;us_code=510050.SH;option_var=全部;call_put=全部;field=option_code,option_name,strike_price,multiplier",)
    :param w:
    :param windcode:
    :param date:
    :return:
    """
    param = 'date=%s' % date
    param += ';us_code=%s' % us_code
    if field:
        param += ';field=%s' % field


# Path: kquant_data/wind/utils.py
# def asDateTime(v, asDate=False):
#     """
#     万得中读出来的时间总多5ms，覆写这部分
#     w.asDateTime = asDateTime
#     w.start()
#     :param v:
#     :param asDate:
#     :return:
#     """
#     # return datetime(1899, 12, 30, 0, 0, 0, 0) + timedelta(v + 0.005 / 3600 / 24)
#     return datetime(1899, 12, 30, 0, 0, 0, 0) + timedelta(v)


# Path: kquant_data/wind/wset.py
import os
import pandas as pd
from .utils import asDateTime

    param = 'exchange=%s' % exchange
    param += ';windcode=%s' % windcode
    param += ';status=%s' % status
    if field:
        param += ';field=%s' % field

    w.asDateTime = asDateTime
    w_wset_data = w.wset("optioncontractbasicinfo", param)
    df = pd.DataFrame(w_wset_data.Data)
    df = df.T
    df.columns = w_wset_data.Fields
    return df


def download_optionchain(w, date='2017-11-28', us_code='510050.SH',
                         field='option_code,option_name,strike_price,multiplier'):
    """
    下载指定日期期权数据

w_wset_data = vba_wset("optionchain","date=2017-11-28;us_code=510050.SH;option_var=全部;call_put=全部;field=option_code,option_name,strike_price,multiplier",)
    :param w:
    :param windcode:
    :param date:
    :return:
    """
    param = 'date=%s' % date
    param += ';us_code=%s' % us_code
    if field:
        param += ';field=%s' % field


    w.asDateTime = asDateTime