基准组合的年化收益

        Returns:
            [type] -- [description]
191350
def benchmark_annualize_return(self):
        

        return round(
            float(
                self.calc_annualize_return(
                    self.benchmark_assets,
                    self.time_gap
                )
            ),
            2
        )
990844
def _year_from_2digits(short_year, current_year):
        
        if short_year < 100:
            short_year += current_year - (current_year % 100)
            if abs(short_year - current_year) >= 50:
                if short_year < current_year:
                    return short_year + 100
                else:
                    return short_year - 100
        return short_year
1056890
def _end_of_century(self):
        
        year = self.year - 1 - (self.year - 1) % YEARS_PER_CENTURY + YEARS_PER_CENTURY

        return self.set(year, 12, 31, 23, 59, 59, 999999)
775655
function getUnitsPerEm(xMin, xMax, yMin, yMax) {
            var seed = Math.ceil(Math.min(yMax - yMin, xMax - xMin));

            if (!seed) {
                return 1024;
            }

            if (seed <= 128) {
                return seed;
            }

            // 获取合适的unitsPerEm
            var unitsPerEm = 128;
            while (unitsPerEm < 16384) {

                if (seed <= 1.2 * unitsPerEm) {
                    return unitsPerEm;
                }

                unitsPerEm = unitsPerEm << 1;
            }

            return 1024;
        }
890531
public int getYear() {

        MinguoEra era = this.getEra();
        return ((era == MinguoEra.ROC) ? this.iso.getYear() - 1911 : 1912 - this.iso.getYear());

    }
851017
def build_dated_queryset(self):
        
        qs = self.get_dated_queryset()
        years = self.get_date_list(qs)
        [self.build_year(dt) for dt in years]
177219
public static Date plusYears(Date date, int years) {
		return plus(date, years, DateTimeField.YEAR);
	}
1342099
def year(columns, name=None):
    

    if columns < 0:
        # Can't have negative size
        raise BaseException()

    field = numeric(columns, name)

    # Parse action
    field.addParseAction(_to_year)

    return field
303589
def datetime2yeardoy(time: Union[str, datetime.datetime]) -> Tuple[int, float]:
    
    T = np.atleast_1d(time)

    utsec = np.empty_like(T, float)
    yd = np.empty_like(T, int)
    for i, t in enumerate(T):
        if isinstance(t, np.datetime64):
            t = t.astype(datetime.datetime)
        elif isinstance(t, str):
            t = parse(t)

        utsec[i] = datetime2utsec(t)
        yd[i] = t.year*1000 + int(t.strftime('%j'))

    return yd.squeeze()[()], utsec.squeeze()[()]
464876
private static void combineWords(String[] wordNet, int start, int end, CoreDictionary.Attribute[] attributeArray, CoreDictionary.Attribute value)
    {
        if (start + 1 != end)   // 小优化，如果只有一个词，那就不需要合并，直接应用新属性
        {
            StringBuilder sbTerm = new StringBuilder();
            for (int j = start; j < end; ++j)
            {
                if (wordNet[j] == null) continue;
                sbTerm.append(wordNet[j]);
                wordNet[j] = null;
            }
            wordNet[start] = sbTerm.toString();
        }
        attributeArray[start] = value;
    }
1335817
def from_year(cls, year):
        

        first_day = date(year, 1, 1)
        return cls.from_date(first_day, period="year")
522587
def yearly(self):
        
        if self._yearly is None:
            self._yearly = YearlyList(self._version, account_sid=self._solution['account_sid'], )
        return self._yearly
904031
def iter_by_year(self):
        """"""
        for yr, details in self.txn_details.iter_by_year():
            yield yr, Performance(details)
985679
def loaddate(self):
    ''' 
    '''
    ld = csv.reader(open('./%s/opendate.csv' % _CSVFILEPATH, 'r'))
    re = {}
    re['close'] = []
    re['open'] = []

    for i in ld:
      ''' 0 = 休市, 1 = 開市 '''
      if i[1] == '0':
        re['close'] += [datetime.strptime(i[0],'%Y/%m/%d').date()]
      elif i[1] == '1':
        re['open'] += [datetime.strptime(i[0],'%Y/%m/%d').date()]
      else:
        pass
    return re
1180549
def _datetime_key_for_merge(self, logevent):
        """"""
        if not logevent:
            # if logfile end is reached, return max datetime to never
            # pick this line
            return datetime(MAXYEAR, 12, 31, 23, 59, 59, 999999, tzutc())

        # if no datetime present (line doesn't have one) return mindate
        # to pick this line immediately
        return logevent.datetime or datetime(MINYEAR, 1, 1, 0, 0, 0, 0,
                                             tzutc())
1233611
def getyrdoy(date):
    """"""

    try:
        doy = date.toordinal()-datetime(date.year,1,1).toordinal()+1
    except AttributeError:
        raise AttributeError("Must supply a pandas datetime object or " +
                             "equivalent")
    else:
        return date.year, doy
1278270
def _format_years(years):
    
    def sub(x):
        return x[1] - x[0]

    ranges = []
    for k, iterable in groupby(enumerate(sorted(years)), sub):
        rng = list(iterable)
        if len(rng) == 1:
            s = str(rng[0][1])
        else:
            s = "{}-{}".format(rng[0][1], rng[-1][1])
        ranges.append(s)
    return ", ".join(ranges)