def average_monthly(funds): """ @summary Computes average monthly returns centered around 0 @param funds: A time series containing daily fund values @return an array of average monthly returns """ rets = daily(funds) ret_i = 0 years = qsdateutil.getYears(funds) averages = [] for year in years: months = qsdateutil.getMonths(funds, year) for month in months: avg = 0 count = 0 days = qsdateutil.getDays(funds, year, month) for day in days: avg += rets[ret_i] ret_i += 1 count += 1 averages.append(float(avg) / count) return (averages)
def average_monthly(funds): """ @summary Computes average monthly returns centered around 0 @param funds: A time series containing daily fund values @return an array of average monthly returns """ rets = daily(funds) ret_i = 0 years = qsdateutil.getYears(funds) averages = [] for year in years: months = qsdateutil.getMonths(funds, year) for month in months: avg = 0 count = 0 days = qsdateutil.getDays(funds, year, month) for day in days: avg += rets[ret_i] ret_i += 1 count += 1 averages.append(float(avg) / count) return(averages)