Update entry/exit timeout documentation
the type of order is now an Order, no longer a dictionary. closes #6691
This commit is contained in:
parent
a4ec8984cd
commit
4019c05fee
@ -418,7 +418,7 @@ The function must return either `True` (cancel order) or `False` (keep order ali
|
|||||||
|
|
||||||
``` python
|
``` python
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from freqtrade.persistence import Trade
|
from freqtrade.persistence import Trade, Order
|
||||||
|
|
||||||
class AwesomeStrategy(IStrategy):
|
class AwesomeStrategy(IStrategy):
|
||||||
|
|
||||||
@ -430,7 +430,7 @@ class AwesomeStrategy(IStrategy):
|
|||||||
'exit': 60 * 25
|
'exit': 60 * 25
|
||||||
}
|
}
|
||||||
|
|
||||||
def check_entry_timeout(self, pair: str, trade: 'Trade', order: dict,
|
def check_entry_timeout(self, pair: str, trade: 'Trade', order: 'Order',
|
||||||
current_time: datetime, **kwargs) -> bool:
|
current_time: datetime, **kwargs) -> bool:
|
||||||
if trade.open_rate > 100 and trade.open_date_utc < current_time - timedelta(minutes=5):
|
if trade.open_rate > 100 and trade.open_date_utc < current_time - timedelta(minutes=5):
|
||||||
return True
|
return True
|
||||||
@ -441,7 +441,7 @@ class AwesomeStrategy(IStrategy):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def check_exit_timeout(self, pair: str, trade: Trade, order: dict,
|
def check_exit_timeout(self, pair: str, trade: Trade, order: 'Order',
|
||||||
current_time: datetime, **kwargs) -> bool:
|
current_time: datetime, **kwargs) -> bool:
|
||||||
if trade.open_rate > 100 and trade.open_date_utc < current_time - timedelta(minutes=5):
|
if trade.open_rate > 100 and trade.open_date_utc < current_time - timedelta(minutes=5):
|
||||||
return True
|
return True
|
||||||
@ -459,7 +459,7 @@ class AwesomeStrategy(IStrategy):
|
|||||||
|
|
||||||
``` python
|
``` python
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from freqtrade.persistence import Trade
|
from freqtrade.persistence import Trade, Order
|
||||||
|
|
||||||
class AwesomeStrategy(IStrategy):
|
class AwesomeStrategy(IStrategy):
|
||||||
|
|
||||||
@ -471,22 +471,22 @@ class AwesomeStrategy(IStrategy):
|
|||||||
'exit': 60 * 25
|
'exit': 60 * 25
|
||||||
}
|
}
|
||||||
|
|
||||||
def check_entry_timeout(self, pair: str, trade: Trade, order: dict,
|
def check_entry_timeout(self, pair: str, trade: 'Trade', order: 'Order',
|
||||||
current_time: datetime, **kwargs) -> bool:
|
current_time: datetime, **kwargs) -> bool:
|
||||||
ob = self.dp.orderbook(pair, 1)
|
ob = self.dp.orderbook(pair, 1)
|
||||||
current_price = ob['bids'][0][0]
|
current_price = ob['bids'][0][0]
|
||||||
# Cancel buy order if price is more than 2% above the order.
|
# Cancel buy order if price is more than 2% above the order.
|
||||||
if current_price > order['price'] * 1.02:
|
if current_price > order.price * 1.02:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def check_exit_timeout(self, pair: str, trade: Trade, order: dict,
|
def check_exit_timeout(self, pair: str, trade: 'Trade', order: 'Order',
|
||||||
current_time: datetime, **kwargs) -> bool:
|
current_time: datetime, **kwargs) -> bool:
|
||||||
ob = self.dp.orderbook(pair, 1)
|
ob = self.dp.orderbook(pair, 1)
|
||||||
current_price = ob['asks'][0][0]
|
current_price = ob['asks'][0][0]
|
||||||
# Cancel sell order if price is more than 2% below the order.
|
# Cancel sell order if price is more than 2% below the order.
|
||||||
if current_price < order['price'] * 0.98:
|
if current_price < order.price * 0.98:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
```
|
```
|
||||||
|
@ -183,11 +183,11 @@ class AwesomeStrategy(IStrategy):
|
|||||||
|
|
||||||
``` python hl_lines="2 6"
|
``` python hl_lines="2 6"
|
||||||
class AwesomeStrategy(IStrategy):
|
class AwesomeStrategy(IStrategy):
|
||||||
def check_entry_timeout(self, pair: str, trade: 'Trade', order: dict,
|
def check_entry_timeout(self, pair: str, trade: 'Trade', order: 'Order',
|
||||||
current_time: datetime, **kwargs) -> bool:
|
current_time: datetime, **kwargs) -> bool:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def check_exit_timeout(self, pair: str, trade: 'Trade', order: dict,
|
def check_exit_timeout(self, pair: str, trade: 'Trade', order: 'Order',
|
||||||
current_time: datetime, **kwargs) -> bool:
|
current_time: datetime, **kwargs) -> bool:
|
||||||
return False
|
return False
|
||||||
```
|
```
|
||||||
|
@ -206,18 +206,18 @@ class IStrategy(ABC, HyperStrategyMixin):
|
|||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def check_buy_timeout(self, pair: str, trade: Trade, order: dict,
|
def check_buy_timeout(self, pair: str, trade: Trade, order: Order,
|
||||||
current_time: datetime, **kwargs) -> bool:
|
current_time: datetime, **kwargs) -> bool:
|
||||||
"""
|
"""
|
||||||
DEPRECATED: Please use `check_entry_timeout` instead.
|
DEPRECATED: Please use `check_entry_timeout` instead.
|
||||||
"""
|
"""
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def check_entry_timeout(self, pair: str, trade: Trade, order: dict,
|
def check_entry_timeout(self, pair: str, trade: Trade, order: Order,
|
||||||
current_time: datetime, **kwargs) -> bool:
|
current_time: datetime, **kwargs) -> bool:
|
||||||
"""
|
"""
|
||||||
Check entry timeout function callback.
|
Check entry timeout function callback.
|
||||||
This method can be used to override the enter-timeout.
|
This method can be used to override the entry-timeout.
|
||||||
It is called whenever a limit entry order has been created,
|
It is called whenever a limit entry order has been created,
|
||||||
and is not yet fully filled.
|
and is not yet fully filled.
|
||||||
Configuration options in `unfilledtimeout` will be verified before this,
|
Configuration options in `unfilledtimeout` will be verified before this,
|
||||||
@ -225,8 +225,8 @@ class IStrategy(ABC, HyperStrategyMixin):
|
|||||||
|
|
||||||
When not implemented by a strategy, this simply returns False.
|
When not implemented by a strategy, this simply returns False.
|
||||||
:param pair: Pair the trade is for
|
:param pair: Pair the trade is for
|
||||||
:param trade: trade object.
|
:param trade: Trade object.
|
||||||
:param order: Order dictionary as returned from CCXT.
|
:param order: Order object.
|
||||||
:param current_time: datetime object, containing the current datetime
|
:param current_time: datetime object, containing the current datetime
|
||||||
:param **kwargs: Ensure to keep this here so updates to this won't break your strategy.
|
:param **kwargs: Ensure to keep this here so updates to this won't break your strategy.
|
||||||
:return bool: When True is returned, then the entry order is cancelled.
|
:return bool: When True is returned, then the entry order is cancelled.
|
||||||
@ -234,30 +234,30 @@ class IStrategy(ABC, HyperStrategyMixin):
|
|||||||
return self.check_buy_timeout(
|
return self.check_buy_timeout(
|
||||||
pair=pair, trade=trade, order=order, current_time=current_time)
|
pair=pair, trade=trade, order=order, current_time=current_time)
|
||||||
|
|
||||||
def check_sell_timeout(self, pair: str, trade: Trade, order: dict,
|
def check_sell_timeout(self, pair: str, trade: Trade, order: Order,
|
||||||
current_time: datetime, **kwargs) -> bool:
|
current_time: datetime, **kwargs) -> bool:
|
||||||
"""
|
"""
|
||||||
DEPRECATED: Please use `check_exit_timeout` instead.
|
DEPRECATED: Please use `check_exit_timeout` instead.
|
||||||
"""
|
"""
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def check_exit_timeout(self, pair: str, trade: Trade, order: dict,
|
def check_exit_timeout(self, pair: str, trade: Trade, order: Order,
|
||||||
current_time: datetime, **kwargs) -> bool:
|
current_time: datetime, **kwargs) -> bool:
|
||||||
"""
|
"""
|
||||||
Check sell 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.
|
||||||
It is called whenever a (long) limit sell order or (short) limit buy
|
It is called whenever a limit exit order has been created,
|
||||||
has been created, and is not yet fully filled.
|
and is not yet fully filled.
|
||||||
Configuration options in `unfilledtimeout` will be verified before this,
|
Configuration options in `unfilledtimeout` will be verified before this,
|
||||||
so ensure to set these timeouts high enough.
|
so ensure to set these timeouts high enough.
|
||||||
|
|
||||||
When not implemented by a strategy, this simply returns False.
|
When not implemented by a strategy, this simply returns False.
|
||||||
:param pair: Pair the trade is for
|
:param pair: Pair the trade is for
|
||||||
:param trade: trade object.
|
:param trade: Trade object.
|
||||||
:param order: Order dictionary as returned from CCXT.
|
:param order: Order object
|
||||||
:param current_time: datetime object, containing the current datetime
|
:param current_time: datetime object, containing the current datetime
|
||||||
:param **kwargs: Ensure to keep this here so updates to this won't break your strategy.
|
:param **kwargs: Ensure to keep this here so updates to this won't break your strategy.
|
||||||
:return bool: When True is returned, then the (long)sell/(short)buy-order is cancelled.
|
:return bool: When True is returned, then the exit-order is cancelled.
|
||||||
"""
|
"""
|
||||||
return self.check_sell_timeout(
|
return self.check_sell_timeout(
|
||||||
pair=pair, trade=trade, order=order, current_time=current_time)
|
pair=pair, trade=trade, order=order, current_time=current_time)
|
||||||
|
@ -170,7 +170,8 @@ def confirm_trade_exit(self, pair: str, trade: 'Trade', order_type: str, amount:
|
|||||||
"""
|
"""
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def check_entry_timeout(self, pair: str, trade: 'Trade', order: dict, **kwargs) -> bool:
|
def check_entry_timeout(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.
|
||||||
@ -183,14 +184,16 @@ def check_entry_timeout(self, pair: str, trade: 'Trade', order: dict, **kwargs)
|
|||||||
|
|
||||||
When not implemented by a strategy, this simply returns False.
|
When not implemented by a strategy, this simply returns False.
|
||||||
:param pair: Pair the trade is for
|
:param pair: Pair the trade is for
|
||||||
:param trade: trade object.
|
:param trade: Trade object.
|
||||||
:param order: Order dictionary as returned from CCXT.
|
:param order: Order object.
|
||||||
|
:param current_time: datetime object, containing the current datetime
|
||||||
:param **kwargs: Ensure to keep this here so updates to this won't break your strategy.
|
:param **kwargs: Ensure to keep this here so updates to this won't break your strategy.
|
||||||
:return bool: When True is returned, then the buy-order is cancelled.
|
:return bool: When True is returned, then the entry order is cancelled.
|
||||||
"""
|
"""
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def check_exit_timeout(self, pair: str, trade: 'Trade', order: dict, **kwargs) -> bool:
|
def check_exit_timeout(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.
|
||||||
@ -203,8 +206,9 @@ def check_exit_timeout(self, pair: str, trade: 'Trade', order: dict, **kwargs) -
|
|||||||
|
|
||||||
When not implemented by a strategy, this simply returns False.
|
When not implemented by a strategy, this simply returns False.
|
||||||
:param pair: Pair the trade is for
|
:param pair: Pair the trade is for
|
||||||
:param trade: trade object.
|
:param trade: Trade object.
|
||||||
:param order: Order dictionary as returned from CCXT.
|
:param order: Order object.
|
||||||
|
:param current_time: datetime object, containing the current datetime
|
||||||
:param **kwargs: Ensure to keep this here so updates to this won't break your strategy.
|
:param **kwargs: Ensure to keep this here so updates to this won't break your strategy.
|
||||||
:return bool: When True is returned, then the exit-order is cancelled.
|
:return bool: When True is returned, then the exit-order is cancelled.
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user