Return average of bid and ask, or NaN if no valid bid and ask
        are available.

def midpoint(self) -> float:
        """
        Return average of bid and ask, or NaN if no valid bid and ask
        are available.
        """
        return (self.bid + self.ask) / 2 if self.hasBidAsk() else nan