Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Triple Barrier Method from "Advances in Financial Machine Learning" - De Prado 2018 #105

Open
jaymon0703 opened this issue Jul 31, 2019 · 5 comments
Assignees

Comments

@jaymon0703
Copy link
Collaborator

De Prado (https://www.amazon.com/Advances-Financial-Machine-Learning-Marcos/dp/1119482089) introduces the Triple Barrier Method concept for labeling observations in a potential ML model for time series. The 3 barriers are 2 horizontal bars (representing profit-taking and stop-loss prices) and one vertical bar (representing an expiration timespan, ie. x number of bars). Where the top horizontal bar is touched first, the observation gets a label of +1. If the lower horizontal bar is touched first, the observation gets a label of -1. If the vertical bar is touched first, De Prado suggests 2 options...either give the observation the sign of the return or a zero. Your choice should depend on the problem you are trying to solve.

De Prado says the output from the function should be a dataframe containing the timestamps at which any barrier was touched. De Prado also mentions 8 possible configurations of the "barrier triplet" in which the barriers are enabled or disabled reflecting different objectives and constraints. For our replication of the method, we should consider all configurations, some of which share some overlap with the trading strategy posed by Olsen et al in https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2951348.

There could be a few applications of this method in quantstrat but our initial focus will be for extending it to signal analysis for any periodicity.

TODO: Add more info?

@braverock
Copy link
Owner

There is R code for the triple barrier method in

http://www.mlfactor.com/Data.html#the-triple-barrier-method

it is all tidy, and focused on labeling for supervised learning. It should be a good start.

@cl7805
Copy link

cl7805 commented May 27, 2021

Hi, marvellous explanation above. The example given in the book is intraday. I'm doing swing trading amd I'm stuck on the distinction between Timedelta and span. What does span=100 mean?
2nd, I have a KeyError on Timestamp using yahoo finance, does it mean I should discard it as I assume it means it is missing data?

@jaymon0703
Copy link
Collaborator Author

Please share link to R code? I cannot see it anywhere, nor the terms you mention...assuming you are referring to http://www.mlfactor.com/Data.html#the-triple-barrier-method

@cl7805
Copy link

cl7805 commented May 29, 2021

No, it's python

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants