def perf_weekly_by_14_day(self): num_days = 14 if len(self.close_prices()) < num_days: return -1 perf = (self.close_prices()[-1] - self.close_prices()[-num_days] ) / self.close_prices()[-num_days] return metric.compound(perf, num_days / 5.0) # 14 business days = 2.8 wks
def perf_weekly_by_quarter(self): perf_quarter_str = self.attr_dict['Perf Quarter'] == '-' and \ self.attr_dict['Perf YTD'] or self.attr_dict['Perf Quarter'] perf_quarter = misc.to_float_value(perf_quarter_str) return metric.compound(perf_quarter / 100, 13)
def perf_weekly_by_month(self): perf_month = misc.to_float_value(self.attr_dict['Perf Month']) return metric.compound(perf_month / 100, 4.33)
def perf_weekly_by_half_year(self): perf_half_year_str = self.attr_dict['Perf Half Y'] == '-' and \ self.attr_dict['Perf YTD'] or self.attr_dict['Perf Half Y'] perf_half_year = misc.to_float_value(perf_half_year_str) return metric.compound(perf_half_year / 100, 26)