Exemplo n.º 1
0
def compare_dwt(date, x, file_name='comparewt.jpg'):

    ax = []
    labels = []
    l = len(x)
    ax.append(x[:l-10])
    labels.append("Часовий ряд")
    ax.append(compute_dwt(x, 'db2')[:l - 10])
    labels.append("Вейвлет Добеши")
    ax.append(compute_dwt(x, 'haar')[:l - 10])
    labels.append("Вейвлет Хаара")
    ax.append(compute_dwt(x, 'coif2')[:l - 10])
    labels.append("Вейвлет Койфлет")
    showPlotLabelsCompare(ax, date[:l-10], labels, file_name)
Exemplo n.º 2
0
def compare_dwt(date, x, file_name='comparewt.jpg'):

    ax = []
    labels = []
    l = len(x)
    ax.append(x[:l - 10])
    labels.append("Часовий ряд")
    ax.append(compute_dwt(x, 'db2')[:l - 10])
    labels.append("Вейвлет Добеши")
    ax.append(compute_dwt(x, 'haar')[:l - 10])
    labels.append("Вейвлет Хаара")
    ax.append(compute_dwt(x, 'coif2')[:l - 10])
    labels.append("Вейвлет Койфлет")
    showPlotLabelsCompare(ax, date[:l - 10], labels, file_name)
Exemplo n.º 3
0
def wavelet_reserch(date, x, type='macd', wavelet='db1'):

    tx = []
    x = exp_moving_average(x, 5)

    if type == 'hurst':
        tx = hurst(x)
    elif type == 'macd':
        tx = macd(x, 12, 26)

    ax = list()
    at = list()

    if type == 'hurst':
        division_line = 0
    else:
        division_line = .5
    splt_x, splt_date = split_timeline(tx, date, division_line=division_line)

    ax += list(splt_x)
    at += list(splt_date)

    wx = list()
    wt = list()
    wt += list(splt_date)

    wavelet_sum = []
    for t in splt_x:
        temp = compute_dwt(t, wavelet)
        wavelet_sum.append(temp)
    wx += list(wavelet_sum)

    # fx = list()
    # ft = list()
    # ft += list(splt_date)
    #
    # fft_sum = []
    # for t in splt_x:
    #     temp = np.fft.fft(t)
    #     fft_sum.append(temp)
    # fx += list(fft_sum)

    showPlot(date, x, 'w_x.png')

    # showPlotMixSeparate(ax, at, 'w_hurst.png')
    # showPlotMixSeparate(wx, wt, 'w_hurst_wt.png')
    # showPlotMixSeparate(fx, ft, 'w_hurst_fft.png')
    return ax, at, wx, wt


# hurst_research()
# macd_research()
Exemplo n.º 4
0
def wavelet_reserch(date, x, type='macd', wavelet='db1'):

    tx = []
    x = exp_moving_average(x, 5)

    if type == 'hurst':
        tx = hurst(x)
    elif type == 'macd':
        tx = macd(x, 12, 26)

    ax = list()
    at = list()

    if type == 'hurst':
        division_line = 0
    else:
        division_line = .5
    splt_x, splt_date = split_timeline(tx, date, division_line=division_line)

    ax += list(splt_x)
    at += list(splt_date)

    wx = list()
    wt = list()
    wt += list(splt_date)

    wavelet_sum = []
    for t in splt_x:
        temp = compute_dwt(t, wavelet)
        wavelet_sum.append(temp)
    wx += list(wavelet_sum)

    # fx = list()
    # ft = list()
    # ft += list(splt_date)
    #
    # fft_sum = []
    # for t in splt_x:
    #     temp = np.fft.fft(t)
    #     fft_sum.append(temp)
    # fx += list(fft_sum)

    showPlot(date, x, 'w_x.png')

    # showPlotMixSeparate(ax, at, 'w_hurst.png')
    # showPlotMixSeparate(wx, wt, 'w_hurst_wt.png')
    # showPlotMixSeparate(fx, ft, 'w_hurst_fft.png')
    return ax, at, wx, wt

# hurst_research()
# macd_research()