class_docstr: A size of a financial instrument for use in trading.
  
  Parameters
  ----------
  instrument : `Instrument`
      The unit of the quantity.
  size : `Decimal`
      The number of units of the instrument.
  path_id : str, optional
      The path order_id that this quantity is allocated for and associated
      with.
  
  Raises
  ------
  InvalidNegativeQuantity
      Raised if the `size` of the quantity being created is negative.
docstr: Contains the size of the quantity to be compatible with the settings
  of a given exchange.
  
  Parameters
  ----------
  exchange_pair : `ExchangePair`
      The exchange pair containing the exchange the quantity must be
      compatible with.
  
  Returns
  -------
  `Quantity`
      A quantity compatible with the given exchange.
docstr_tok: ["Contains","the","size","of","the","quantity","to","be","compatible","with","the","settings","of","a","given","exchange",".","Parameters","--","--","--","--","--","exchange_pair",":","`","ExchangePair","`","The","exchange","pair","containing","the","exchange","the","quantity","must","be","compatible","with",".","Returns","--","--","--","-","`","Quantity","`","A","quantity","compatible","with","the","given","exchange","."]
code: def contain(self, exchange_pair: "ExchangePair"):
      """Contains the size of the quantity to be compatible with the settings
      of a given exchange.
  
      Parameters
      ----------
      exchange_pair : `ExchangePair`
          The exchange pair containing the exchange the quantity must be
          compatible with.
  
      Returns
      -------
      `Quantity`
          A quantity compatible with the given exchange.
      """
      options = exchange_pair.exchange.options
      price = exchange_pair.price
  
      if exchange_pair.pair.base == self.instrument:
          size = self.size
          return Quantity(
              self.instrument,
              min(size, options.max_trade_size),
              self.path_id,
          )
  
      size = self.size * price
      if size < options.max_trade_size:
          return Quantity(self.instrument, self.size, self.path_id)
  
      max_trade_size = Decimal(options.max_trade_size)
      contained_size = max_trade_size / price
      contained_size = contained_size.quantize(
          Decimal(10) ** -self.instrument.precision, rounding=ROUND_DOWN
      )
      return Quantity(self.instrument, contained_size, self.path_id)
  
imports: import operator
  from typing import Union, Tuple, Callable, TypeVar
  from numbers import Number
  from decimal import Decimal, ROUND_DOWN
  from functools import total_ordering
  from tensortrade.core.exceptions import InvalidNegativeQuantity, IncompatibleInstrumentOperation, InvalidNonNumericQuantity, QuantityOpPathMismatch
label_desc: Use image node_id 8 for calling the Quantity obj's underlying member method code with example usage: obj.contain(exchange_pair) and returns: Quantity, Quantity, Quantity