valleyjudge.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:valleyjudge 作者: dcolascione 项目源码 文件源码
def make_vests(
        total,
        annual_ratios,
        start_date,
        vesting_dates):
    """Generate a vesting schedule for a grant.

    TOTAL is the total value, in dollars, of the grant.  ANNUAL_RATIOS
    is a sequence of numbers, which must sum to one, that determine
    how much of the grant vests in each year.  START_DATE is a
    datetime.date object indicating when the grant clock starts
    ticking.  VESTING_DATES is a sequence of (MONTH, DAY) tuples that
    indicate the months and days when grants vest each year.

    Return a sequence of (VDATE, VAMOUNT) tuples; each VDATE is a date
    on which a vest happens; and VAMOUNT is the amount, in dollars,
    given out on that day.

    """
    vests = []
    cliff_vest_day = start_date.replace(year = start_date.year + 1)
    vests.append((cliff_vest_day, annual_ratios[0] * total))
    annual_ratios = annual_ratios[1:]
    nrv = 0
    d = cliff_vest_day + timedelta(days=1)
    while annual_ratios:
        if (d.month, d.day) in vesting_dates:
            dist_from_cliff = d - cliff_vest_day
            frac = annual_ratios[0] / len(vesting_dates)
            vests.append((d, frac * total))
            nrv += 1
        if nrv == len(vesting_dates):
            nrv = 0
            annual_ratios = annual_ratios[1:]
        d += timedelta(days=1)
    return vests
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号