oos_months = 3
    segments = 3

    # get segmented dates
    isOosDates = timeUtil.is_oos_data_split(issue, pivotDate, is_oos_ratio,
                                            oos_months, segments)
    dataLoadStartDate = isOosDates[0]
    is_start_date = isOosDates[1]
    oos_start_date = isOosDates[2]
    is_months = isOosDates[3]
    is_end_date = isOosDates[4]
    oos_end_date = isOosDates[5]

    #load data
    dataSet = dSet.read_issue_data(issue)
    dataSet = dSet.set_date_range(dataSet, dataLoadStartDate, pivotDate)

    #set beLong level
    beLongThreshold = 0.0
    dataSet = ct.setTarget(dataSet, "Long", beLongThreshold)

    #    def stationarity_tests(s_df, signal, issue):
    #        print("=============================================================")
    #        adf_test(s_df, signal, issue)
    #        hurst_setup(s_df[signal][:], issue)
    #        print("========================================")

    for i in range(segments):
        modelData = dSet.set_date_range(dataSet, is_start_date, is_end_date)
        print("\n\n\nIN SAMPLE")
        # Stationarity tests
示例#2
0
    else:
        print('no date')
        tradeDate += BDay(1)
        print('tradeDate: ', tradeDate)
        
    # set trade date
    tradeDate = tradeDate.strftime('%Y-%m-%d')
    print(tradeDate)

    # get first/last row
    df_start_date = temp_raw_df.Date[0]
    lastRow = temp_raw_df.shape[0]
    df_end_date = temp_raw_df.Date[lastRow-1]
    
    feat_df = dSet.set_date_range(temp_raw_df, df_start_date, df_end_date)
    # Resolve any NA's for now
    feat_df.fillna(method='ffill', inplace=True)
    
    #set beLong level
    beLongThreshold = 0.000
    feat_df = ct.setTarget(temp_raw_df, "Long", beLongThreshold)

    # Adding features with new day
    input_dict = sysUtil.get_dict(system_directory, 'input_dict')
    feat_df = featureGen.generate_features(feat_df, input_dict)
    feat_df = transf.normalizer(feat_df, 'Volume', 50)
    
    col_vals = [k for k,v in feature_dict.items() if v == 'Drop']
    to_drop = ['Open','High','Low', 'gainAhead', 'Close', 'Volume', 'AdjClose', 'beLong']
    for x in to_drop:
示例#3
0
    timeUtil = TimeUtility()
    modelUtil = ModelUtility()
    #timeSeriesImp = TimeSeriesSplitImproved()

    dataLoadStartDate = "2014-09-26"
    dataLoadEndDate = "2018-04-05"
    issue = "TLT"
    # Set IS-OOS parameters
    pivotDate = datetime.date(2018, 4, 2)
    is_oos_ratio = 2
    oos_months = 4
    segments = 4

    dataSet = dSet.read_issue_data(issue)

    dataSet = dSet.set_date_range(dataSet, dataLoadStartDate, pivotDate)
    #set beLong level
    beLongThreshold = 0.000
    dataSet = ct.setTarget(dataSet, "Long", beLongThreshold)

    input_dict = {}  # initialize
    input_dict = {
        'f1': {
            'fname': 'ATR',
            'params': [5],
            'transform': ['Zscore', 10]
        },
        'f2': {
            'fname': 'RSI',
            'params': [2],
            'transform': ['Scaler', 'robust']
    plotIt = PlotUtility()
    taLibMomSt = TALibMomentumStudies()
    dSet = DataRetrieve()

    issue = "TLT"
    df = dSet.read_issue_data(issue)

    lastRow = df.shape[0]
    dataLoadEndDate = df.Date[lastRow - 100]
    pprint(dataLoadEndDate)

    dataLoadStartDate = df.Date[lastRow - 3000]
    pprint(dataLoadStartDate)

    dataSet = dSet.set_date_range(df, dataLoadStartDate, dataLoadEndDate)
    pprint(dataSet.tail(10))

    # Resolve any NA's for now
    dataSet.fillna(method='ffill', inplace=True)

    dataSet = taLibMomSt.RSI(dataSet, 10)
    #dataSet = taLibMomSt.RSI2(dataSet, 2)
    pprint(dataSet.head(5))
    pprint(dataSet.tail(5))
    dataSet = taLibMomSt.PPO(dataSet, 12, 26)
    #    dataSet = taLibMomSt.CMO(dataSet, 20)
    #    dataSet = taLibMomSt.CCI(dataSet, 20)
    #    dataSet = taLibMomSt.UltOsc(dataSet, 7, 24, 28)
    #    dataSet = taLibMomSt.rate_OfChg(dataSet, 10)
            'Low': raw_df.Low[index],
            'Close': raw_df.Close[index],
            'AdjClose': raw_df.AdjClose[index],
            'Volume': raw_df.Volume[index]
        },
        ignore_index=True)
    print(new_data_df.tail(2))

    # get first row
    df_start_date = new_data_df.Date[0]

    # get last row
    lastRow = new_data_df.shape[0]
    df_end_date = new_data_df.Date[lastRow - 1]

    feat_df = dSet.set_date_range(new_data_df, df_start_date, df_end_date)
    # Resolve any NA's for now
    feat_df.fillna(method='ffill', inplace=True)

    #set beLong level
    beLongThreshold = 0.000
    feat_df = ct.setTarget(new_data_df, "Long", beLongThreshold)

    print(feat_df.tail(2))

    # Adding features with new day
    input_dict = sysUtil.get_dict(system_directory, 'input_dict')

    feat_df = featureGen.generate_features(feat_df, input_dict)
    feat_df = transf.normalizer(feat_df, 'Volume', 50)