You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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..
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
My current temporary solution is to compare the
size
andprice
of the order with one in trades and closed_trades. A sample code is: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