code: def _check_spot_bid(spot_bid, spot_history):
      
      average = mean([datum.price for datum in spot_history])
      if spot_bid > average * 2:
          logger.warn("Your bid $ %f is more than double this instance type's average "
                   "spot price ($ %f) over the last week", spot_bid, average)
docs: Prevents users from potentially over-paying for instances
  
      Note: this checks over the whole region, not a particular zone
  
      :param spot_bid: float
  
      :type spot_history: list[SpotPriceHistory]
  
      :raises UserError: if bid is > 2X the spot price's average
  
      >>> from collections import namedtuple
      >>> FauxHistory = namedtuple( "FauxHistory", [ "price", "availability_zone" ] )
      >>> spot_data = [ FauxHistory( 0.1, "us-west-2a" ), \
                        FauxHistory( 0.2, "us-west-2a" ), \
                        FauxHistory( 0.3, "us-west-2b" ), \
                        FauxHistory( 0.6, "us-west-2b" ) ]
      >>> # noinspection PyProtectedMember
      >>> _check_spot_bid( 0.1, spot_data )
      >>> # noinspection PyProtectedMember
  
      # >>> Box._check_spot_bid( 2, spot_data )
      Traceback (most recent call last):
      ...
      UserError: Your bid $ 2.000000 is more than double this instance type's average spot price ($ 0.300000) over the last week