mlfinlab
mlfinlab copied to clipboard
Tripple-Barrier extension suggestion
Tripple-Barrier extension suggestion:
Add magnitude move barriers not determined by percentage moves, for example, a 10 cent move.
Say you are interested in some spread between two or more instruments. This spread can be positive, negative or even zero. The percentage moves don't make sense here.
A quick fix would be to convert your spread to the dollar value invested since inception, a la etf trick. However, sometimes the absolute magnitude of the move is of interest.
Another practical example in the futures space would be something like a limits up/down filter for events.
There is a minor error on the labeling function get_events() of the triple barrier:
Line 148:
# 3) Form events object, apply stop loss on vertical barrier
if side_prediction is None:
side_ = pd.Series(1.0, index=target.index)
pt_sl_ = [pt_sl[0], pt_sl[0]]
else:
side_ = side_prediction.reindex(target.index) # Subset side_prediction on target index.
pt_sl_ = pt_sl[:2]
it should be 1 instead of 0:
# 3) Form events object, apply stop loss on vertical barrier
if side_prediction is None:
side_ = pd.Series(1.0, index=target.index)
pt_sl_ = [pt_sl[0], pt_sl[1]] <<<<<<<<<<<<<<<-----------------------------
else:
side_ = side_prediction.reindex(target.index) # Subset side_prediction on target index.
pt_sl_ = pt_sl[:2]
@davilramos, well spotted.
@PanPip will you please do a fix for this in the morning? Then we can do a hotfix into master.
@davilramos Thank you for noticing!
This issue is now fixed.
Any progress on the extension? Should be simple, like adding a bool to identify whether to use returns or actual differences.