Обсуждение статьи "Cоздание стратегии возврата к среднему на основе машинного обучения" - страница 4

[Удален]  
Evgeniy Chernish #:
Максим, расскажите подробнее как вы разбиваете на кластеры траекторию цены валютной пары по коэффициенту асимметрии. 

Рассчитывается в скользящем окне как признак, добавляется в датасет. По этому признаку происходит кластеризация, присваиваются метки кластеров всему датасету. Потом выбираются строки, которые принадлежат одному из кластеров. Там и цены и все остальные признаки остаются. Собственно, все.

[Удален]  
fxsaber #:

Почему тогда не ЗЗ?

Правда, нашел небольшое объяснение.

Наверное, выкидывание из ЗЗ-ряда некоторых вершин, дало бы тот же эффект.
import pandas as pd
from scipy.signal import find_peaks

@njit
def calculate_labels_zigzag(peaks, troughs, len_close):
    """
    Generates labels based on the occurrence of peaks and troughs in the data.

    Args:
        peaks (np.array): Indices of the peaks in the data.
        troughs (np.array): Indices of the troughs in the data.
        len_close (int): The length of the close prices.

    Returns:
        np.array: An array of labels.
    """
    labels = np.empty(len_close, dtype=np.float64)
    labels.fill(2.0)  # Initialize all labels to 2.0 (no signal)
    
    for i in range(len_close):
        if i in peaks:
            labels[i] = 1.0  # Sell signal at peaks
        elif i in troughs:
            labels[i] = 0.0  # Buy signal at troughs
    return labels

def get_labels_filter_ZZ(dataset, peak_prominence=0.1) -> pd.DataFrame:
    """
    Generates labels for a financial dataset based on zigzag peaks and troughs.

    This function identifies peaks and troughs in the closing prices using the 'find_peaks' 
    function from scipy.signal. It generates buy signals at troughs and sell signals at peaks.

    Args:
        dataset (pd.DataFrame): DataFrame containing financial data with a 'close' column.
        peak_prominence (float, optional): Minimum prominence of peaks and troughs, 
                                           used to filter out insignificant fluctuations. 
                                           Defaults to 0.1.

    Returns:
        pd.DataFrame: The original DataFrame with a new 'labels' column and filtered rows:
                       - 'labels' column: 
                            - 0: Buy
                            - 1: Sell
                       - Rows where 'labels' is 2 (no signal) are removed.
                       - Rows with missing values (NaN) are removed.
    """

    # Find peaks and troughs in the closing prices
    peaks, _ = find_peaks(dataset['close'], prominence=peak_prominence)
    troughs, _ = find_peaks(-dataset['close'], prominence=peak_prominence)
    
    # Calculate buy/sell labels using the new zigzag-based labeling function
    labels = calculate_labels_zigzag(peaks, troughs, len(dataset)) 

    # Add the calculated labels as a new 'labels' column to the DataFrame
    dataset['labels'] = labels

    # Remove rows where the 'labels' column has a value of 2.0 (no signal)
    dataset = dataset.drop(dataset[dataset.labels == 2.0].index)
    
    # Return the modified DataFrame 
    return dataset


[Удален]  
Maxim Dmitrievsky #:

Можете самостоятельно добавить этот код в библиотеку разметчиков сделок.

 
Maxim Dmitrievsky #:

Стало хуже.

[Удален]  
fxsaber #:

Стало хуже.

Да, но это в лоб, безо всяких ухищрений. 
 
Maxim Dmitrievsky #:

Возможно ли совмещать модели в МТ5? Допустим я выбрал топ-20, следовательно появилось 40 файлов onnx. Что делать в таком случае? 

[Удален]  
Evgeni Gavrilovi #:

Возможно ли совмещать модели в МТ5? Допустим я выбрал топ-20, следовательно появилось 40 файлов onnx. Что делать в таком случае? 

Статья не на эту тему. Ансамблирование не предусмотрено. 
Копий ботов можно сколько угодно создать.
 
Конечно можно было бы добавить просадки, а то смущают гладкие линии, предчувствую что там слив доходил до -80% а то и более)
[Удален]  
Evgeni Gavrilovi #:
Конечно можно было бы добавить просадки, а то смущают гладкие линии, предчувствую что там слив доходил до -80% а то и более)
Пожелания по улучшению статьи не принимаю, только обсуждение существующего/вопросы.
 

Добавил все основные признаки с модуля pandas. 

https://pandas.pydata.org/docs/reference/window.html

В итоге получил такой график. Максим, спасибо за ваш труд.


Window#
  • pandas.pydata.org
Window# instances are returned by calls: and . instances are returned by calls: and . instances are returned by calls: and . Rolling window functions# Weighted window functions# Expanding window functions# Exponentially-weighted window functions...