from datetime import datetime


def parse_period(period):
    """Convert various financial periods to number of days

    :param int/str period: Number of days for the return window or one of
        the following keyword strings. Each keyword can be adjusted using a
        dash and modifier (i.e. 2-day, 6-year, etc)
            * day
            * month
            * quarter
            * year
            * ytd
    :return int days:
    """
    if isinstance(period, int):
        days = period
    elif isinstance(period, str):
        today = datetime.today()
        keyword_durations = {
            'day': 1,
            'week': 7,
            'month': 30,
            'quarter': 91,
            'year': 365,
            'ytd': (today - datetime(today.year, 1, 1)).days}
        if '-' in period:
            multiplier, keyword = period.split('-')
            multiplier = int(multiplier)
        else:
            keyword = period
            multiplier = 1
        if keyword not in keyword_durations:
            raise ValueError(f'{period} string does not match supported formats')
        days = multiplier * keyword_durations[keyword]
    else:
        raise ValueError(f'Exepcted type int or str, but received {type(period)}')
    return days