Advances in Financial Machine Learning, Snippet 3.7, page 51. Labeling for Side & Size with Meta Labels

get_bins(triple_barrier_events, price)

Arguments

triple_barrier_events

data.table or data.frame from get_events function

price

xts or data.table with index and price columns

Value

Events -events Datetime is event's start time -events ret is event's target -events trgt is event's target -events bin label; bin in (-1,1) or bin in (0,1)if metalabel

Examples

data("spy") close <- subset(spy, select = c("index", "close")) daily_vol <- daily_volatility(close) cusum_events <- cusum_filter(close, 0.001) vertical_barriers <- add_vertical_barrier(cusum_events, spy$index, num_days = 1) events <- get_events(price = close, t_events = cusum_events, pt_sl = c(1, 2), target = daily_vol, min_ret = 0.005, vertical_barrier_times=vertical_barriers, side_prediction=NA) labels <- get_bins(events, close)