def yield_in(transaction_file): df = read_file(transaction_file) dates = sorted(pd.unique(df.dt_date.ravel()).tolist()) dates.append(date.today()) for i, d in enumerate(dates): if i != len(dates) - 1: d2 = dates[i + 1] - timedelta(days=2) startprice = worth_at_date(transaction_file, d).sum() endprice = worth_at_date(transaction_file, d2).sum() print cv.get_yield(d, startprice, d2, endprice) print startprice print endprice