# Path: alphaware/enums.py
# class OutputDataFormat(IntEnum):
#     MULTI_INDEX_DF = 0
#     PITVOT_TABLE_DF = 1
# 
# class ReturnType(IntEnum):
#     Non_Cumul = 0
#     Cumul = 1
# 
# Path: alphaware/const.py
# RETURN = namedtuple('RETURN', ['data', 'type'])


import pandas as pd
import numpy as np
from datetime import datetime
from argcheck import expect_types
from xutils.date_utils import Date
from empyrical import cum_returns
from ..enums import (OutputDataFormat,
                     ReturnType)
from ..const import RETURN
@expect_types(date=(str, datetime, Date))
def ensure_pyfin_date(date, date_format='%Y-%m-%d'):
    """
    :param date: str, datetime, 日期
    :param date_format: str, 时间格式
    :return: PyFin.Date object 
    """
    if isinstance(date, Date):
        return date
    elif isinstance(date, str):
        return Date.strptime(date, date_format)
    else:
        return Date.fromDateTime(date)


@expect_types(date=(str, datetime))
def ensure_datetime(date, date_format='%Y-%m-%d'):
    """
    :param date: str, datetime, 日期
    :param date_format: str, 时间格式
    :return: datetime
    """
    if isinstance(date, datetime):
        return date
    else:
        return datetime.strptime(date, date_format)


@expect_types(data=(pd.DataFrame, pd.Series), data_format=OutputDataFormat)
def ensure_pd_index_names(data, data_format, valid_index):

# Path: alphaware/enums.py
# class OutputDataFormat(IntEnum):
#     MULTI_INDEX_DF = 0
#     PITVOT_TABLE_DF = 1
# 
# class ReturnType(IntEnum):
#     Non_Cumul = 0
#     Cumul = 1
# 
# Path: alphaware/const.py
# RETURN = namedtuple('RETURN', ['data', 'type'])


# Path: alphaware/utils/input_validation.py
import pandas as pd
import numpy as np
from datetime import datetime
from argcheck import expect_types
from xutils.date_utils import Date
from empyrical import cum_returns
from ..enums import (OutputDataFormat,
                     ReturnType)
from ..const import RETURN

@expect_types(date=(str, datetime, Date))
def ensure_pyfin_date(date, date_format='%Y-%m-%d'):
    """
    :param date: str, datetime, 日期
    :param date_format: str, 时间格式
    :return: PyFin.Date object 
    """
    if isinstance(date, Date):
        return date
    elif isinstance(date, str):
        return Date.strptime(date, date_format)
    else:
        return Date.fromDateTime(date)


@expect_types(date=(str, datetime))
def ensure_datetime(date, date_format='%Y-%m-%d'):
    """
    :param date: str, datetime, 日期
    :param date_format: str, 时间格式
    :return: datetime
    """
    if isinstance(date, datetime):
        return date
    else:
        return datetime.strptime(date, date_format)


@expect_types(data=(pd.DataFrame, pd.Series), data_format=OutputDataFormat)
def ensure_pd_index_names(data, data_format, valid_index):

    if data_format == OutputDataFormat.MULTI_INDEX_DF: