Harmonize short parameter name in stoploss_from_open()
This commit is contained in:
parent
40cd478c6d
commit
17ae6a0c78
@ -69,7 +69,7 @@ def merge_informative_pair(dataframe: pd.DataFrame, informative: pd.DataFrame,
|
|||||||
def stoploss_from_open(
|
def stoploss_from_open(
|
||||||
open_relative_stop: float,
|
open_relative_stop: float,
|
||||||
current_profit: float,
|
current_profit: float,
|
||||||
for_short: bool = False
|
is_short: bool = False
|
||||||
) -> float:
|
) -> float:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -84,15 +84,15 @@ def stoploss_from_open(
|
|||||||
|
|
||||||
:param open_relative_stop: Desired stop loss percentage relative to open price
|
:param open_relative_stop: Desired stop loss percentage relative to open price
|
||||||
:param current_profit: The current profit percentage
|
: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
|
:return: Stop loss value relative to current price
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# formula is undefined for current_profit -1 (longs) or 1 (shorts), return maximum value
|
# 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
|
return 1
|
||||||
|
|
||||||
if for_short is True:
|
if is_short is True:
|
||||||
stoploss = -1+((1-open_relative_stop)/(1-current_profit))
|
stoploss = -1+((1-open_relative_stop)/(1-current_profit))
|
||||||
else:
|
else:
|
||||||
stoploss = 1-((1+open_relative_stop)/(1+current_profit))
|
stoploss = 1-((1+open_relative_stop)/(1+current_profit))
|
||||||
|
Loading…
Reference in New Issue
Block a user