Skip to content

Commit 3a4a113

Browse files
committed
Update cost calculation logic in Position class
- Changed the condition in _update_costs method to check for trade.position_effect being POSITION_EFFECT.OPEN instead of trade.side being SIDE.BUY, ensuring accurate cost updates for trade transactions. - This adjustment improves the handling of trade costs based on the position effect, enhancing the overall functionality of the Position class.
1 parent 1964bfd commit 3a4a113

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

rqalpha/portfolio/position.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ def before_trading(self, trading_date):
248248

249249
def _update_costs(self, trade: Trade):
250250
self._transaction_cost += trade.transaction_cost
251-
if trade.side == SIDE.BUY:
251+
if trade.position_effect == POSITION_EFFECT.OPEN:
252252
self._trade_cost += trade.last_price * trade.last_quantity
253253
else:
254254
self._trade_cost -= trade.last_price * trade.last_quantity

0 commit comments

Comments
 (0)