Markets end higher for second consecutive week