-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
-
My current temporary solution is to compare the size
and price
of the order with one in trades and closed_trades. A sample code is:
class MyStrategy(Strategy):
position = 0
tp_order = None
tp_price = 0.0
def next(self):
if self.position > 0:
if tp_order is not None:
# check if tp order if filled?
if (self.trades[-1].size = -self.position and self.trades[-1].entry_price == tp_price) or (self.closed_trades[-1].size = -self.position and self.closed_trades[-1].entry_price == tp_price):
position = 0
tp_order = None
else:
# place tp_order
tp_order = self.sell(size = self.position, limit=self.tp_price)
else:
# calculate the entry price
entry_price = ....
qty=..
buy_order = self.buy(qty, limit=entry_price)
...
Is there any better way to check if the limit order (i.e., tp_order
in my example) is filled?
I suggest to have __eq__
function in Order class..
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment