class_docstr: Default fill strategy.
  
  :param volumeLimit: The proportion of the volume that orders can take up in a bar. Must be > 0 and <= 1.
      If None, then volume limit is not checked.
  :type volumeLimit: float
  
  This strategy works as follows:
  
  * A :class:`pyalgotrade.broker.MarketOrder` is always filled using the open/close price.
  * A :class:`pyalgotrade.broker.LimitOrder` will be filled like this:
      * If the limit price was penetrated with the open price, then the open price is used.
      * If the bar includes the limit price, then the limit price is used.
      * Note that when buying the price is penetrated if it gets <= the limit price, and when selling the price
        is penetrated if it gets >= the limit price
  * A :class:`pyalgotrade.broker.StopOrder` will be filled like this:
      * If the stop price was penetrated with the open price, then the open price is used.
      * If the bar includes the stop price, then the stop price is used.
      * Note that when buying the price is penetrated if it gets >= the stop price, and when selling the price
        is penetrated if it gets <= the stop price
  * A :class:`pyalgotrade.broker.StopLimitOrder` will be filled like this:
      * If the stop price was penetrated with the open price, or if the bar includes the stop price, then the limit
        order becomes active.
      * If the limit order is active:
          * If the limit order was activated in this same bar and the limit price is penetrated as well, then the
            best between the stop price and the limit fill price (as described earlier) is used.
          * If the limit order was activated at a previous bar then the limit fill price (as described earlier)
            is used.
  
  .. note::
      * This is the default strategy used by the Broker.
      * It uses :class:`pyalgotrade.broker.slippage.NoSlippage` slippage model by default.
      * If volumeLimit is 0.25, and a certain bar's volume is 100, then no more than 25 shares can be used by all
        orders that get processed at that bar.
      * If using trade bars, then all the volume from that bar can be used.
class_docstr_tok: ["Default","fill","strategy",".",":","param","volumeLimit",":","The","proportion","of","the","volume","that","orders","can","take","up","in","a","bar",".","Must","be",">","0","and","<","=","1",".","If","None",",","then","volume","limit","is","not","checked",".",":","type","volumeLimit",":","float","This","strategy","works","as","follows",":","*","A",":","class",":","`","pyalgotrade.broker.MarketOrder","`","is","always","filled","using","the","open\/close","price",".","*","A",":","class",":","`","pyalgotrade.broker.LimitOrder","`","will","be","filled","like","this",":","*","If","the","limit","price","was","penetrated","with","the","open","price",",","then","the","open","price","is","used",".","*","If","the","bar","includes","the","limit","price",",","then","the","limit","price","is","used",".","*","Note","that","when","buying","the","price","is","penetrated","if","it","gets","<","=","the","limit","price",",","and","when","selling","the","price","is","penetrated","if","it","gets",">","=","the","limit","price","*","A",":","class",":","`","pyalgotrade.broker.StopOrder","`","will","be","filled","like","this",":","*","If","the","stop","price","was","penetrated","with","the","open","price",",","then","the","open","price","is","used",".","*","If","the","bar","includes","the","stop","price",",","then","the","stop","price","is","used",".","*","Note","that","when","buying","the","price","is","penetrated","if","it","gets",">","=","the","stop","price",",","and","when","selling","the","price","is","penetrated","if","it","gets","<","=","the","stop","price","*","A",":","class",":","`","pyalgotrade.broker.StopLimitOrder","`","will","be","filled","like","this",":","*","If","the","stop","price","was","penetrated","with","the","open","price",",","or","if","the","bar","includes","the","stop","price",",","then","the","limit","order","becomes","active",".","*","If","the","limit","order","is","active",":","*","If","the","limit","order","was","activated","in","this","same","bar","and","the","limit","price","is","penetrated","as","well",",","then","the","best","between","the","stop","price","and","the","limit","fill","price","(","as","described","earlier",")","is","used",".","*","If","the","limit","order","was","activated","at","a","previous","bar","then","the","limit","fill","price","(","as","described","earlier",")","is","used",".","..","note",":",":","*","This","is","the","default","strategy","used","by","the","Broker",".","*","It","uses",":","class",":","`","pyalgotrade.broker.slippage.NoSlippage","`","slippage","model","by","default",".","*","If","volumeLimit","is","0.25",",","and","a","certain","bar","'s","volume","is","100",",","then","no","more","than","25","shares","can","be","used","by","all","orders","that","get","processed","at","that","bar",".","*","If","using","trade","bars",",","then","all","the","volume","from","that","bar","can","be","used","."]
code: def fillStopLimitOrder(self, broker_, order, bar):
      ret = None
  
      # First check if the stop price was hit so the limit order becomes active.
      stopPriceTrigger = None
      if not order.getStopHit():
          stopPriceTrigger = get_stop_price_trigger(
              order.getAction(),
              order.getStopPrice(),
              broker_.getUseAdjustedValues(),
              bar,
          )
          order.setStopHit(stopPriceTrigger is not None)
  
      # If the stop price was hit, check if we can fill the limit order.
      if order.getStopHit():
          # Calculate the fill size for the order.
          fillSize = self.__calculateFillSize(broker_, order, bar)
          if fillSize == 0:
              broker_.getLogger().debug(
                  "Not enough volume to fill %s stop limit order [%s] for %s share/s"
                  % (
                      order.getInstrument(),
                      order.getId(),
                      order.getRemaining(),
                  )
              )
              return None
  
          price = get_limit_price_trigger(
              order.getAction(),
              order.getLimitPrice(),
              broker_.getUseAdjustedValues(),
              bar,
          )
          if price is not None:
              # If we just hit the stop price, we need to make additional checks.
              if stopPriceTrigger is not None:
                  if order.isBuy():
                      # If the stop price triggered is lower than the limit price, then use that one.
                      # Else use the limit price.
                      price = min(
                          stopPriceTrigger, order.getLimitPrice()
                      )
                  else:
                      # If the stop price triggered is greater than the limit price, then use that one.
                      # Else use the limit price.
                      price = max(
                          stopPriceTrigger, order.getLimitPrice()
                      )
  
              ret = FillInfo(price, fillSize)
  
      return ret
  
imports: import abc
  import six
  from pyalgotrade import broker
  import pyalgotrade.bar
  from .None import slippage
label_desc: Use image node_id 12 for calling the DefaultStrategy obj's underlying member method code with example usage: obj.fillStopLimitOrder(broker_, order, bar) and returns: ret, None