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

Pyramid Trading - Scaling into a position - DCA Trading possible ? #1106

Open
wesssup opened this issue Sep 1, 2023 · 10 comments
Open

Pyramid Trading - Scaling into a position - DCA Trading possible ? #1106

wesssup opened this issue Sep 1, 2023 · 10 comments
Labels

Comments

@wesssup
Copy link

wesssup commented Sep 1, 2023

I have a question , is it possible to implement Pyramid Trading (https://www.investopedia.com/articles/trading/09/pyramid-trading.asp) also called scaling into a position or DCA .... ... is there a way to do it ?

I Guess in BaseTradingRecord line 204 ,

boolean newTradeWillBeAnEntry = currentPosition.isNew();
maybe should be adapted, as there could be many openings for one position... only one close.

Seen to the rest of the code there also maybe impact on costmodels..

@wesssup wesssup changed the title Backtesting & Pyramid Trading - Scaling into a postion Pyramid Trading - Scaling into a postion - DCA Trading possible ? Sep 2, 2023
@wesssup wesssup changed the title Pyramid Trading - Scaling into a postion - DCA Trading possible ? Pyramid Trading - Scaling into a position - DCA Trading possible ? Sep 2, 2023
@TheCookieLab
Copy link
Member

TheCookieLab commented Sep 2, 2023 via email

@nimo23
Copy link
Contributor

nimo23 commented Sep 2, 2023

For both, it would be good to just check for existing issues beforehand, rather than opening a new one and posting your comments, suggestions, or future plans here:

#755

@wesssup
Copy link
Author

wesssup commented Sep 2, 2023 via email

@nimo23
Copy link
Contributor

nimo23 commented Sep 2, 2023

But it’s not the same, "multiple trades" or "scaling into a trade", or is due to the limited information not clear what you exact try to do…

I read again this issue. Yes, this issue has nothing to do with supporting "multiple trades".. well, then I don't understand why you liked the also wrong comment from #1106 (comment) which also has nothing to do with it..

Scaling into the position requires making decisions based on criteria. This is currently not possible. See here: #1054. Btw, scaling positions actually works with the existing trading record, but in blind mode as long as #1054 is not supported.

You see, searching for existing issues helps! Feel free to help.

@wesssup
Copy link
Author

wesssup commented Sep 8, 2023

@TheCookieLab -->https://github.com/wesssup/ta4j It's not perfect, but it serves the purpose I needed for our app and strategies... (And, yes, it's on the head, due to the requirement in our DEVOPS) I ran the tests, and nothing appears to be broken. Pyramid trading is not unit-tested in this head/git... we apparently wrote the test on our own software stack....
Anyway, we ran a few scenarios with pyramid trading, and it appears to work as I intended.
Perhaps instead of vars, have two Strategy Property parameters, 'isPyramid' and 'depth'...

@TheCookieLab
Copy link
Member

TheCookieLab commented Sep 9, 2023 via email

@nimo23
Copy link
Contributor

nimo23 commented Sep 9, 2023

would you be willing to create a draft PR to facilitate collaboration for this?

I would not agree with this PR. Looking into wesssup@846229d, it is nothing else than a workaround which pollutes a lot of our base classes only because of one concept. It is by far not a clear solution and would worsen the condition of the lib, since one concept was sloppily crammed into other concepts. @wesssup If it works for you, then leave it in your branch. I will not agree to put this into this lib. It would be far better to provide a clean solution to this problem as suggested here: #1054 (comment). I'm planning on doing a PR to solve #1054 (after pending PR's are merged) to make things like this possible. If #1054 was done, then this "pyramid trading" would end up being nothing more than a criterion type indicator (called PyramidCriterion). That would be the only clean solution.

@wesssup
Copy link
Author

wesssup commented Sep 10, 2023

Hi @nimo23 , I never requested that you accept the changes.. I even suggested improvements. However you want to call it: a property, a criterion,…. its fine by me 😊 adaption is needed. Even so, I'm not requesting a merge with the TA4J repository. Even I wouldn't recommend it.

However, I can assure you that there is a workable implementation strategy with minimal issues with backwards compatibility. Since the entire ta4J model is based on opening only one position at a time, there are undoubtedly many base classes that are affected. It can be found in the basic operating and calculation functions, for example. Thus, you can picture.
Anyway, I can only draw the conclusion that I'm here in a very constructive way to offer a potential way to do it , WITH workable code, and you….
Anyway I can't wait to see how your PR works 😊. There is now a piece of code that can be used until that time, if someone wants to investigate it more deeply (like @TheCookieLab ) or test it in a new ‘java’ algorithmic trading strategy. (what exactly our goal is)

@wesssup
Copy link
Author

wesssup commented Sep 10, 2023

@wesw very promising - would you be willing to create a draft PR to facilitate collaboration for this?

@TheCookieLab I'm sorry, but I currently have too much on my plate. Do whatever you want to do with it 😊 . Although there is still a lot of work to be done....., for us, things are going as planned, and we get the same data from our strategy as from the TradingView Pine Strategy Tester....happy camper here 😊

==> Draft #1113

@nimo23
Copy link
Contributor

nimo23 commented Sep 10, 2023

There is now a piece of code that can be used until that time, if someone wants to investigate it more deeply (like @TheCookieLab ) or test it in a new ‘java’ algorithmic trading strategy. (what exactly our goal is)

No, problem! @TheCookieLab has its own branch. If he wants to merge it in his own branch, he can do it whatsoever. But your PR is nothing more than a workaround and is far from a clean and future-proof solution - it's a typical dirty hack :)

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

No branches or pull requests

3 participants