def ib_duration_str(start_date=None):
    """
    Get a datetime object or a epoch timestamp and return
    an IB-compatible durationStr for reqHistoricalData()
    """
    now = datetime.datetime.utcnow()

    if is_number(start_date):
        diff = now - datetime.datetime.fromtimestamp(float(start_date))
    elif isinstance(start_date, str):
        diff = now - parse_date(start_date)
    elif isinstance(start_date, datetime.datetime):
        diff = now - start_date
    else:
        return None

    # get diff
    second_diff = diff.seconds
    day_diff = diff.days

    # small diff?
    if day_diff < 0 or second_diff < 60:
        return None

    # return str(second_diff)+ " S"
    if day_diff == 0 and second_diff > 1:
        return str(second_diff) + " S"
    if 31 > day_diff > 0:
        return str(day_diff) + " D"
    if 365 > day_diff > 31:
        return str(ceil(day_diff / 30)) + " M"

    return str(ceil(day_diff / 365)) + " Y"