Как ускорить расчёт вейвлетов?

```

def calculate_cwt_data(df, idx, timeframe, data_points, wavelet_name, scale, collection):
    global ROWS_FROM_CWT

    date = df.iloc[idx:idx + data_points].reset_index()["Date"].tolist()
    close = df.iloc[idx:idx + data_points]["Close"].values
    percent_change = calculate_precent_change(close)
    stat_date = date[0]
    end_date = date[-1]

    # Выполняем непрерывное вейвлет-преобразование для обновленных данных
    coefficients, frequencies = pywt.cwt(close, scales, wavelet_name)

    # Нормализация данных
    coefficients = normalize_array(coefficients)

    # Отбираем только нужные строки
    coefficients = coefficients[ROWS_FROM_CWT].tolist()

    document = {
        "_id": f"{idx}_{timeframe}_{wavelet_name}_{data_points}",
        "stat_date": stat_date,
        "end_date": end_date,
        "percent_change": percent_change,
        "rows_from_cwt": ROWS_FROM_CWT,
        "coefficients": coefficients
    }

    collection.insert_one(document)


MONGO_USERNAME = "root"
MONGO_PASSWORD = "example"
MONGO_HOST = "mongodb"          
MONGO_PORT = 27017 
MONGO_URI = f"mongodb://{MONGO_USERNAME}:{MONGO_PASSWORD}@{MONGO_HOST}:{MONGO_PORT}/admin"

mongo_client = MongoClient(MONGO_URI)
db = client['cwt']

ROWS_FROM_CWT = [0, 5, 10, 20, 30, 40, 50, 70, 90, 100, 140, 180]
WAVELETS = ["gaus1", "gaus2", "gaus4", "gaus5", "gaus8", "mexh", "morl"]
SCALE = np.arange(1, 196)
DATA_POINTS = [100, 500]

STEP_BETWEEN_IDX = {
    "15m": 10,
    "30m": 8,
    "1h": 4,
    "2h": 2,
    "4h": 1,
    "1d": 1
}


for timeframe in TIMEFRAMES:
    for wavelet_name in WAVELETS:
        for data_points in DATA_POINTS:
            print("-"*20, f"{timeframe} {wavelet_name} {data_points}", "-"*20, end="\n"*2)
        
            collection = db[f'cwt_{timeframe}_{wavelet_name}_{data_points}']

            amount_of_steps = ohlcv_df[timeframe].shape[0] - data_points

            for idx in tqdm.tqdm(range(0, amount_of_steps, STEP_BETWEEN_IDX[timeframe])):
                calculate_cwt_data(
                    ohlcv_df[timeframe],
                    idx,
                    timeframe,
                    data_points,
                    wavelet_name,
                    SCALE,
                    collection
                )Как ускорить работу данной функции?


def calculate_cwt_data(df, idx, timeframe, data_points, wavelet_name, scale, collection):
    global ROWS_FROM_CWT

    date = df.iloc[idx:idx + data_points].reset_index()["Date"].tolist()
    close = df.iloc[idx:idx + data_points]["Close"].values
    percent_change = calculate_precent_change(close)
    stat_date = date[0]
    end_date = date[-1]

    # Выполняем непрерывное вейвлет-преобразование для обновленных данных
    coefficients, frequencies = pywt.cwt(close, scales, wavelet_name)

    # Нормализация данных
    coefficients = normalize_array(coefficients)

    # Отбираем только нужные строки
    coefficients = coefficients[ROWS_FROM_CWT].tolist()

    document = {
        "_id": f"{idx}_{timeframe}_{wavelet_name}_{data_points}",
        "stat_date": stat_date,
        "end_date": end_date,
        "percent_change": percent_change,
        "rows_from_cwt": ROWS_FROM_CWT,
        "coefficients": coefficients
    }

    collection.insert_one(document)


MONGO_USERNAME = "root"
MONGO_PASSWORD = "example"
MONGO_HOST = "mongodb"          
MONGO_PORT = 27017 
MONGO_URI = f"mongodb://{MONGO_USERNAME}:{MONGO_PASSWORD}@{MONGO_HOST}:{MONGO_PORT}/admin"

mongo_client = MongoClient(MONGO_URI)
db = client['cwt']

ROWS_FROM_CWT = [0, 5, 10, 20, 30, 40, 50, 70, 90, 100, 140, 180]
WAVELETS = ["gaus1", "gaus2", "gaus4", "gaus5", "gaus8", "mexh", "morl"]
SCALE = np.arange(1, 196)
DATA_POINTS = [100, 500]

STEP_BETWEEN_IDX = {
    "15m": 10,
    "30m": 8,
    "1h": 4,
    "2h": 2,
    "4h": 1,
    "1d": 1
}


for timeframe in TIMEFRAMES:
    for wavelet_name in WAVELETS:
        for data_points in DATA_POINTS:
            print("-"*20, f"{timeframe} {wavelet_name} {data_points}", "-"*20, end="\n"*2)
        
            collection = db[f'cwt_{timeframe}_{wavelet_name}_{data_points}']

            amount_of_steps = ohlcv_df[timeframe].shape[0] - data_points

            for idx in tqdm.tqdm(range(0, amount_of_steps, STEP_BETWEEN_IDX[timeframe])):
                calculate_cwt_data(
                    ohlcv_df[timeframe],
                    idx,
                    timeframe,
                    data_points,
                    wavelet_name,
                    SCALE,
                    collection
                )

```