def weighted_moving_average(days, weights):
    """
    | Calculates the rolling weighted moving average. The weights list should have the size of the days window.
    | Name: weighted\_moving\_average\_\ **days**

    :param days: Size of the window
    :type days: int
    :param weights: Weights to use for the calculation
    :type weights: list(int)
    """
    def f(w):
        def g(x):
            return (w * x).sum() / sum(w)

        return g

    def return_function(data):
        if len(weights) == days:
            column_name = f"weighted_moving_average_{days}"
            if column_name not in data.columns:
                data[column_name] = (
                    data["close"].rolling(window=days).apply(f(weights), raw=True)
                )
            return data[column_name].copy()
        else:
            raise Exception("Weights length and rolling mean must be same length")

    return return_function