def calculate_unrealized_pnl(self, bid, ask):
        if self.is_position_opened:
            # Retrieve position from server
            pos = self.oanda.get_position(self.account_id,
                                          self.instrument)
            units = pos["units"]
            side = pos["side"]
            avg_price = float(pos["avgPrice"])

            self.unrealized_pnl = units * (
                (avg_price - bid)
                if (side == "buy")
                else (avg_price - ask))
        else:
            self.unrealized_pnl = 0
dataset/ETHPy150Open jamesmawm/Mastering-Python-for-Finance-source-codes/B03898_08_codes/ForexSystem.py/ForexSystem.calculate_unrealized_pnl/swapped operands of `-`