mlfinlab icon indicating copy to clipboard operation
mlfinlab copied to clipboard

Tripple-Barrier extension suggestion

Open Jackal08 opened this issue 4 years ago • 4 comments

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.

Jackal08 avatar Sep 01 '20 22:09 Jackal08

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 avatar Sep 03 '20 17:09 davilramos

@davilramos, well spotted.

@PanPip will you please do a fix for this in the morning? Then we can do a hotfix into master.

Jackal08 avatar Sep 03 '20 18:09 Jackal08

@davilramos Thank you for noticing!

This issue is now fixed.

PanPip avatar Sep 04 '20 08:09 PanPip

Any progress on the extension? Should be simple, like adding a bool to identify whether to use returns or actual differences.

mauritzvdworm avatar Feb 15 '21 09:02 mauritzvdworm