def get_cot_strategy_signals(**kwargs):

    ticker_head = kwargs['ticker_head']
    date_to = kwargs['date_to']

    datetime_to = cu.convert_doubledate_2datetime(date_to)

    data_out = gfp.get_futures_price_preloaded(ticker_head=ticker_head)
    data_out = data_out[data_out['settle_date'] <= datetime_to]

    data_out_front = data_out[data_out['tr_dte'] <= 60]
    data_out_front.drop_duplicates(subset=['settle_date'], keep='last', inplace=True)

    data_out_back = data_out[data_out['tr_dte'] > 60]
    data_out_back.drop_duplicates(subset=['settle_date'], keep='last', inplace=True)

    merged_data = pd.merge(data_out_front[['settle_date','tr_dte','close_price']],data_out_back[['tr_dte','close_price','settle_date','ticker','change_1']],how='inner',on='settle_date')
    merged_data['const_mat']=((merged_data['tr_dte_y']-60)*merged_data['close_price_x']+
                              (60-merged_data['tr_dte_x'])*merged_data['close_price_y'])/\
                             (merged_data['tr_dte_y']-merged_data['tr_dte_x'])

    cot_output = cot.get_cot_data(ticker_head=ticker_head,date_to=date_to)

    cot_output['comm_net'] = cot_output['Commercial Long']-cot_output['Commercial Short']
    cot_output['spec_net'] = cot_output['Noncommercial Long'] - cot_output['Noncommercial Short']

    cot_output['comm_min'] = cot_output['comm_net'].rolling(window=156, min_periods=156, center=False).min()
    cot_output['comm_max'] = cot_output['comm_net'].rolling(window=156, min_periods=156, center=False).max()
    cot_output['cot_index_slow'] = 100 * (cot_output['comm_net'] - cot_output['comm_min']) / (
                cot_output['comm_max'] - cot_output['comm_min'])

    cot_output['settle_date'] = [x+dt.timedelta(days=3) for x in cot_output['settle_date']]

    combined_data = pd.merge(merged_data,cot_output,how='inner',on='settle_date')

    return {'ticker_head':ticker_head,
            'success': True, 'cot_index_slow': cot_output['cot_index_slow'].iloc[-1],
            'combined_data': combined_data,}
def get_cot_strategy_signals(**kwargs):

    ticker_head = kwargs['ticker_head']
    date_to = kwargs['date_to']
    target_noise = 5000

    ticker_class = cmi.ticker_class[ticker_head]
    datetime_to = cu.convert_doubledate_2datetime(date_to)

    data_out = gfp.get_futures_price_preloaded(ticker_head=ticker_head)
    data_out = data_out[data_out['settle_date'] <= datetime_to]

    data_out_front = data_out[data_out['tr_dte'] <= 60]
    data_out_front.drop_duplicates(subset=['settle_date'], keep='last', inplace=True)

    data_out_back = data_out[data_out['tr_dte'] > 60]
    data_out_back.drop_duplicates(subset=['settle_date'], keep='last', inplace=True)

    merged_data = pd.merge(data_out_front[['settle_date','tr_dte','close_price']],data_out_back[['tr_dte','close_price','settle_date','ticker','change_1']],how='inner',on='settle_date')
    merged_data['const_mat']=((merged_data['tr_dte_y']-60)*merged_data['close_price_x']+
                              (60-merged_data['tr_dte_x'])*merged_data['close_price_y'])/\
                             (merged_data['tr_dte_y']-merged_data['tr_dte_x'])

    merged_data['const_mat_change_1'] = merged_data['const_mat']-merged_data['const_mat'].shift(1)
    merged_data['const_mat_change_10'] = merged_data['const_mat']-merged_data['const_mat'].shift(10)
    merged_data['const_mat_change_20'] = merged_data['const_mat']-merged_data['const_mat'].shift(20)

    merged_data['const_mat_change_1_std'] = pd.rolling_std(merged_data['const_mat_change_1'], window=150, min_periods=75)

    merged_data['const_mat_ma5'] = pd.rolling_mean(merged_data['const_mat'], window=5, min_periods=4)
    merged_data['const_mat_ma10'] = pd.rolling_mean(merged_data['const_mat'], window=10, min_periods=8)
    merged_data['const_mat_ma20'] = pd.rolling_mean(merged_data['const_mat'], window=20, min_periods=16)
    merged_data['const_mat_ma40'] = pd.rolling_mean(merged_data['const_mat'], window=40, min_periods=32)
    merged_data['const_mat_ma80'] = pd.rolling_mean(merged_data['const_mat'], window=80, min_periods=64)

    merged_data['const_mat_ma5spread'] = (merged_data['const_mat']-merged_data['const_mat_ma5'])/merged_data['const_mat_change_1_std']
    merged_data['const_mat_ma10spread'] = (merged_data['const_mat']-merged_data['const_mat_ma10'])/merged_data['const_mat_change_1_std']
    merged_data['const_mat_ma20spread'] = (merged_data['const_mat']-merged_data['const_mat_ma20'])/merged_data['const_mat_change_1_std']
    merged_data['const_mat_ma40spread'] = (merged_data['const_mat']-merged_data['const_mat_ma40'])/merged_data['const_mat_change_1_std']
    merged_data['const_mat_ma80spread'] = (merged_data['const_mat']-merged_data['const_mat_ma80'])/merged_data['const_mat_change_1_std']

    merged_data['const_mat_change1norm'] = (merged_data['const_mat'].shift(-1)-merged_data['const_mat'])/merged_data['const_mat_change_1_std']
    merged_data['const_mat_change2norm'] = (merged_data['const_mat'].shift(-2)-merged_data['const_mat'])/merged_data['const_mat_change_1_std']
    merged_data['const_mat_change5norm'] = (merged_data['const_mat'].shift(-5)-merged_data['const_mat'])/merged_data['const_mat_change_1_std']
    merged_data['const_mat_change10norm'] = (merged_data['const_mat'].shift(-10)-merged_data['const_mat'])/merged_data['const_mat_change_1_std']
    merged_data['const_mat_change20norm'] = (merged_data['const_mat'].shift(-20)-merged_data['const_mat'])/merged_data['const_mat_change_1_std']

    merged_data['const_mat_change_10_std'] = pd.rolling_std(merged_data['const_mat_change_10'], window=150, min_periods=75)
    merged_data['const_mat_change_20_std'] = pd.rolling_std(merged_data['const_mat_change_20'], window=150, min_periods=75)

    merged_data['const_mat_change_10_norm'] = merged_data['const_mat_change_10']/merged_data['const_mat_change_10_std']
    merged_data['const_mat_change_20_norm'] = merged_data['const_mat_change_20']/merged_data['const_mat_change_20_std']

    merged_data['const_mat_min5'] = pd.rolling_min(merged_data['const_mat'], window=5, min_periods=4)
    merged_data['const_mat_min10'] = pd.rolling_min(merged_data['const_mat'], window=10, min_periods=8)
    merged_data['const_mat_min20'] = pd.rolling_min(merged_data['const_mat'], window=20, min_periods=16)

    merged_data['const_mat_max5'] = pd.rolling_max(merged_data['const_mat'], window=5, min_periods=4)
    merged_data['const_mat_max10'] = pd.rolling_max(merged_data['const_mat'], window=10, min_periods=8)
    merged_data['const_mat_max20'] = pd.rolling_max(merged_data['const_mat'], window=20, min_periods=16)

    cot_output = cot.get_cot_data(ticker_head=ticker_head,date_to=date_to)

    if ticker_class in ['FX','STIR','Index','Treasury']:

        cot_output['comm_net'] = cot_output['Dealer Longs']-cot_output['Dealer Shorts']
        cot_output['comm_long'] = cot_output['Dealer Longs']
        cot_output['comm_short'] = cot_output['Dealer Shorts']
        cot_output['spec_net'] = cot_output['Asset Manager Longs']-cot_output['Asset Manager Shorts']+cot_output['Leveraged Funds Longs']-cot_output['Leveraged Funds Shorts']
        cot_output['spec_long'] = cot_output['Asset Manager Longs']+cot_output['Leveraged Funds Longs']
        cot_output['spec_short'] = cot_output['Asset Manager Shorts']+cot_output['Leveraged Funds Shorts']
    else:
        cot_output['comm_net'] = cot_output['Producer/Merchant/Processor/User Longs']-cot_output['Producer/Merchant/Processor/User Shorts']
        cot_output['comm_long'] = cot_output['Producer/Merchant/Processor/User Longs']
        cot_output['comm_short'] = cot_output['Producer/Merchant/Processor/User Shorts']
        cot_output['spec_net'] = cot_output['Money Manager Longs']-cot_output['Money Manager Shorts']
        cot_output['spec_long'] = cot_output['Money Manager Longs']
        cot_output['spec_short'] = cot_output['Money Manager Shorts']


    cot_output['spec_long_per_mean'] = pd.rolling_mean(cot_output['spec_long_per'],window=150,min_periods=75)
    cot_output['spec_short_per_mean'] = pd.rolling_mean(cot_output['spec_short_per'],window=150,min_periods=75)




    cot_output['comm_net_change_1'] = cot_output['comm_net']-cot_output['comm_net'].shift(1)
    cot_output['comm_net_change_2'] = cot_output['comm_net']-cot_output['comm_net'].shift(2)
    cot_output['comm_net_change_4'] = cot_output['comm_net']-cot_output['comm_net'].shift(4)

    cot_output['spec_net_change_1'] = cot_output['spec_net']-cot_output['spec_net'].shift(1)
    cot_output['spec_net_change_2'] = cot_output['spec_net']-cot_output['spec_net'].shift(2)
    cot_output['spec_net_change_4'] = cot_output['spec_net']-cot_output['spec_net'].shift(4)

    cot_output['comm_long_change_1'] = cot_output['comm_long']-cot_output['comm_long'].shift(1)
    cot_output['comm_short_change_1'] = cot_output['comm_short']-cot_output['comm_short'].shift(1)

    cot_output['comm_net_change_1_std'] = pd.rolling_std(cot_output['comm_net_change_1'], window=150, min_periods=75)
    cot_output['comm_net_change_2_std'] = pd.rolling_std(cot_output['comm_net_change_2'], window=150, min_periods=75)
    cot_output['comm_net_change_4_std'] = pd.rolling_std(cot_output['comm_net_change_4'], window=150, min_periods=75)

    cot_output['spec_net_change_1_std'] = pd.rolling_std(cot_output['spec_net_change_1'], window=150, min_periods=75)
    cot_output['spec_net_change_2_std'] = pd.rolling_std(cot_output['spec_net_change_2'], window=150, min_periods=75)
    cot_output['spec_net_change_4_std'] = pd.rolling_std(cot_output['spec_net_change_4'], window=150, min_periods=75)

    cot_output['comm_long_change_1_std'] = pd.rolling_std(cot_output['comm_long_change_1'], window=150, min_periods=75)
    cot_output['comm_short_change_1_std'] = pd.rolling_std(cot_output['comm_short_change_1'], window=150, min_periods=75)

    cot_output['comm_net_change_1_norm'] = cot_output['comm_net_change_1']/cot_output['comm_net_change_1_std']
    cot_output['comm_net_change_2_norm'] = cot_output['comm_net_change_2']/cot_output['comm_net_change_2_std']
    cot_output['comm_net_change_4_norm'] = cot_output['comm_net_change_4']/cot_output['comm_net_change_4_std']

    cot_output['spec_net_change_1_norm'] = cot_output['spec_net_change_1']/cot_output['spec_net_change_1_std']
    cot_output['spec_net_change_2_norm'] = cot_output['spec_net_change_2']/cot_output['spec_net_change_2_std']
    cot_output['spec_net_change_4_norm'] = cot_output['spec_net_change_4']/cot_output['spec_net_change_4_std']

    cot_output['comm_long_change_1_norm'] = cot_output['comm_long_change_1']/cot_output['comm_long_change_1_std']
    cot_output['comm_short_change_1_norm'] = cot_output['comm_short_change_1']/cot_output['comm_short_change_1_std']

    cot_output['comm_net_mean'] = pd.rolling_mean(cot_output['comm_net'],window=150,min_periods=75)
    cot_output['spec_net_mean'] = pd.rolling_mean(cot_output['spec_net'],window=150,min_periods=75)

    cot_output['comm_net_std'] = pd.rolling_std(cot_output['comm_net'],window=150,min_periods=75)
    cot_output['spec_net_std'] = pd.rolling_std(cot_output['spec_net'],window=150,min_periods=75)

    cot_output['comm_z'] = (cot_output['comm_net']-cot_output['comm_net_mean'])/cot_output['comm_net_std']
    cot_output['spec_z'] = (cot_output['spec_net']-cot_output['spec_net_mean'])/cot_output['spec_net_std']

    cot_output['settle_date'] = cot_output.index
    cot_output['settle_date'] = [x+dt.timedelta(days=3) for x in cot_output['settle_date']]

    combined_data = pd.merge(merged_data,cot_output,how='left',on='settle_date')

    combined_data['comm_net_change_1_norm'] = combined_data['comm_net_change_1_norm'].fillna(method='pad')
    combined_data['comm_net_change_2_norm'] = combined_data['comm_net_change_2_norm'].fillna(method='pad')
    combined_data['comm_net_change_4_norm'] = combined_data['comm_net_change_4_norm'].fillna(method='pad')

    combined_data['spec_net_change_1_norm'] = combined_data['spec_net_change_1_norm'].fillna(method='pad')
    combined_data['spec_net_change_2_norm'] = combined_data['spec_net_change_2_norm'].fillna(method='pad')
    combined_data['spec_net_change_4_norm'] = combined_data['spec_net_change_4_norm'].fillna(method='pad')

    combined_data['comm_z'] = combined_data['comm_z'].fillna(method='pad')
    combined_data['spec_z'] = combined_data['spec_z'].fillna(method='pad')

    position = 0
    position_list = []
    entry_index_list = []
    exit_index_list = []
    entry_price_list = []
    exit_price_list = []

    for i in range(len(combined_data.index)):

        spec_change1_signal = combined_data['spec_net_change_1_norm'].iloc[i]
        spec_change4_signal = combined_data['spec_net_change_4_norm'].iloc[i]
        spec_z_signal = combined_data['spec_z'].iloc[i]
        price_i = combined_data['const_mat'].iloc[i]

        min_10 = combined_data['const_mat_min10'].iloc[i]
        max_10 = combined_data['const_mat_max10'].iloc[i]
        min_20 = combined_data['const_mat_min20'].iloc[i]
        max_20 = combined_data['const_mat_max20'].iloc[i]

        const_mat_change_10_norm = combined_data['const_mat_change_10_norm'].iloc[i]
        const_mat_change_20_norm = combined_data['const_mat_change_20_norm'].iloc[i]

        if i == len(combined_data.index)-1:
            if position != 0:
                exit_index_list.append(i)
                exit_price_list.append(price_i)
            break

        price_i1 = combined_data['const_mat'].iloc[i+1]

        if (position == 0) and (spec_z_signal>0.5) and (price_i==min_10):
            position = 1
            position_list.append(position)
            entry_index_list.append(i)
            entry_price_list.append(price_i1)
        elif (position == 0) and (spec_z_signal<-0.5) and (price_i==max_10):
            position = -1
            position_list.append(position)
            entry_index_list.append(i)
            entry_price_list.append(price_i1)
        elif (position == 1) and ((price_i==min_20)):
            position = 0
            exit_index_list.append(i)
            exit_price_list.append(price_i1)
        elif (position == -1) and ((price_i==max_20)):
            position = 0
            exit_index_list.append(i)
            exit_price_list.append(price_i1)

    return {'combined_data': combined_data}
def get_fm_signals(**kwargs):

    ticker_head = kwargs['ticker_head']
    date_to = kwargs['date_to']

    #print(ticker_head)

    ticker_class = cmi.ticker_class[ticker_head]

    datetime_to = cu.convert_doubledate_2datetime(date_to)

    date5_years_ago = cu.doubledate_shift(date_to,5*365)
    datetime5_years_ago = cu.convert_doubledate_2datetime(date5_years_ago)

    data_out = gfp.get_futures_price_preloaded(ticker_head=ticker_head,settle_date_to=datetime_to)

    data4day = data_out[data_out['settle_date']==datetime_to]
    data4day = data4day[data4day['tr_dte']>=20]

    if len(data4day.index)<2:
        return {'ticker': '', 'comm_net': np.nan, 'spec_net': np.nan,
            'comm_cot_index_slow': np.nan, 'comm_cot_index_fast': np.nan, 'trend_direction': np.nan,'curve_slope': np.nan,
            'rsi_3': np.nan, 'rsi_7': np.nan, 'rsi_14': np.nan,
            'change1': np.nan,
            'change1_instant': np.nan,
            'change5': np.nan,
            'change10': np.nan,
            'change20': np.nan,
            'change1_dollar': np.nan,
            'change1_instant_dollar': np.nan,
            'change5_dollar': np.nan,
            'change10_dollar': np.nan,
            'change20_dollar': np.nan}

    data4day.sort_values('volume', ascending=False, inplace=True)
    data4day = data4day.iloc[:2]

    data4day.sort_values('tr_dte',ascending=True,inplace=True)

    ticker1 = data4day['ticker'].iloc[0]
    ticker2 = data4day['ticker'].iloc[1]

    tr_dte_list = [data4day['tr_dte'].iloc[0], data4day['tr_dte'].iloc[1]]

    amcb_output = opUtil.get_aggregation_method_contracts_back({'ticker_head': ticker_head, 'ticker_class': cmi.ticker_class[ticker_head]})
    aggregation_method = amcb_output['aggregation_method']
    contracts_back = amcb_output['contracts_back']

    futures_data_dictionary = {ticker_head: data_out}

    aligned_output = opUtil.get_aligned_futures_data(contract_list=[ticker1,ticker2],
                                                          tr_dte_list=tr_dte_list,
                                                          aggregation_method=aggregation_method,
                                                          contracts_back=contracts_back,
                                                          date_to=date_to,
                                                          futures_data_dictionary=futures_data_dictionary,
                                                          use_last_as_current=False)

    aligned_data = aligned_output['aligned_data']
    current_data = aligned_output['current_data']

    yield1_current = 100*(current_data['c1']['close_price']-current_data['c2']['close_price'])/current_data['c2']['close_price']
    yield1 = 100*(aligned_data['c1']['close_price']-aligned_data['c2']['close_price'])/aligned_data['c2']['close_price']

    last5_years_indx = aligned_data['settle_date']>=datetime5_years_ago

    yield1_last5_years = yield1[last5_years_indx]
    curve_slope = stats.get_quantile_from_number({'x':yield1_current,'y': yield1_last5_years})

    ticker_head_data = gfp.get_futures_price_preloaded(ticker_head=ticker_head)
    ticker_head_data = ticker_head_data[ticker_head_data['settle_date'] <= datetime_to]

    if ticker_class in ['Index', 'FX', 'Metal', 'Treasury', 'STIR']:

        merged_data = ticker_head_data[ticker_head_data['tr_dte'] >= 10]
        merged_data.sort_values(['settle_date', 'tr_dte'],ascending=True,inplace=True)
        merged_data.drop_duplicates(subset=['settle_date'], keep='first', inplace=True)

        merged_data['ma200'] = merged_data['close_price'].rolling(200).mean()
        merged_data['ma200_10'] = merged_data['ma200']-merged_data['ma200'].shift(10)
    else:
        data_out_front = ticker_head_data[ticker_head_data['tr_dte'] <= 60]
        data_out_front.drop_duplicates(subset=['settle_date'], keep='last', inplace=True)

        data_out_back = ticker_head_data[ticker_head_data['tr_dte'] > 60]
        data_out_back.drop_duplicates(subset=['settle_date'], keep='last', inplace=True)

        merged_data = pd.merge(data_out_front[['settle_date','tr_dte','close_price']],data_out_back[['tr_dte','close_price','settle_date','ticker','change_1']],how='inner',on='settle_date')
        merged_data['const_mat']=((merged_data['tr_dte_y']-60)*merged_data['close_price_x']+
                                  (60-merged_data['tr_dte_x'])*merged_data['close_price_y'])/\
                                 (merged_data['tr_dte_y']-merged_data['tr_dte_x'])

        merged_data['ma200'] = merged_data['const_mat'].rolling(200).mean()
        merged_data['ma200_10'] = merged_data['ma200']-merged_data['ma200'].shift(10)

    merged_data = merged_data[merged_data['settle_date']==datetime_to]

    if len(merged_data.index) == 0:
        trend_direction = np.nan
    elif merged_data['ma200_10'].iloc[0]>=0:
        trend_direction = 1
    else:
        trend_direction = -1

    ticker_data = gfp.get_futures_price_preloaded(ticker=ticker2,settle_date_to=datetime_to)

    ticker_data = ti.rsi(data_frame_input=ticker_data, change_field='change_1', period=3)
    ticker_data = ti.rsi(data_frame_input=ticker_data, change_field='change_1', period=7)
    ticker_data = ti.rsi(data_frame_input=ticker_data, change_field='change_1', period=14)

    cot_output = cot.get_cot_data(ticker_head=ticker_head, date_to=date_to)

    daily_noise = np.std(ticker_data['change_1'].iloc[-60:])

    if len(cot_output.index)>0:

        if ticker_class in ['FX','STIR','Index','Treasury']:

            cot_output['comm_long'] = cot_output['Asset Manager Longs']+cot_output['Dealer Longs']
            cot_output['comm_short'] = cot_output['Asset Manager Shorts']+cot_output['Dealer Shorts']
            cot_output['comm_net'] = cot_output['comm_long']-cot_output['comm_short']

            cot_output['spec_long'] = cot_output['Leveraged Funds Longs']
            cot_output['spec_short'] = cot_output['Leveraged Funds Shorts']
            cot_output['spec_net'] = cot_output['spec_long']-cot_output['spec_short']

        else:
            cot_output['comm_long'] = cot_output['Producer/Merchant/Processor/User Longs']+cot_output['Swap Dealer Longs']
            cot_output['comm_short'] = cot_output['Producer/Merchant/Processor/User Shorts']+cot_output['Swap Dealer Shorts']
            cot_output['comm_net'] = cot_output['comm_long']-cot_output['comm_short']
            cot_output['spec_long'] = cot_output['Money Manager Longs']+cot_output['Other Reportable Longs']
            cot_output['spec_short'] = cot_output['Money Manager Shorts']+cot_output['Other Reportable Shorts']
            cot_output['spec_net'] = cot_output['spec_long']-cot_output['spec_short']

        if (datetime_to-cot_output['settle_date'].iloc[-1]).days>=10:
            comm_net = np.nan
            spec_net = np.nan
        else:
            comm_net = cot_output['comm_net'].iloc[-1]
            spec_net = cot_output['spec_net'].iloc[-1]

        comm_net_min_slow = cot_output['comm_net'].iloc[-156:].min()
        comm_net_max_slow = cot_output['comm_net'].iloc[-156:].max()

        comm_cot_index_slow = 100*(comm_net-comm_net_min_slow)/(comm_net_max_slow-comm_net_min_slow)

        comm_net_min_fast = cot_output['comm_net'].iloc[-52:].min()
        comm_net_max_fast = cot_output['comm_net'].iloc[-52:].max()

        comm_cot_index_fast = 100*(comm_net-comm_net_min_fast)/(comm_net_max_fast-comm_net_min_fast)

    else:
        comm_net = np.nan
        spec_net = np.nan
        comm_cot_index_slow = np.nan
        comm_cot_index_fast = np.nan

    contract_multiplier = cmi.contract_multiplier[ticker_head]

    return {'ticker': ticker2, 'comm_net': comm_net, 'spec_net': spec_net,
            'comm_cot_index_slow': comm_cot_index_slow, 'comm_cot_index_fast': comm_cot_index_fast, 'trend_direction': trend_direction,'curve_slope': curve_slope,
            'rsi_3': ticker_data['rsi_3'].iloc[-1], 'rsi_7': ticker_data['rsi_7'].iloc[-1], 'rsi_14': ticker_data['rsi_14'].iloc[-1],
            'change1': ticker_data['change1'].iloc[-1]/daily_noise,
            'change1_instant': ticker_data['change1_instant'].iloc[-1]/daily_noise,
            'change5': ticker_data['change5'].iloc[-1]/daily_noise,
            'change10': ticker_data['change10'].iloc[-1]/daily_noise,
            'change20': ticker_data['change20'].iloc[-1]/daily_noise,
            'change1_dollar': ticker_data['change1'].iloc[-1]*contract_multiplier,
            'change1_instant_dollar': ticker_data['change1_instant'].iloc[-1]*contract_multiplier,
            'change5_dollar': ticker_data['change5'].iloc[-1]*contract_multiplier,
            'change10_dollar': ticker_data['change10'].iloc[-1]*contract_multiplier,
            'change20_dollar': ticker_data['change20'].iloc[-1]*contract_multiplier}
def get_results_4tickerhead(**kwargs):

    ticker_head = kwargs['ticker_head']
    date_to = kwargs['date_to']

    ticker_class = cmi.ticker_class[ticker_head]

    indicator_list = [
        'change_1_high_volume', 'change_5_high_volume',
        'change_10_high_volume', 'change_20_high_volume',
        'change_1_low_volume', 'change_5_low_volume', 'change_10_low_volume',
        'change_20_low_volume', 'change_1Normalized', 'change_5Normalized',
        'change_10Normalized', 'change_20Normalized',
        'comm_net_change_1_normalized', 'comm_net_change_2_normalized',
        'comm_net_change_4_normalized', 'spec_net_change_1_normalized',
        'spec_net_change_2_normalized', 'spec_net_change_4_normalized',
        'comm_z', 'spec_z'
    ]

    date_from = cu.doubledate_shift(date_to, 5 * 365)

    datetime_to = cu.convert_doubledate_2datetime(date_to)

    panel_data = gfp.get_futures_price_preloaded(ticker_head=ticker_head,
                                                 settle_date_from=date_from,
                                                 settle_date_to=date_to)
    panel_data = panel_data[panel_data['tr_dte'] >= 40]

    panel_data.sort(['settle_date', 'tr_dte'],
                    ascending=[True, True],
                    inplace=True)
    rolling_data = panel_data.drop_duplicates(subset=['settle_date'],
                                              take_last=False)

    daily_noise = np.std(rolling_data['change_1'])
    average_volume = rolling_data['volume'].mean()

    rolling_data['change_40'] = pd.rolling_sum(rolling_data['change_1'],
                                               40,
                                               min_periods=30)
    rolling_data['change_20'] = pd.rolling_sum(rolling_data['change_1'],
                                               20,
                                               min_periods=15)
    rolling_data['change_10'] = pd.rolling_sum(rolling_data['change_1'],
                                               10,
                                               min_periods=7)

    rolling_data['change_1Normalized'] = rolling_data['change_1'] / daily_noise
    rolling_data['change_5Normalized'] = rolling_data['change_5'] / daily_noise
    rolling_data[
        'change_10Normalized'] = rolling_data['change_10'] / daily_noise
    rolling_data[
        'change_20Normalized'] = rolling_data['change_20'] / daily_noise
    rolling_data[
        'change_40Normalized'] = rolling_data['change_40'] / daily_noise

    rolling_data['change1Normalized'] = rolling_data['change1'] / daily_noise
    rolling_data['change1_InstantNormalized'] = rolling_data[
        'change1_instant'] / daily_noise

    rolling_data['change1_InstantNormalized'] = rolling_data[
        'change1_instant'] / daily_noise
    rolling_data['high1_InstantNormalized'] = (
        rolling_data['high1_instant'] -
        rolling_data['close_price']) / daily_noise
    rolling_data['low1_InstantNormalized'] = (
        rolling_data['low1_instant'] -
        rolling_data['close_price']) / daily_noise

    rolling_data['change5Normalized'] = rolling_data['change5'] / daily_noise
    rolling_data['change10Normalized'] = rolling_data['change10'] / daily_noise
    rolling_data['change20Normalized'] = rolling_data['change20'] / daily_noise

    rolling_data['volume_mean20'] = pd.rolling_mean(rolling_data['volume'],
                                                    20,
                                                    min_periods=15)
    rolling_data['volume_mean10'] = pd.rolling_mean(rolling_data['volume'],
                                                    10,
                                                    min_periods=7)
    rolling_data['volume_mean5'] = pd.rolling_mean(rolling_data['volume'],
                                                   5,
                                                   min_periods=4)

    rolling_data['volume_mean20Normalized'] = rolling_data[
        'volume_mean20'] / average_volume
    rolling_data['volume_mean10Normalized'] = rolling_data[
        'volume_mean10'] / average_volume
    rolling_data['volume_mean5Normalized'] = rolling_data[
        'volume_mean5'] / average_volume
    rolling_data['volume_Normalized'] = rolling_data['volume'] / average_volume

    rolling_data['change_1_high_volume'] = (
        rolling_data['volume'] >
        average_volume) * rolling_data['change_1Normalized']
    rolling_data['change_5_high_volume'] = (
        rolling_data['volume_mean5'] >
        average_volume) * rolling_data['change_5Normalized']
    rolling_data['change_10_high_volume'] = (
        rolling_data['volume_mean10'] >
        average_volume) * rolling_data['change_10Normalized']
    rolling_data['change_20_high_volume'] = (
        rolling_data['volume_mean20'] >
        average_volume) * rolling_data['change_20Normalized']

    rolling_data['change_1_low_volume'] = (
        rolling_data['volume'] <=
        average_volume) * rolling_data['change_1Normalized']
    rolling_data['change_5_low_volume'] = (
        rolling_data['volume_mean5'] <=
        average_volume) * rolling_data['change_5Normalized']
    rolling_data['change_10_low_volume'] = (
        rolling_data['volume_mean10'] <=
        average_volume) * rolling_data['change_10Normalized']
    rolling_data['change_20_low_volume'] = (
        rolling_data['volume_mean20'] <=
        average_volume) * rolling_data['change_20Normalized']

    cot_output = cot.get_cot_data(ticker_head=ticker_head,
                                  date_from=date_from,
                                  date_to=date_to)

    dictionary_out = {
        'vote1': np.nan,
        'vote1_instant': np.nan,
        'vote12_instant': np.nan,
        'vote13_instant': np.nan,
        'vote5': np.nan,
        'vote10': np.nan,
        'vote20': np.nan,
        'regress_forecast1': np.nan,
        'regress_forecast2': np.nan,
        'regress_forecast3': np.nan,
        'svr_forecast1': np.nan,
        'svr_forecast2': np.nan,
        'norm_pnl1': np.nan,
        'norm_pnl1Instant': np.nan,
        'long_tight_stop_pnl1Instant': np.nan,
        'long_loose_stop_pnl1Instant': np.nan,
        'short_tight_stop_pnl1Instant': np.nan,
        'short_loose_stop_pnl1Instant': np.nan,
        'norm_pnl5': np.nan,
        'norm_pnl10': np.nan,
        'norm_pnl20': np.nan,
        'rolling_data': pd.DataFrame()
    }

    for ind in indicator_list:
        dictionary_out[ind] = np.nan

    if len(cot_output.index) < 20:
        return dictionary_out

    cot_net = pd.DataFrame()

    if ticker_class in ['FX', 'STIR', 'Index', 'Treasury']:
        cot_net['comm_net'] = cot_output['Dealer Longs'] - cot_output[
            'Dealer Shorts']
        cot_net['spec_net'] = cot_output['Asset Manager Longs'] - cot_output[
            'Asset Manager Shorts'] + cot_output[
                'Leveraged Funds Longs'] - cot_output['Leveraged Funds Shorts']
    else:
        cot_net['comm_net'] = cot_output[
            'Producer/Merchant/Processor/User Longs'] - cot_output[
                'Producer/Merchant/Processor/User Shorts']
        cot_net['spec_net'] = cot_output['Money Manager Longs'] - cot_output[
            'Money Manager Shorts']

    cot_net['comm_net_change_1'] = cot_net['comm_net'] - cot_net[
        'comm_net'].shift(1)
    cot_net['comm_net_change_2'] = cot_net['comm_net'] - cot_net[
        'comm_net'].shift(2)
    cot_net['comm_net_change_4'] = cot_net['comm_net'] - cot_net[
        'comm_net'].shift(4)

    cot_net['spec_net_change_1'] = cot_net['spec_net'] - cot_net[
        'spec_net'].shift(1)
    cot_net['spec_net_change_2'] = cot_net['spec_net'] - cot_net[
        'spec_net'].shift(2)
    cot_net['spec_net_change_4'] = cot_net['spec_net'] - cot_net[
        'spec_net'].shift(4)

    comm_net_change_1_avg = np.std(cot_net['comm_net_change_1'])
    comm_net_change_2_avg = np.std(cot_net['comm_net_change_2'])
    comm_net_change_4_avg = np.std(cot_net['comm_net_change_4'])
    spec_net_change_1_avg = np.std(cot_net['spec_net_change_1'])
    spec_net_change_2_avg = np.std(cot_net['spec_net_change_2'])
    spec_net_change_4_avg = np.std(cot_net['spec_net_change_4'])

    cot_net['comm_net_change_1_normalized'] = cot_net[
        'comm_net_change_1'] / comm_net_change_1_avg
    cot_net['comm_net_change_2_normalized'] = cot_net[
        'comm_net_change_2'] / comm_net_change_2_avg
    cot_net['comm_net_change_4_normalized'] = cot_net[
        'comm_net_change_4'] / comm_net_change_4_avg

    cot_net['spec_net_change_1_normalized'] = cot_net[
        'spec_net_change_1'] / spec_net_change_1_avg
    cot_net['spec_net_change_2_normalized'] = cot_net[
        'spec_net_change_2'] / spec_net_change_2_avg
    cot_net['spec_net_change_4_normalized'] = cot_net[
        'spec_net_change_4'] / spec_net_change_4_avg

    cot_net['comm_z'] = (cot_net['comm_net'] - np.mean(
        cot_net['comm_net'])) / np.std(cot_net['comm_net'])
    cot_net['spec_z'] = (cot_net['spec_net'] - np.mean(
        cot_net['spec_net'])) / np.std(cot_net['spec_net'])

    cot_net['settle_date'] = cot_net.index
    cot_net['settle_date'] = [
        x + dt.timedelta(days=3) for x in cot_net['settle_date']
    ]

    combined_data = pd.merge(rolling_data,
                             cot_net,
                             how='left',
                             on='settle_date')

    combined_data['comm_net_change_1_normalized'] = combined_data[
        'comm_net_change_1_normalized'].fillna(method='pad')
    combined_data['comm_net_change_2_normalized'] = combined_data[
        'comm_net_change_2_normalized'].fillna(method='pad')
    combined_data['comm_net_change_4_normalized'] = combined_data[
        'comm_net_change_4_normalized'].fillna(method='pad')

    combined_data['spec_net_change_1_normalized'] = combined_data[
        'spec_net_change_1_normalized'].fillna(method='pad')
    combined_data['spec_net_change_2_normalized'] = combined_data[
        'spec_net_change_2_normalized'].fillna(method='pad')
    combined_data['spec_net_change_4_normalized'] = combined_data[
        'spec_net_change_4_normalized'].fillna(method='pad')

    combined_data['comm_z'] = combined_data['comm_z'].fillna(method='pad')
    combined_data['spec_z'] = combined_data['spec_z'].fillna(method='pad')

    test_data = combined_data[combined_data['settle_date'] == datetime_to]
    training_data = combined_data[combined_data['settle_date'] < datetime_to +
                                  dt.timedelta(days=-30)]

    if test_data.empty or training_data.empty:
        return dictionary_out

    sharp1_list = []
    sharp1_instant_list = []
    sharp5_list = []
    sharp10_list = []
    sharp20_list = []
    higher_level_list = []
    lower_level_list = []

    for i in range(len(indicator_list)):
        selected_data = training_data[training_data[
            indicator_list[i]].notnull()]
        indicator_levels = stats.get_number_from_quantile(
            y=selected_data[indicator_list[i]].values, quantile_list=[10, 90])
        lower_level_list.append(indicator_levels[0])
        higher_level_list.append(indicator_levels[1])
        low_data = selected_data[
            selected_data[indicator_list[i]] < indicator_levels[0]]
        high_data = selected_data[
            selected_data[indicator_list[i]] > indicator_levels[1]]
        high_data['pnl1'] = high_data['change1Normalized']
        low_data['pnl1'] = -low_data['change1Normalized']

        high_data['pnl1_instant'] = high_data['change1_InstantNormalized']
        low_data['pnl1_instant'] = -low_data['change1_InstantNormalized']

        high_data['pnl5'] = high_data['change5Normalized']
        low_data['pnl5'] = -low_data['change5Normalized']

        high_data['pnl10'] = high_data['change10Normalized']
        low_data['pnl10'] = -low_data['change10Normalized']

        high_data['pnl20'] = high_data['change20Normalized']
        low_data['pnl20'] = -low_data['change20Normalized']
        merged_data = pd.concat([high_data, low_data])
        sharp1_list.append(16 * merged_data['pnl1'].mean() /
                           merged_data['pnl1'].std())
        sharp1_instant_list.append(16 * merged_data['pnl1_instant'].mean() /
                                   merged_data['pnl1_instant'].std())
        sharp5_list.append(7.2 * merged_data['pnl5'].mean() /
                           merged_data['pnl5'].std())
        sharp10_list.append(5.1 * merged_data['pnl10'].mean() /
                            merged_data['pnl10'].std())
        sharp20_list.append(3.5 * merged_data['pnl20'].mean() /
                            merged_data['pnl20'].std())

    sharp_frame = pd.DataFrame.from_items([('indicator', indicator_list),
                                           ('lower_level', lower_level_list),
                                           ('higher_level', higher_level_list),
                                           ('sharp1', sharp1_list),
                                           ('sharp1_instant',
                                            sharp1_instant_list),
                                           ('sharp5', sharp5_list),
                                           ('sharp10', sharp10_list),
                                           ('sharp20', sharp20_list)])

    vote1 = 0

    for i in range(len(indicator_list)):
        indicator_value = test_data[indicator_list[i]].iloc[0]
        selected_sharp_row = sharp_frame[sharp_frame['indicator'] ==
                                         indicator_list[i]]

        if (selected_sharp_row['sharp1'].iloc[0] > 0.75) & (
                indicator_value > selected_sharp_row['higher_level'].iloc[0]):
            vote1 += 1
        elif (selected_sharp_row['sharp1'].iloc[0] > 0.75) & (
                indicator_value < selected_sharp_row['lower_level'].iloc[0]):
            vote1 -= 1
        elif (selected_sharp_row['sharp1'].iloc[0] < -0.75) & (
                indicator_value > selected_sharp_row['higher_level'].iloc[0]):
            vote1 -= 1
        elif (selected_sharp_row['sharp1'].iloc[0] < -0.75) & (
                indicator_value < selected_sharp_row['lower_level'].iloc[0]):
            vote1 += 1

    vote1_instant = 0

    for i in range(len(indicator_list)):
        indicator_value = test_data[indicator_list[i]].iloc[0]
        selected_sharp_row = sharp_frame[sharp_frame['indicator'] ==
                                         indicator_list[i]]

        if (selected_sharp_row['sharp1_instant'].iloc[0] > 0.75) & (
                indicator_value > selected_sharp_row['higher_level'].iloc[0]):
            vote1_instant += 1
        elif (selected_sharp_row['sharp1_instant'].iloc[0] > 0.75) & (
                indicator_value < selected_sharp_row['lower_level'].iloc[0]):
            vote1_instant -= 1
        elif (selected_sharp_row['sharp1_instant'].iloc[0] < -0.75) & (
                indicator_value > selected_sharp_row['higher_level'].iloc[0]):
            vote1_instant -= 1
        elif (selected_sharp_row['sharp1_instant'].iloc[0] < -0.75) & (
                indicator_value < selected_sharp_row['lower_level'].iloc[0]):
            vote1_instant += 1

    vote12_instant = 0

    indicator_t_list = [
        'change_1_high_volume', 'change_5_high_volume',
        'change_10_high_volume', 'change_20_high_volume',
        'change_1_low_volume', 'change_5_low_volume', 'change_10_low_volume',
        'change_20_low_volume'
    ]

    for i in range(len(indicator_t_list)):
        indicator_value = test_data[indicator_t_list[i]].iloc[0]
        selected_sharp_row = sharp_frame[sharp_frame['indicator'] ==
                                         indicator_t_list[i]]

        if (selected_sharp_row['sharp1_instant'].iloc[0] > 0.75) & (
                indicator_value > selected_sharp_row['higher_level'].iloc[0]):
            vote12_instant += 1
        elif (selected_sharp_row['sharp1_instant'].iloc[0] > 0.75) & (
                indicator_value < selected_sharp_row['lower_level'].iloc[0]):
            vote12_instant -= 1
        elif (selected_sharp_row['sharp1_instant'].iloc[0] < -0.75) & (
                indicator_value > selected_sharp_row['higher_level'].iloc[0]):
            vote12_instant -= 1
        elif (selected_sharp_row['sharp1_instant'].iloc[0] < -0.75) & (
                indicator_value < selected_sharp_row['lower_level'].iloc[0]):
            vote12_instant += 1

    vote13_instant = 0

    for i in range(len(indicator_t_list)):
        indicator_value = test_data[indicator_t_list[i]].iloc[0]
        selected_sharp_row = sharp_frame[sharp_frame['indicator'] ==
                                         indicator_t_list[i]]

        if (selected_sharp_row['sharp1_instant'].iloc[0] > 1) & (
                indicator_value > selected_sharp_row['higher_level'].iloc[0]):
            vote13_instant += 1
        elif (selected_sharp_row['sharp1_instant'].iloc[0] > 1) & (
                indicator_value < selected_sharp_row['lower_level'].iloc[0]):
            vote13_instant -= 1
        elif (selected_sharp_row['sharp1_instant'].iloc[0] < -1) & (
                indicator_value > selected_sharp_row['higher_level'].iloc[0]):
            vote13_instant -= 1
        elif (selected_sharp_row['sharp1_instant'].iloc[0] < -1) & (
                indicator_value < selected_sharp_row['lower_level'].iloc[0]):
            vote13_instant += 1

    vote5 = 0

    for i in range(len(indicator_list)):
        indicator_value = test_data[indicator_list[i]].iloc[0]
        selected_sharp_row = sharp_frame[sharp_frame['indicator'] ==
                                         indicator_list[i]]

        if (selected_sharp_row['sharp5'].iloc[0] > 0.75) & (
                indicator_value > selected_sharp_row['higher_level'].iloc[0]):
            vote5 += 1
        elif (selected_sharp_row['sharp5'].iloc[0] > 0.75) & (
                indicator_value < selected_sharp_row['lower_level'].iloc[0]):
            vote5 -= 1
        elif (selected_sharp_row['sharp5'].iloc[0] < -0.75) & (
                indicator_value > selected_sharp_row['higher_level'].iloc[0]):
            vote5 -= 1
        elif (selected_sharp_row['sharp5'].iloc[0] < -0.75) & (
                indicator_value < selected_sharp_row['lower_level'].iloc[0]):
            vote5 += 1

    vote10 = 0

    for i in range(len(indicator_list)):
        indicator_value = test_data[indicator_list[i]].iloc[0]
        selected_sharp_row = sharp_frame[sharp_frame['indicator'] ==
                                         indicator_list[i]]

        if (selected_sharp_row['sharp10'].iloc[0] > 0.75) & (
                indicator_value > selected_sharp_row['higher_level'].iloc[0]):
            vote10 += 1
        elif (selected_sharp_row['sharp10'].iloc[0] > 0.75) & (
                indicator_value < selected_sharp_row['lower_level'].iloc[0]):
            vote10 -= 1
        elif (selected_sharp_row['sharp10'].iloc[0] < -0.75) & (
                indicator_value > selected_sharp_row['higher_level'].iloc[0]):
            vote10 -= 1
        elif (selected_sharp_row['sharp10'].iloc[0] < -0.75) & (
                indicator_value < selected_sharp_row['lower_level'].iloc[0]):
            vote10 += 1

    vote20 = 0

    for i in range(len(indicator_list)):
        indicator_value = test_data[indicator_list[i]].iloc[0]
        selected_sharp_row = sharp_frame[sharp_frame['indicator'] ==
                                         indicator_list[i]]

        if (selected_sharp_row['sharp20'].iloc[0] > 0.75) & (
                indicator_value > selected_sharp_row['higher_level'].iloc[0]):
            vote20 += 1
        elif (selected_sharp_row['sharp20'].iloc[0] > 0.75) & (
                indicator_value < selected_sharp_row['lower_level'].iloc[0]):
            vote20 -= 1
        elif (selected_sharp_row['sharp20'].iloc[0] < -0.75) & (
                indicator_value > selected_sharp_row['higher_level'].iloc[0]):
            vote20 -= 1
        elif (selected_sharp_row['sharp20'].iloc[0] < -0.75) & (
                indicator_value < selected_sharp_row['lower_level'].iloc[0]):
            vote20 += 1

    #svr_rbf = SVR(kernel='rbf', C=1e3, gamma=0.1)
    #svr_forecast = svr_rbf.fit(x,y).predict(test_data[indicator_list].values)[0]
    #svc_rbf1 = SVC(kernel='rbf', C=1, gamma=0.1)
    #svc_forecast1 = svc_rbf1.fit(x,y).predict(test_data[indicator_list].values)[0]

    regress_forecast1 = np.nan
    regress_forecast2 = np.nan
    regress_forecast3 = np.nan
    svr_forecast1 = np.nan
    svr_forecast2 = np.nan

    try:
        regress_input = training_data[[
            'change_1Normalized', 'change_10Normalized',
            'change1_InstantNormalized'
        ]].dropna()
        y = regress_input['change1_InstantNormalized']
        X = regress_input[['change_1Normalized', 'change_10Normalized']]
        X = sm.add_constant(X)
        params1 = sm.OLS(y, X).fit().params
        regress_forecast1 = params1['const']+\
                        params1['change_1Normalized']*test_data['change_1Normalized'].iloc[0]+\
                        params1['change_10Normalized']*test_data['change_10Normalized'].iloc[0]
    except:
        pass

    try:
        regress_input = training_data[[
            'change_1Normalized', 'change_10Normalized',
            'change1_InstantNormalized', 'comm_net_change_1_normalized'
        ]].dropna()
        y = regress_input['change1_InstantNormalized']
        X = regress_input[[
            'change_1Normalized', 'change_10Normalized',
            'comm_net_change_1_normalized'
        ]]
        X = sm.add_constant(X)
        params2 = sm.OLS(y, X).fit().params
        regress_forecast2 = params2['const']+\
                        params2['change_1Normalized']*test_data['change_1Normalized'].iloc[0]+\
                        params2['change_10Normalized']*test_data['change_10Normalized'].iloc[0]+\
                        params2['comm_net_change_1_normalized']*test_data['comm_net_change_1_normalized'].iloc[0]
    except:
        pass

    try:
        regress_input = training_data[[
            'change_1Normalized', 'change_10Normalized',
            'change1_InstantNormalized', 'spec_net_change_1_normalized'
        ]].dropna()
        y = regress_input['change1_InstantNormalized']
        X = regress_input[[
            'change_1Normalized', 'change_10Normalized',
            'spec_net_change_1_normalized'
        ]]
        X = sm.add_constant(X)
        params3 = sm.OLS(y, X).fit().params
        regress_forecast3 = params3['const']+\
                        params3['change_1Normalized']*test_data['change_1Normalized'].iloc[0]+\
                        params3['change_10Normalized']*test_data['change_10Normalized'].iloc[0]+\
                        params3['spec_net_change_1_normalized']*test_data['spec_net_change_1_normalized'].iloc[0]
    except:
        pass

    regress_input = training_data[[
        'change_1Normalized', 'change_10Normalized',
        'change1_InstantNormalized', 'comm_net_change_1_normalized'
    ]].dropna()

    try:
        svr_rbf1 = SVR(kernel='rbf', C=1, gamma=0.04)
        y = regress_input['change1_InstantNormalized']
        X = regress_input[[
            'change_1Normalized', 'change_10Normalized',
            'comm_net_change_1_normalized'
        ]]
        svr_forecast1 = svr_rbf1.fit(X, y).predict(test_data[[
            'change_1Normalized', 'change_10Normalized',
            'comm_net_change_1_normalized'
        ]].values)[0]
    except:
        pass

    try:
        svr_rbf2 = SVR(kernel='rbf', C=50, gamma=0.04)
        y = regress_input['change1_InstantNormalized']
        X = regress_input[[
            'change_1Normalized', 'change_10Normalized',
            'comm_net_change_1_normalized'
        ]]
        svr_forecast2 = svr_rbf2.fit(X, y).predict(test_data[[
            'change_1Normalized', 'change_10Normalized',
            'comm_net_change_1_normalized'
        ]].values)[0]
    except:
        pass

    if test_data['low1_InstantNormalized'].iloc[0] < -0.25:
        long_tight_stop_pnl1Instant = -0.25
    else:
        long_tight_stop_pnl1Instant = test_data[
            'change1_InstantNormalized'].iloc[0]

    if test_data['low1_InstantNormalized'].iloc[0] < -0.5:
        long_loose_stop_pnl1Instant = -0.5
    else:
        long_loose_stop_pnl1Instant = test_data[
            'change1_InstantNormalized'].iloc[0]

    if test_data['high1_InstantNormalized'].iloc[0] > 0.25:
        short_tight_stop_pnl1Instant = -0.25
    else:
        short_tight_stop_pnl1Instant = -test_data[
            'change1_InstantNormalized'].iloc[0]

    if test_data['high1_InstantNormalized'].iloc[0] > 0.5:
        short_loose_stop_pnl1Instant = -0.5
    else:
        short_loose_stop_pnl1Instant = -test_data[
            'change1_InstantNormalized'].iloc[0]

    dictionary_out['vote1'] = vote1
    dictionary_out['vote1_instant'] = vote1_instant
    dictionary_out['vote12_instant'] = vote12_instant
    dictionary_out['vote13_instant'] = vote13_instant
    dictionary_out['vote5'] = vote5
    dictionary_out['vote10'] = vote10
    dictionary_out['vote20'] = vote20
    dictionary_out['regress_forecast1'] = regress_forecast1
    dictionary_out['regress_forecast2'] = regress_forecast2
    dictionary_out['regress_forecast3'] = regress_forecast3
    dictionary_out['svr_forecast1'] = svr_forecast1
    dictionary_out['svr_forecast2'] = svr_forecast2
    dictionary_out['norm_pnl1'] = test_data['change1Normalized'].iloc[0]
    dictionary_out['norm_pnl1Instant'] = test_data[
        'change1_InstantNormalized'].iloc[0]
    dictionary_out['long_tight_stop_pnl1Instant'] = long_tight_stop_pnl1Instant
    dictionary_out['long_loose_stop_pnl1Instant'] = long_loose_stop_pnl1Instant
    dictionary_out[
        'short_tight_stop_pnl1Instant'] = short_tight_stop_pnl1Instant
    dictionary_out[
        'short_loose_stop_pnl1Instant'] = short_loose_stop_pnl1Instant
    dictionary_out['norm_pnl5'] = test_data['change5Normalized'].iloc[0]
    dictionary_out['norm_pnl10'] = test_data['change10Normalized'].iloc[0]
    dictionary_out['norm_pnl20'] = test_data['change20Normalized'].iloc[0]
    dictionary_out['rolling_data'] = rolling_data

    for ind in indicator_list:
        dictionary_out[ind] = test_data[ind].iloc[0]

    return dictionary_out