Harmonize short parameter name in stoploss_from_open()

This commit is contained in:
Guillermo Rodríguez 2022-01-22 18:01:56 +01:00
parent 40cd478c6d
commit 17ae6a0c78

View File

@ -69,7 +69,7 @@ def merge_informative_pair(dataframe: pd.DataFrame, informative: pd.DataFrame,
def stoploss_from_open(
open_relative_stop: float,
current_profit: float,
for_short: bool = False
is_short: bool = False
) -> float:
"""
@ -84,15 +84,15 @@ def stoploss_from_open(
:param open_relative_stop: Desired stop loss percentage relative to open price
:param current_profit: The current profit percentage
:param for_short: When true, perform the calculation for short instead of long
:param is_short: When true, perform the calculation for short instead of long
:return: Stop loss value relative to current price
"""
# formula is undefined for current_profit -1 (longs) or 1 (shorts), return maximum value
if (current_profit == -1 and not for_short) or (for_short and current_profit == 1):
if (current_profit == -1 and not is_short) or (is_short and current_profit == 1):
return 1
if for_short is True:
if is_short is True:
stoploss = -1+((1-open_relative_stop)/(1-current_profit))
else:
stoploss = 1-((1+open_relative_stop)/(1+current_profit))