scrtlabs / catalyst

An Algorithmic Trading Library for Crypto-Assets in Python
http://enigma.co
Apache License 2.0
2.49k stars 726 forks source link

Support for stop orders. #139

Open sekamaneka opened 6 years ago

sekamaneka commented 6 years ago

Dear Catalyst Maintainers,

I hope this is the right forum for this. Are there any plans on supporting stop orders soon? I could make a workaround but it would not be an elegant solution..

fredfortier commented 6 years ago

Yes, but not all exchanges have a stop order feature. So we decided to stick with the types of order supported by most exchanges for now.

In future releases, we’re planning implement a soft stop-limit order by keeping the stop price target in Catalyst, sending a limit order to the exchange only when reached. As long as we manage it this way, it will work on all exchanges. We’ll update this issue as soon as we have an ETA but it should be relatively soon.

In the meanwhile, you can implement similar logic in your algorithm by using the context variable to keep your stop triggers, evaluating then during each frame, and calling your limit orders when reached.

This approach also has the benefit of keeping your stop targets private, making sure that nobody is hunting your stops. On Sat, Jan 6, 2018 at 12:23 AM swilso793 notifications@github.com wrote:

Dear Catalyst Maintainers,

I hope this is the right forum for this. Are there any plans on supporting stop orders soon?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/enigmampc/catalyst/issues/139, or mute the thread https://github.com/notifications/unsubscribe-auth/ABZ-QpSrzIePwnXwwh3rl_8mFP79wMDYks5tHy1lgaJpZM4RVPXZ .

lacabra commented 6 years ago

@fredfortier I have the issue that when I do as you say you can implement similar logic in your algorithm by using the context variable to keep your stop triggers, evaluating then during each frame, and calling your limit orders when reached whenever I my algorithm stops and I restart it, those context variables are lost. The algo remembers my positions and transactions, but not the context variables. Is this the expected behavior? Or else where can I store my stop triggers so that they persist across runs?

fredfortier commented 6 years ago

That's a good point. I don't think that we can easily persist the entire context which is an instance of the Algorithm class. But we can come up with some mechanism to persist an arbitrary state.

moremorecoin commented 6 years ago

I think it's great to support all markets at the same time, however, if that is too much of work, why not just support those markets that has stop order inbuilt right now? I feel most of us care only those big markets and most of them support stop order. The stop order has been illustrated in the documents( https://enigma.co/catalyst/appendix.html#catalyst.api.order), it's really annoying that you find it unusable after finish coding your strategy.

lenak25 commented 6 years ago

@moremorecoin thanks for reporting this, we have fixed the misleading docs.

markudevelop commented 6 years ago

I think it will be beneficial to have a work around or at least support the exchanges that have it does anyone have proof of concept code using the @fredfortier mention by sending a limit orders? @lacabra

scoriiu commented 5 years ago

@fredfortier We’ll update this issue as soon as we have an ETA but it should be relatively soon. No ETA so far, so what relatively soon does mean? IMO stop and trailing stops are basic components of the risk management strategies, so I'm looking forward to see it happen.