class_docstr: Subclasses the IBPy order to provide the minimum extra functionality
  needed to be compatible with the internally defined orders
  
  Once ``OrderBase`` has processed the parameters, the __init__ method takes
  over to use the parameter values and set the appropriate values in the
  ib.ext.Order.Order object
  
  Any extra parameters supplied with kwargs are applied directly to the
  ib.ext.Order.Order object, which could be used as follows::
  
    Example: if the 4 order execution types directly supported by
    ``backtrader`` are not enough, in the case of for example
    *Interactive Brokers* the following could be passed as *kwargs*::
  
      orderType='LIT', lmtPrice=10.0, auxPrice=9.8
  
    This would override the settings created by ``backtrader`` and
    generate a ``LIMIT IF TOUCHED`` order with a *touched* price of 9.8
    and a *limit* price of 10.0.
  
  This would be done almost always from the ``Buy`` and ``Sell`` methods of
  the ``Strategy`` subclass being used in ``Cerebro``
class_docstr_tok: ["Subclasses","the","IBPy","order","to","provide","the","minimum","extra","functionality","needed","to","be","compatible","with","the","internally","defined","orders","Once","``","OrderBase","``","has","processed","the","parameters",",","the","__init__","method","takes","over","to","use","the","parameter","values","and","set","the","appropriate","values","in","the","ib.ext.Order.Order","object","Any","extra","parameters","supplied","with","kwargs","are","applied","directly","to","the","ib.ext.Order.Order","object",",","which","could","be","used","as","follows",":",":","Example",":","if","the","4","order","execution","types","directly","supported","by","``","backtrader","``","are","not","enough",",","in","the","case","of","for","example","*","Interactive","Brokers","*","the","following","could","be","passed","as","*","kwargs","*",":",":","orderType='LIT","'",",","lmtPrice=10.0",",","auxPrice=9.8","This","would","override","the","settings","created","by","``","backtrader","``","and","generate","a","``","LIMIT","IF","TOUCHED","``","order","with","a","*","touched","*","price","of","9.8","and","a","*","limit","*","price","of","10.0",".","This","would","be","done","almost","always","from","the","``","Buy","``","and","``","Sell","``","methods","of","the","``","Strategy","``","subclass","being","used","in","``","Cerebro","``"]
code: def __init__(self, action, **kwargs):
      # Marker to indicate an openOrder has been seen with
      # PendinCancel/Cancelled which is indication of an upcoming
      # cancellation
      self._willexpire = False
  
      self.ordtype = self.Buy if action == "BUY" else self.Sell
  
      super(IBOrder, self).__init__()
      ib.ext.Order.Order.__init__(self)  # Invoke 2nd base class
  
      # Now fill in the specific IB parameters
      self.m_orderType = self._IBOrdTypes[self.exectype]
      self.m_permid = 0
  
      # 'B' or 'S' should be enough
      self.m_action = bytes(action)
  
      # Set the prices
      self.m_lmtPrice = 0.0
      self.m_auxPrice = 0.0
  
      if (
          self.exectype == self.Market
      ):  # is it really needed for Market?
          pass
      elif (
          self.exectype == self.Close
      ):  # is it ireally needed for Close?
          pass
      elif self.exectype == self.Limit:
          self.m_lmtPrice = self.price
      elif self.exectype == self.Stop:
          self.m_auxPrice = self.price  # stop price / exec is market
      elif self.exectype == self.StopLimit:
          self.m_lmtPrice = self.pricelimit  # req limit execution
          self.m_auxPrice = self.price  # trigger price
      elif self.exectype == self.StopTrail:
          if self.trailamount is not None:
              self.m_auxPrice = self.trailamount
          elif self.trailpercent is not None:
              # value expected in % format ... multiply 100.0
              self.m_trailingPercent = self.trailpercent * 100.0
      elif self.exectype == self.StopTrailLimit:
          self.m_trailStopPrice = self.m_lmtPrice = self.price
          # The limit offset is set relative to the price difference in TWS
          self.m_lmtPrice = self.pricelimit
          if self.trailamount is not None:
              self.m_auxPrice = self.trailamount
          elif self.trailpercent is not None:
              # value expected in % format ... multiply 100.0
              self.m_trailingPercent = self.trailpercent * 100.0
  
      self.m_totalQuantity = abs(self.size)  # ib takes only positives
  
      self.m_transmit = self.transmit
      if self.parent is not None:
          self.m_parentId = self.parent.m_orderId
  
      # Time In Force: DAY, GTC, IOC, GTD
      if self.valid is None:
          tif = "GTC"  # Good til cancelled
      elif isinstance(self.valid, (datetime, date)):
          tif = "GTD"  # Good til date
          self.m_goodTillDate = bytes(
              self.valid.strftime("%Y%m%d %H:%M:%S")
          )
      elif isinstance(self.valid, (timedelta,)):
          if self.valid == self.DAY:
              tif = "DAY"
          else:
              tif = "GTD"  # Good til date
              valid = (
                  datetime.now() + self.valid
              )  # .now, using localtime
              self.m_goodTillDate = bytes(
                  valid.strftime("%Y%m%d %H:%M:%S")
              )
  
      elif self.valid == 0:
          tif = "DAY"
      else:
          tif = "GTD"  # Good til date
          valid = num2date(self.valid)
          self.m_goodTillDate = bytes(valid.strftime("%Y%m%d %H:%M:%S"))
  
      self.m_tif = bytes(tif)
  
      # OCA
      self.m_ocaType = 1  # Cancel all remaining orders with block
  
      # pass any custom arguments to the order
      for k in kwargs:
          setattr(self, (not hasattr(self, k)) * "m_" + k, kwargs[k])
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import collections
  from copy import copy
  from datetime import date, datetime, timedelta
  import threading
  import uuid
  import ib.ext.Order
  import ib.opt
  from backtrader.feed import DataBase
  from backtrader import TimeFrame, num2date, date2num, BrokerBase, Order, OrderBase, OrderData
  from backtrader.utils.py3 import bytes, bstr, with_metaclass, queue, MAXFLOAT
  from backtrader.metabase import MetaParams
  from backtrader.comminfo import CommInfoBase
  from backtrader.position import Position
  from backtrader.stores import ibstore
  from backtrader.utils import AutoDict, AutoOrderedDict
  from backtrader.comminfo import CommInfoBase
label_desc: Use image node_id 2 to create a new IBOrder object from inherited base classes: OrderBase, ib.ext.Order with example: obj = IBOrder(action)