def METHOD_NAME(stop_rate: float, current_rate: float, is_short: bool = False,
                           leverage: float = 1.0) -> float:
    """
    Given current price and desired stop price, return a stop loss value that is relative to current
    price.
    The requested stop can be positive for a stop above the open price, or negative for
    a stop below the open price. The return value is always >= 0.
    Returns 0 if the resulting stop price would be above the current price.
    :param stop_rate: Stop loss price.
    :param current_rate: Current asset price.
    :param is_short: When true, perform the calculation for short instead of long
    :param leverage: Leverage to use for the calculation
    :return: Positive stop loss value relative to current price
    """
    # formula is undefined for current_rate 0, return maximum value
    if current_rate == 0:
        return 1
    stoploss = 1 - (stop_rate / current_rate)
    if is_short:
        stoploss = -stoploss
    # negative stoploss values indicate the requested stop price is higher/lower
    # (long/short) than the current price
    # shorts can yield stoploss values higher than 1, so limit that as well
    return max(min(stoploss, 1.0), 0.0) * leverage