Skip to content

Commit

Permalink
Merge pull request #599 from mar-heaven/develop
Browse files Browse the repository at this point in the history
🐛Fix calculation avg_price error
  • Loading branch information
Cuizi7 committed Jan 22, 2021
2 parents 4728eb5 + 2ee07a5 commit c49385d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion rqalpha/model/order.py
Expand Up @@ -289,11 +289,11 @@ def fill(self, trade):
assert self.filled_quantity + quantity <= self.quantity
new_quantity = self._filled_quantity + quantity
self._transaction_cost += trade.commission + trade.tax
self._filled_quantity = new_quantity
if self.unfilled_quantity == 0:
self._status = ORDER_STATUS.FILLED
if trade.position_effect != POSITION_EFFECT.MATCH:
self._avg_price = (self._avg_price * self._filled_quantity + trade.last_price * quantity) / new_quantity
self._filled_quantity = new_quantity

def mark_rejected(self, reject_reason):
if not self.is_final():
Expand Down

0 comments on commit c49385d

Please sign in to comment.