예제 #1
0
    print pd.DataFrame({'values': [(len(y)/K)*(K-1)]}, index=['Training Size / Fold'])
    print cv_results
    print "=============================================================================="

# time period cutoffs in minutes from start
time_period_cutoffs = (30, 180, 420, 450)

#quotes, trades = get_data('XLE', 2012, 1, 5, bar_width='second')
data = get_more_data('XLE', 2012, 2, 1, days=1, bar_width='second')

hls = [10, 40, 100]

for quotes, trades in data:
    features.label_data(quotes, label_hls=hls)
    features.add_ema(quotes, halflives=hls)
    features.add_dema(quotes, halflives=hls)
    features.add_momentum(quotes, halflives=hls)
    features.add_log_return_ema(quotes, halflives=hls)
    #features.add_trade_momentum(quotes, trades, bar_width='second')
    features.add_price_diff(quotes)
    features.add_size_diff(quotes)
    #features.add_trade_momentum_dema(quotes, trades, halflife=40)

quotes_list, trades_list = zip(*data)

quotes = pd.concat(quotes_list)
trades = pd.concat(trades_list)

feature_names = ['momentum', 'dEMA_10', 'dEMA_40', 'dEMA_100',
                 'log_returns_10-', 'log_returns_40-', 'log_returns_100-',
                 'log_returns_std_10-', 'log_returns_std_40-', 'size_diff',
예제 #2
0
crossover_hls = (10, 40)

filter_feature_names = []
#filter_feature_names = ['crossover?', 'high_momentum?', 'dEMA_10_sign_change?', 'dEMA_40_sign_change?']
feature_names = []

for data, trades in datas:
    features.add_future_log_returns(data, label_hls=hls)
    features.add_future_log_returns_rolling(data, windows=(10, 30, 60))
    feature_names += features.add_price_dema(data, halflives=hls)
    feature_names += features.add_momentum(data, halflives=hls)
    feature_names += features.add_log_return_ema(data, halflives=hls)
    feature_names += features.add_price_diff(data)
    feature_names += features.add_size_diff(data)
    #feature_names += features.add_vpin_time(data, window=dt.timedelta(seconds=20))
    feature_names += features.add_dema(data, features=['momentum', 'dEMA_10', 'dEMA_40', 'dEMA_100'])
    #filter_feature_names += features.add_crossover_filter(data, halflives=crossover_hls)
    #filter_feature_names += features.add_high_momentum_filter(data, cutoff=0.1, halflives=(10, 40, 100))
    #filter_feature_names += features.add_dema_sign_change_filter(data, halflife=10)
    #filter_feature_names += features.add_dema_sign_change_filter(data, halflife=40)
    features.add_crossover_filter(data, halflives=crossover_hls)
    features.add_high_momentum_filter(data, cutoff=0.1, halflives=(10, 40, 100))
    add_dema_sign_change_filter(data, halflife=10)
    add_dema_sign_change_filter(data, halflife=40)


feature_names = list(set(feature_names))

data = pd.concat(zip(*datas)[0])

#quotes_list, trades_list = zip(*data)