class_docstr: Calculates a commission for a transaction based on a per contract cost with
  an optional minimum cost per trade.
  
  Parameters
  ----------
  cost : float or dict
      The amount of commissions paid per contract traded. If given a float,
      the commission for all futures contracts is the same. If given a
      dictionary, it must map root symbols to the commission cost for
      contracts of that symbol.
  exchange_fee : float or dict
      A flat-rate fee charged by the exchange per trade. This value is a
      constant, one-time charge no matter how many contracts are being
      traded. If given a float, the fee for all contracts is the same. If
      given a dictionary, it must map root symbols to the fee for contracts
      of that symbol.
  min_trade_cost : float, optional
      The minimum amount of commissions paid per trade.
class_docstr_tok: ["Calculates","a","commission","for","a","transaction","based","on","a","per","contract","cost","with","an","optional","minimum","cost","per","trade",".","Parameters","--","--","--","--","--","cost",":","float","or","dict","The","amount","of","commissions","paid","per","contract","traded",".","If","given","a","float",",","the","commission","for","all","futures","contracts","is","the","same",".","If","given","a","dictionary",",","it","must","map","root","symbols","to","the","commission","cost","for","contracts","of","that","symbol",".","exchange_fee",":","float","or","dict","A","flat-rate","fee","charged","by","the","exchange","per","trade",".","This","value","is","a","constant",",","one-time","charge","no","matter","how","many","contracts","are","being","traded",".","If","given","a","float",",","the","fee","for","all","contracts","is","the","same",".","If","given","a","dictionary",",","it","must","map","root","symbols","to","the","fee","for","contracts","of","that","symbol",".","min_trade_cost",":","float",",","optional","The","minimum","amount","of","commissions","paid","per","trade","."]
code: def __init__(
      self,
      cost,
      exchange_fee,
      min_trade_cost=DEFAULT_MINIMUM_COST_PER_FUTURE_TRADE,
  ):
      # If 'cost' or 'exchange fee' are constants, use a dummy mapping to
      # treat them as a dictionary that always returns the same value.
      # NOTE: These dictionary does not handle unknown root symbols, so it
      # may be worth revisiting this behavior.
      if isinstance(cost, (int, float)):
          self._cost_per_contract = DummyMapping(float(cost))
      else:
          # Cost per contract is a dictionary. If the user's dictionary does
          # not provide a commission cost for a certain contract, fall back
          # on the pre-defined cost values per root symbol.
          self._cost_per_contract = defaultdict(
              lambda: DEFAULT_PER_CONTRACT_COST, **cost
          )
  
      if isinstance(exchange_fee, (int, float)):
          self._exchange_fee = DummyMapping(float(exchange_fee))
      else:
          # Exchange fee is a dictionary. If the user's dictionary does not
          # provide an exchange fee for a certain contract, fall back on the
          # pre-defined exchange fees per root symbol.
          self._exchange_fee = merge(
              FUTURE_EXCHANGE_FEES_BY_SYMBOL,
              exchange_fee,
          )
  
      self.min_trade_cost = min_trade_cost or 0
  
imports: from abc import abstractmethod
  from collections import defaultdict
  from six import with_metaclass
  from toolz import merge
  from catalyst.assets import Equity, Future
  from catalyst.finance.constants import FUTURE_EXCHANGE_FEES_BY_SYMBOL
  from catalyst.finance.shared import AllowedAssetMarker, FinancialModelMeta
  from catalyst.utils.dummy import DummyMapping
label_desc: Use image node_id 1 to create a new PerContract object from inherited base classes: FutureCommissionModel with example: obj = PerContract(cost, exchange_fee, min_trade_cost)