#!/usr/bin/env python
# coding: utf-8

def generate_lead_lag(lookback_windows, lead_lags, contravariants, ):
    parameters = []
    for contravariant in contravariants:
        for lookback_window in lookback_windows:
            for lead in lead_lags:
                if lead < lookback_window:
                    parameters.append({
                        'lead':lead,
                        'lookback_window':lookback_window,
                        'contravariant':contravariant
                    })
    return parameters

def generate_dd_threshold_lo(lookback_windows, up_thresholds, lags, contravariants):
    parameters = []
    for lookback_window in lookback_windows:
        for contravariant in contravariants:
            for up_threshold in up_thresholds:
                for lag in lags:
                    if lag <= int(lookback_window/2.):
                        parameters.append({
                            'lookback_window':lookback_window,
                            'contravariant':contravariant,
                            'up_threshold':up_threshold,
                            'lag':lag
                        })
    return parameters

def generate_dd_threshold_ls(lookback_windows, low_thresholds, up_thresholds, lags, contravariants):
    parameters = []
    for lookback_window in lookback_windows:
        for contravariant in contravariants:
            for low_threshold in low_thresholds:
                for up_threshold in up_thresholds:
                    for lag in lags:
                        if lag <= int(lookback_window/2.):
                            parameters.append({
                                'lookback_window':lookback_window,
                                'contravariant':contravariant,
                                'low_threshold':low_threshold,
                                'up_threshold':up_threshold,
                                'lag':lag
                            })
    return parameters

def generate_lookback_only(lookback_windows):
    parameters = []
    for lookback_window in lookback_windows:
                parameters.append({
                    'lookback_window':lookback_window
                })
    return parameters


def generate_lo_slope_ma(lookback_windows, pente_windows, contravariants,):
    parameters = []
    for lookback_window in lookback_windows:
        for pente_window in pente_windows:
            for contravariant in contravariants:
                if pente_window <= lookback_window:
                    parameters.append({
                        'lookback_window':lookback_window,
                        'pente_window':pente_window,
                        'contravariant':contravariant
                    })
    return parameters


# def generate_fourier_wvt_decomposition(lookback_windows,contravariants,n_harms,fft_filter_types,dec_levels,thresholds,obs_covs):
#     parameters = []
#     for lookback_window in lookback_windows:
#         for contravariant in contravariants:
#             for fft_filter_type in fft_filter_types:
#                 for n_harm in n_harms:
#                     for dec_level in dec_levels:
#                         for threshold in thresholds:
#                             for observation_covariance in obs_covs:
#                                 if n_harm < lookback_window:
#                                     parameters.append({
#                                         'lookback_window':lookback_window,
#                                         'contravariant':contravariant,
#                                         'fft_filter_type':fft_filter_type,
#                                         'n_harm':n_harm,
#                                         'dec_level':dec_level,
#                                         'threshold':threshold,
#                                         'observation_covariance':observation_covariance
#                                     })
#     return parameters

def generate_fourier_wvt_decomposition(lookback_windows,contravariants,n_harms,fft_filter_types,dec_levels,thresholds):
    parameters = []
    for lookback_window in lookback_windows:
        for contravariant in contravariants:
            for fft_filter_type in fft_filter_types:
                for n_harm in n_harms:
                    for dec_level in dec_levels:
                        for threshold in thresholds:
                                if n_harm < lookback_window:
                                    parameters.append({
                                        'lookback_window':lookback_window,
                                        'contravariant':contravariant,
                                        'fft_filter_type':fft_filter_type,
                                        'n_harm':n_harm,
                                        'dec_level':dec_level,
                                        'threshold':threshold,
                                    })
    return parameters

def generate_kalman(lookback_windows,contravariants,n_harms,fft_filter_types,thresholds,obs_covs):
    parameters = []
    for lookback_window in lookback_windows:
        for contravariant in contravariants:
            for fft_filter_type in fft_filter_types:
                for n_harm in n_harms:
                    for threshold in thresholds:
                        for observation_covariance in obs_covs:
                            if n_harm < lookback_window:
                                parameters.append({
                                    'lookback_window':lookback_window,
                                    'contravariant':contravariant,
                                    'fft_filter_type':fft_filter_type,
                                    'n_harm':n_harm,
                                    'threshold':threshold,
                                    'observation_covariance':observation_covariance
                                })
    return parameters

def generate_fourier_decomposition(lookback_windows,contravariants,n_harms,fft_filter_types,):
    parameters = []
    for lookback_window in lookback_windows:
        for contravariant in contravariants:
            for fft_filter_type in fft_filter_types:
                for n_harm in n_harms:
                    if n_harm<lookback_window:
                        parameters.append({
                            'lookback_window':lookback_window,
                            'fft_filter_type': fft_filter_type,
                            'contravariant':contravariant,
                            'n_harm':n_harm
                        })
    return parameters

def generate_lookback_contravariant(lookback_windows, contravariants):
    parameters = []
    for lookback_window in lookback_windows:
        for contravariant in contravariants:
            parameters.append({
                'lookback_window':lookback_window,
                'contravariant':contravariant
            })
    return parameters

def generate_alpha_5(lookback_windows, lags, contravariants):
    parameters = []
    for lookback_window in lookback_windows:
        for lag in lags:
            for contravariant in contravariants:
                if lag < int(lookback_window/2):
                    parameters.append({
                        'lookback_window':lookback_window,
                        'lag':lag,
                        'contravariant':contravariant
                    })
    return parameters

def generate_alpha_8(lookback_windows, contravariants, lags):
    parameters = []
    for lookback_window in lookback_windows:
        for lag in lags:
            for contravariant in contravariants:
                if lag <= lookback_window/4:
                    parameters.append({
                        'lookback_window':lookback_window,
                        'lag' : lag,
                        'contravariant':contravariant
                    })
    return parameters


def generate_alpha_16(lookback_windows, contravariants, lags):
    parameters = []
    for lookback_window in lookback_windows:
        for lag in lags:
            for contravariant in contravariants:
                if lag <= lookback_window/4 and lag >= 2:
                    parameters.append({
                        'lookback_window':lookback_window,
                        'lag' : lag,
                        'contravariant':contravariant
                    })
    return parameters

def generate_alpha_16_lo(lookback_windows, contravariants, lags, up_thresholds):
    parameters = []
    for lookback_window in lookback_windows:
        for up_threshold in up_thresholds:
            for lag in lags:
                for contravariant in contravariants:
                    if lag <= lookback_window/4 and lag >= 2:
                        parameters.append({
                            'lookback_window':lookback_window,
                            'lag' : lag,
                            'up_threshold': up_threshold,
                            'contravariant':contravariant
                        })
    return parameters

def generate_alpha_16_ls(lookback_windows, contravariants, lags, up_thresholds, low_thresholds):
    parameters = []
    for lookback_window in lookback_windows:
        for up_threshold in up_thresholds:
            for low_threshold in low_thresholds:
                for lag in lags:
                    for contravariant in contravariants:
                        if lag <= lookback_window/4 and lag >= 2:
                            parameters.append({
                                'lookback_window':lookback_window,
                                'lag' : lag,
                                'low_threshold': low_threshold,
                                'up_threshold': up_threshold,
                                'contravariant':contravariant
                            })
    return parameters
def generate_volume_weighted_high_low_vol_lo(lookback_windows, vol_thresholds, up_trend_thresholds, contravariants, lags, display):
    parameters = []
    for lookback_window in lookback_windows:
        for contravariant in contravariants:
            for vol_threshold in vol_thresholds:
                for up_trend_threshold in up_trend_thresholds:
                    for lag in lags:
                        if lag <= int(lookback_window/2):
                            parameters.append({
                                'lookback_window':lookback_window,
                                'contravariant':contravariant,
                                'vol_threshold':vol_threshold,
                                'up_trend_threshold':up_trend_threshold,
                                'lag':lag,
                                'display' : display
                            })
    return parameters

def generate_volume_weighted_high_low_vol_ls(lookback_windows, vol_thresholds, up_trend_thresholds,  low_trend_thresholds, contravariants, lags, display):
    parameters = []
    for lookback_window in lookback_windows:
        for contravariant in contravariants:
            for vol_threshold in vol_thresholds:
                for up_trend_threshold in up_trend_thresholds:
                    for low_trend_threshold in low_trend_thresholds:
                        for lag in lags:
                            if lag <= int(lookback_window/2):
                                parameters.append({
                                    'lookback_window':lookback_window,
                                    'contravariant':contravariant,
                                    'vol_threshold':vol_threshold,
                                    'up_trend_threshold':up_trend_threshold,
                                    'low_trend_threshold': low_trend_threshold,
                                    'lag':lag,
                                    'display' : display
                                })
    return parameters

def generate_lo_slope_ma(lookback_windows, pente_windows, contravariants,):
    parameters = []
    for lookback_window in lookback_windows:
        for pente_window in pente_windows:
            for contravariant in contravariants:
                if pente_window <= lookback_window:
                    parameters.append({
                        'lookback_window':lookback_window,
                        'pente_window':pente_window,
                        'contravariant':contravariant
                    })
    return parameters

def generate_slope_lo_induced(lookback_windows, pente_windows, contravariants, lags, slope_columns, up_trend_thresholds, display):
    parameters = []
    for slope_column in slope_columns:
        for lookback_window in lookback_windows:
            for pente_window in pente_windows:
                for contravariant in contravariants:
                    for lag in lags:
                        for up_trend_threshold in up_trend_thresholds:
                            if pente_window < int(lookback_window/lag):
                                if lag < int(lookback_window/2):
                                    parameters.append({
                                        'lookback_window':lookback_window,
                                        'pente_window':pente_window,
                                        'contravariant':contravariant,
                                        'up_trend_threshold': up_trend_threshold,
                                        'lag':lag,
                                        'slope_column': slope_column,
                                        'display' : display
                                    })
    return parameters

def generate_slope_ls_induced(lookback_windows, pente_windows, contravariants, lags, slope_columns, low_trend_thresholds, up_trend_thresholds, display):
    parameters = []
    for slope_column in slope_columns:
        for lookback_window in lookback_windows:
            for pente_window in pente_windows:
                for contravariant in contravariants:
                    for lag in lags:
                        for low_trend_threshold in low_trend_thresholds:
                            for up_trend_threshold in up_trend_thresholds:
                                if pente_window < int(lookback_window/lag):
                                    if lag < int(lookback_window/2):
                                        parameters.append({
                                            'lookback_window':lookback_window,
                                            'pente_window':pente_window,
                                            'contravariant':contravariant,
                                            'low_trend_threshold': low_trend_threshold,
                                            'up_trend_threshold': up_trend_threshold,
                                            'lag':lag,
                                            'slope_column': slope_column,
                                            'display' : display
                                        })
    return parameters

def generate_trending_rank_ls_induced(lookback_windows, contravariants, lags, slope_columns, up_trend_thresholds,  low_trend_thresholds, display):
    parameters = []
    for slope_column in slope_columns:
        for lookback_window in lookback_windows:
            for contravariant in contravariants:
                for lag in lags:
                    for up_trend_threshold in up_trend_thresholds:
                        for low_trend_threshold in low_trend_thresholds:
                            if lag <= int(lookback_window/2):
                                parameters.append({
                                    'lookback_window':lookback_window,
                                    'contravariant':contravariant,
                                    'up_trend_threshold': up_trend_threshold,
                                    'low_trend_threshold': low_trend_threshold,
                                    'lag':lag,
                                    'slope_column': slope_column,
                                    'display' : display
                                })
    return parameters

def generate_trending_rank_lo_induced(lookback_windows, contravariants, lags, slope_columns, up_trend_thresholds, display):
    parameters = []
    for slope_column in slope_columns:
        for lookback_window in lookback_windows:
            for contravariant in contravariants:
                for lag in lags:
                    for up_trend_threshold in up_trend_thresholds:
                        if lag <= int(lookback_window/2):
                            parameters.append({
                                'lookback_window':lookback_window,
                                'contravariant':contravariant,
                                'up_trend_threshold': up_trend_threshold,
                                'lag':lag,
                                'slope_column': slope_column,
                                'display' : display
                            })
    return parameters

def generate_slope_induced_cont(lookback_windows, contravariants, lags, slope_columns, display):
    parameters = []
    for slope_column in slope_columns:
        for lookback_window in lookback_windows:
            for contravariant in contravariants:
                for lag in lags:

                    if lag <= int(lookback_window/2):
                        parameters.append({
                            'lookback_window':lookback_window,
                            'contravariant':contravariant,
                            'lag':lag,
                            'slope_column': slope_column,
                            'display' : display
                        })
    return parameters


def generate_volume_weighted_high_low_vol_cont(lookback_windows, contravariants, lags, display):
    parameters = []
    for lookback_window in lookback_windows:
        for contravariant in contravariants:
            for lag in lags:
                if lag <= int(lookback_window/2):
                    parameters.append({
                        'lookback_window':lookback_window,
                        'contravariant':contravariant,
                        'lag':lag,
                        'display' : display
                    })
    return parameters