From 0985b11267b890aeeccaed79ebc4ed9644c39f99 Mon Sep 17 00:00:00 2001 From: axel Date: Thu, 5 Aug 2021 18:16:16 -0400 Subject: [PATCH] add doc for custom exit price --- docs/strategy-advanced.md | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/docs/strategy-advanced.md b/docs/strategy-advanced.md index a8e54bbcf..f59cb8ef5 100644 --- a/docs/strategy-advanced.md +++ b/docs/strategy-advanced.md @@ -357,13 +357,13 @@ See [Dataframe access](#dataframe-access) for more information about dataframe u --- -## Custom order entry price rules +## Custom order price rules By default, freqtrade use the orderbook to automatically set an order price, you also have the option to create custom order prices based on your strategy. -You can use this feature by setting the `use_custom_entry_price` option to `true` in config and creating a custom_entry_price function. +You can use this feature by creating a custom_entry_price function in your strategy file to customize entry prices and custom_exit_price for exits. -### Custom order entry price exemple +### Custom order entry and exit price exemple ``` python from datetime import datetime, timedelta, timezone from freqtrade.persistence import Trade @@ -373,13 +373,23 @@ class AwesomeStrategy(IStrategy): # ... populate_* methods def custom_entry_price(self, pair: str, current_time: datetime, - proposed_rate, **kwargs) -> float: + proposed_rate, **kwargs) -> float: dataframe, last_updated = self.dp.get_analyzed_dataframe(pair=pair, timeframe=self.timeframe) - entryprice = dataframe['bollinger_10_lowerband'].iat[-1] + proposed_entryprice = dataframe['bollinger_10_lowerband'].iat[-1] - return entryprice + return proposed_entryprice + + def custom_exit_price(self, pair: str, trade: Trade, + current_time: datetime, proposed_rate: float, + current_profit: float, **kwargs) -> float: + + dataframe, last_updated = self.dp.get_analyzed_dataframe(pair=pair, + timeframe=self.timeframe) + proposed_exitprice = dataframe['bollinger_10_upperband'].iat[-1] + + return proposed_exitprice ```