code: def createStopOrder(self, quantity, parentId=0, stop=0., trail=None,
              transmit=True, group=None, stop_limit=False, rth=False, tif="DAY",
              account=None):
  
          
          if trail:
              if trail == "percent":
                  order = self.createOrder(quantity,
                              trailingPercent = stop,
                              transmit  = transmit,
                              orderType = dataTypes["ORDER_TYPE_TRAIL_STOP"],
                              ocaGroup  = group,
                              parentId  = parentId,
                              rth       = rth,
                              tif       = tif,
                              account   = account
                          )
              else:
                  order = self.createOrder(quantity,
                              trailStopPrice = stop,
                              stop      = stop,
                              transmit  = transmit,
                              orderType = dataTypes["ORDER_TYPE_TRAIL_STOP"],
                              ocaGroup  = group,
                              parentId  = parentId,
                              rth       = rth,
                              tif       = tif,
                              account   = account
                          )
  
          else:
              order = self.createOrder(quantity,
                          stop      = stop,
                          price     = stop if stop_limit else 0.,
                          transmit  = transmit,
                          orderType = dataTypes["ORDER_TYPE_STOP_LIMIT"] if stop_limit else dataTypes["ORDER_TYPE_STOP"],
                          ocaGroup  = group,
                          parentId  = parentId,
                          rth       = rth,
                          tif       = tif,
                          account   = account
                      )
          return order
docs: Creates STOP order