Merge pull request #6440 from clover-es/feat/short
Add leverage strategy to new-strategy command
This commit is contained in:
commit
551fe7d820
@ -426,8 +426,7 @@ class IStrategy(ABC, HyperStrategyMixin):
|
|||||||
proposed_leverage: float, max_leverage: float, side: str,
|
proposed_leverage: float, max_leverage: float, side: str,
|
||||||
**kwargs) -> float:
|
**kwargs) -> float:
|
||||||
"""
|
"""
|
||||||
Customize leverage for each new trade. This method is not called when edge module is
|
Customize leverage for each new trade. This method is only called in futures mode.
|
||||||
enabled.
|
|
||||||
|
|
||||||
:param pair: Pair that's currently analyzed
|
:param pair: Pair that's currently analyzed
|
||||||
:param current_time: datetime object, containing the current datetime
|
:param current_time: datetime object, containing the current datetime
|
||||||
|
@ -129,6 +129,15 @@ class {{ strategy }}(IStrategy):
|
|||||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||||
),
|
),
|
||||||
'enter_long'] = 1
|
'enter_long'] = 1
|
||||||
|
# Uncomment to use shorts (Only used in futures/margin mode. Check the documentation for more info)
|
||||||
|
"""
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
{{ sell_trend | indent(16) }}
|
||||||
|
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||||
|
),
|
||||||
|
'enter_short'] = 1
|
||||||
|
"""
|
||||||
|
|
||||||
return dataframe
|
return dataframe
|
||||||
|
|
||||||
@ -145,5 +154,14 @@ class {{ strategy }}(IStrategy):
|
|||||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||||
),
|
),
|
||||||
'exit_long'] = 1
|
'exit_long'] = 1
|
||||||
|
# Uncomment to use shorts (Only used in futures/margin mode. Check the documentation for more info)
|
||||||
|
"""
|
||||||
|
dataframe.loc[
|
||||||
|
(
|
||||||
|
{{ buy_trend | indent(16) }}
|
||||||
|
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||||
|
),
|
||||||
|
'exit_short'] = 1
|
||||||
|
"""
|
||||||
return dataframe
|
return dataframe
|
||||||
{{ additional_methods | indent(4) }}
|
{{ additional_methods | indent(4) }}
|
||||||
|
@ -232,3 +232,19 @@ def adjust_trade_position(self, trade: 'Trade', current_time: 'datetime',
|
|||||||
:return float: Stake amount to adjust your trade
|
:return float: Stake amount to adjust your trade
|
||||||
"""
|
"""
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def leverage(self, pair: str, current_time: datetime, current_rate: float,
|
||||||
|
proposed_leverage: float, max_leverage: float, side: str,
|
||||||
|
**kwargs) -> float:
|
||||||
|
"""
|
||||||
|
Customize leverage for each new trade. This method is only called in futures mode.
|
||||||
|
|
||||||
|
:param pair: Pair that's currently analyzed
|
||||||
|
:param current_time: datetime object, containing the current datetime
|
||||||
|
:param current_rate: Rate, calculated based on pricing settings in ask_strategy.
|
||||||
|
:param proposed_leverage: A leverage proposed by the bot.
|
||||||
|
:param max_leverage: Max leverage allowed on this pair
|
||||||
|
:param side: 'long' or 'short' - indicating the direction of the proposed trade
|
||||||
|
:return: A leverage amount, which is between 1.0 and max_leverage.
|
||||||
|
"""
|
||||||
|
return 1.0
|
||||||
|
Loading…
Reference in New Issue
Block a user