'Submits a stop limit order.
:param instrument: Instrument identifier.
:type instrument: string.
:param stopPrice: Stop price.
:type stopPrice: float.
:param limitPrice: Limit price.
:type limitPrice: float.
:param quantity: The amount of shares. Positive means buy, negative means sell.
:type quantity: int/float.
:param goodTillCanceled: True if the order is good till canceled. If False then the order gets automatically canceled when the session closes.
:type goodTillCanceled: boolean.
:param allOrNone: True if the order should be completely filled or not at all.
:type allOrNone: boolean.
:rtype: The :class:`pyalgotrade.broker.StopLimitOrder` submitted.'

def stopLimitOrder(self, instrument, stopPrice, limitPrice, quantity, goodTillCanceled=False, allOrNone=False):

    ret = None
    if (quantity > 0):
        ret = self.getBroker().createStopLimitOrder(pyalgotrade.broker.Order.Action.BUY, instrument, stopPrice, limitPrice, quantity)
    elif (quantity < 0):
        ret = self.getBroker().createStopLimitOrder(pyalgotrade.broker.Order.Action.SELL, instrument, stopPrice, limitPrice, (quantity * (-1)))
    if ret:
        ret.setGoodTillCanceled(goodTillCanceled)
        ret.setAllOrNone(allOrNone)
        self.getBroker().submitOrder(ret)
    return ret
