-
I'm struggling with what might be an obvious thing to many. If I have multiple trades (long only) and now I want to enter a sell limit for all of them to close them out at a specified price. (Basically I'm looking to set a Is there a simple way to do this or do I need to loop through all the open trades and set the |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
As long as |
Beta Was this translation helpful? Give feedback.
-
Okay then I think it has something to do with my logic because it is popping an AssertionError. Perhaps I'm placing an order in the same bar that I'm calculating the position size (which doesn't account for that order), and it is putting me into a short position. I'll debug and come back with answers or questions. :) Thanks for the quick response. |
Beta Was this translation helpful? Give feedback.
-
looping back on this. I had some take profits and stop losses in my opening trades, this was causing the problem because that created multiple sell orders sitting waiting in the order book. The sell(limit) wasn't contingent on anything so it wouldn't get canceled if a tp was hit. then I would have a short order sitting in the order book. |
Beta Was this translation helpful? Give feedback.
-
So how did you end up solving this? I have a similar use case where I have both a tp and sl that are dynamic and are of different size, so I cant use the build in tp and sl arguments. Anyway to force the sell orders to be contingent? |
Beta Was this translation helpful? Give feedback.
As long as
assert self.position.size > 0
,self.sell()
like this looks reasonable. What result do you get?