Event Helpers: fg_signal_to_events
Value
data.table suitable for passing into fgts_dygraph() via the event_ds parameter
Details
This helper applies run-length encoding to match the signal in signal_df to the color in colormap
Examples
# A simple moving average strategy with threshold
require(data.table)
ma_signal<-eqtypx[,.(date,sig=cut(frollmean(EEM,5)-frollmean(EEM,20),
c(-10,-0.5,0.5,10),labels=c("long","flat","short")),EEM)]
colormap<-data.frame(sig=c("long","flat","short"),color=c("#f56462","white","#6161ff"))
fgts_dygraph(eqtypx[,.(date,EEM)],event_ds=fg_signal_to_events(ma_signal,colormap),
dtstartfrac=0.8,roller=1,title="5/20 MA positions")