def calculate_r2_wf(y_true, y_pred, y_moving_mean):
    """
    Calculate out-of-sample R^2 for the walk-forward procedure
    """
    mse_urestricted = ((y_true - y_pred)**2).sum()
    mse_restricted = ((y_true - y_moving_mean)**2).sum()
    return 1 - mse_urestricted/mse_restricted