Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How to check if a limit order is filled? #1202

Unanswered
vuanhduy asked this question in Q&A
Discussion options

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..

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /