chore: update advanced template to new formatting
Some checks are pending
Build Documentation / Deploy Docs through mike (push) Waiting to run

This commit is contained in:
Matthias 2024-11-11 20:25:15 +01:00
parent d9b8f46282
commit 0b0b221c02

View File

@ -13,9 +13,16 @@ def bot_loop_start(self, current_time: datetime, **kwargs) -> None:
""" """
pass pass
def custom_entry_price(self, pair: str, trade: Optional[Trade], def custom_entry_price(
current_time: datetime, proposed_rate: float, self,
entry_tag: Optional[str], side: str, **kwargs) -> float: pair: str,
trade: Trade | None,
current_time: datetime,
proposed_rate: float,
entry_tag: str | None,
side: str,
**kwargs,
) -> float:
""" """
Custom entry price logic, returning the new entry price. Custom entry price logic, returning the new entry price.
@ -33,9 +40,18 @@ def custom_entry_price(self, pair: str, trade: Optional[Trade],
""" """
return proposed_rate return proposed_rate
def adjust_entry_price(self, trade: Trade, order: Optional[Order], pair: str, def adjust_entry_price(
current_time: datetime, proposed_rate: float, current_order_rate: float, self,
entry_tag: Optional[str], side: str, **kwargs) -> float: trade: Trade,
order: Order | None,
pair: str,
current_time: datetime,
proposed_rate: float,
current_order_rate: float,
entry_tag: str | None,
side: str,
**kwargs,
) -> float:
""" """
Entry price re-adjustment logic, returning the user desired limit price. Entry price re-adjustment logic, returning the user desired limit price.
This only executes when a order was already placed, still open (unfilled fully or partially) This only executes when a order was already placed, still open (unfilled fully or partially)
@ -61,9 +77,16 @@ def adjust_entry_price(self, trade: Trade, order: Optional[Order], pair: str,
""" """
return current_order_rate return current_order_rate
def custom_exit_price(self, pair: str, trade: Trade, def custom_exit_price(
current_time: datetime, proposed_rate: float, self,
current_profit: float, exit_tag: Optional[str], **kwargs) -> float: pair: str,
trade: Trade,
current_time: datetime,
proposed_rate: float,
current_profit: float,
exit_tag: str | None,
**kwargs,
) -> float:
""" """
Custom exit price logic, returning the new exit price. Custom exit price logic, returning the new exit price.
@ -82,10 +105,19 @@ def custom_exit_price(self, pair: str, trade: Trade,
""" """
return proposed_rate return proposed_rate
def custom_stake_amount(self, pair: str, current_time: datetime, current_rate: float, def custom_stake_amount(
proposed_stake: float, min_stake: Optional[float], max_stake: float, self,
leverage: float, entry_tag: Optional[str], side: str, pair: str,
**kwargs) -> float: current_time: datetime,
current_rate: float,
proposed_stake: float,
min_stake: float | None,
max_stake: float,
leverage: float,
entry_tag: str | None,
side: str,
**kwargs,
) -> float:
""" """
Customize stake size for each new trade. Customize stake size for each new trade.
@ -104,8 +136,16 @@ def custom_stake_amount(self, pair: str, current_time: datetime, current_rate: f
use_custom_stoploss = True use_custom_stoploss = True
def custom_stoploss(self, pair: str, trade: Trade, current_time: datetime, current_rate: float, def custom_stoploss(
current_profit: float, after_fill: bool, **kwargs) -> float: self,
pair: str,
trade: Trade,
current_time: datetime,
current_rate: float,
current_profit: float,
after_fill: bool,
**kwargs,
) -> float | None:
""" """
Custom stoploss logic, returning the new distance relative to current_rate (as ratio). Custom stoploss logic, returning the new distance relative to current_rate (as ratio).
e.g. returning -0.05 would create a stoploss 5% below current_rate. e.g. returning -0.05 would create a stoploss 5% below current_rate.
@ -126,8 +166,15 @@ def custom_stoploss(self, pair: str, trade: Trade, current_time: datetime, curre
:return float: New stoploss value, relative to the current_rate :return float: New stoploss value, relative to the current_rate
""" """
def custom_exit(self, pair: str, trade: Trade, current_time: datetime, current_rate: float, def custom_exit(
current_profit: float, **kwargs) -> Optional[Union[str, bool]]: self,
pair: str,
trade: Trade,
current_time: datetime,
current_rate: float,
current_profit: float,
**kwargs,
) -> str | bool | None:
""" """
Custom exit signal logic indicating that specified position should be sold. Returning a Custom exit signal logic indicating that specified position should be sold. Returning a
string or True from this method is equal to setting sell signal on a candle at specified string or True from this method is equal to setting sell signal on a candle at specified
@ -150,9 +197,18 @@ def custom_exit(self, pair: str, trade: Trade, current_time: datetime, current_r
""" """
return None return None
def confirm_trade_entry(self, pair: str, order_type: str, amount: float, rate: float, def confirm_trade_entry(
time_in_force: str, current_time: datetime, entry_tag: Optional[str], self,
side: str, **kwargs) -> bool: pair: str,
order_type: str,
amount: float,
rate: float,
time_in_force: str,
current_time: datetime,
entry_tag: str | None,
side: str,
**kwargs,
) -> bool:
""" """
Called right before placing a entry order. Called right before placing a entry order.
Timing for this function is critical, so avoid doing heavy computations or Timing for this function is critical, so avoid doing heavy computations or
@ -177,9 +233,18 @@ def confirm_trade_entry(self, pair: str, order_type: str, amount: float, rate: f
""" """
return True return True
def confirm_trade_exit(self, pair: str, trade: Trade, order_type: str, amount: float, def confirm_trade_exit(
rate: float, time_in_force: str, exit_reason: str, self,
current_time: datetime, **kwargs) -> bool: pair: str,
trade: Trade,
order_type: str,
amount: float,
rate: float,
time_in_force: str,
exit_reason: str,
current_time: datetime,
**kwargs,
) -> bool:
""" """
Called right before placing a regular exit order. Called right before placing a regular exit order.
Timing for this function is critical, so avoid doing heavy computations or Timing for this function is critical, so avoid doing heavy computations or
@ -206,8 +271,9 @@ def confirm_trade_exit(self, pair: str, trade: Trade, order_type: str, amount: f
""" """
return True return True
def check_entry_timeout(self, pair: str, trade: Trade, order: Order, def check_entry_timeout(
current_time: datetime, **kwargs) -> bool: self, pair: str, trade: Trade, order: Order, current_time: datetime, **kwargs
) -> bool:
""" """
Check entry timeout function callback. Check entry timeout function callback.
This method can be used to override the entry-timeout. This method can be used to override the entry-timeout.
@ -228,8 +294,9 @@ def check_entry_timeout(self, pair: str, trade: Trade, order: Order,
""" """
return False return False
def check_exit_timeout(self, pair: str, trade: Trade, order: Order, def check_exit_timeout(
current_time: datetime, **kwargs) -> bool: self, pair: str, trade: Trade, order: Order, current_time: datetime, **kwargs
) -> bool:
""" """
Check exit timeout function callback. Check exit timeout function callback.
This method can be used to override the exit-timeout. This method can be used to override the exit-timeout.
@ -250,12 +317,20 @@ def check_exit_timeout(self, pair: str, trade: Trade, order: Order,
""" """
return False return False
def adjust_trade_position(self, trade: Trade, current_time: datetime, def adjust_trade_position(
current_rate: float, current_profit: float, self,
min_stake: Optional[float], max_stake: float, trade: Trade,
current_entry_rate: float, current_exit_rate: float, current_time: datetime,
current_entry_profit: float, current_exit_profit: float, current_rate: float,
**kwargs) -> Optional[float]: current_profit: float,
min_stake: float | None,
max_stake: float,
current_entry_rate: float,
current_exit_rate: float,
current_entry_profit: float,
current_exit_profit: float,
**kwargs,
) -> float | None | tuple[float | None, str | None]:
""" """
Custom trade adjustment logic, returning the stake amount that a trade should be Custom trade adjustment logic, returning the stake amount that a trade should be
increased or decreased. increased or decreased.
@ -284,9 +359,17 @@ def adjust_trade_position(self, trade: Trade, current_time: datetime,
""" """
return None return None
def leverage(self, pair: str, current_time: datetime, current_rate: float, def leverage(
proposed_leverage: float, max_leverage: float, entry_tag: Optional[str], self,
side: str, **kwargs) -> float: pair: str,
current_time: datetime,
current_rate: float,
proposed_leverage: float,
max_leverage: float,
entry_tag: str | None,
side: str,
**kwargs,
) -> float:
""" """
Customize leverage for each new trade. This method is only called in futures mode. Customize leverage for each new trade. This method is only called in futures mode.
@ -302,8 +385,9 @@ def leverage(self, pair: str, current_time: datetime, current_rate: float,
return 1.0 return 1.0
def order_filled(self, pair: str, trade: Trade, order: Order, def order_filled(
current_time: datetime, **kwargs) -> None: self, pair: str, trade: Trade, order: Order, current_time: datetime, **kwargs
) -> None:
""" """
Called right after an order fills. Called right after an order fills.
Will be called for all order types (entry, exit, stoploss, position adjustment). Will be called for all order types (entry, exit, stoploss, position adjustment).