From 8a1155b0c5f4d453042a86ec9b87e2d716b1ab82 Mon Sep 17 00:00:00 2001 From: Gert Wohlgemuth Date: Fri, 11 May 2018 15:59:03 -0700 Subject: [PATCH 1/3] added trailing stop parameter to example files --- config.json.example | 1 + config_full.json.example | 1 + 2 files changed, 2 insertions(+) diff --git a/config.json.example b/config.json.example index 6a4f20cd6..5b98a505a 100644 --- a/config.json.example +++ b/config.json.example @@ -4,6 +4,7 @@ "stake_amount": 0.05, "fiat_display_currency": "USD", "dry_run": false, + "trailing_stop": false, "unfilledtimeout": 600, "bid_strategy": { "ask_last_balance": 0.0 diff --git a/config_full.json.example b/config_full.json.example index 77ef0faa0..570276e77 100644 --- a/config_full.json.example +++ b/config_full.json.example @@ -5,6 +5,7 @@ "fiat_display_currency": "USD", "dry_run": false, "ticker_interval": "5m", + "trailing_stop": true, "minimal_roi": { "40": 0.0, "30": 0.01, From 734c21fcfd865e851d41f7b11c27813dc0df6341 Mon Sep 17 00:00:00 2001 From: Gert Wohlgemuth Date: Fri, 11 May 2018 16:10:40 -0700 Subject: [PATCH 2/3] cleaned up the logging --- freqtrade/analyze.py | 4 ++-- freqtrade/persistence.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/freqtrade/analyze.py b/freqtrade/analyze.py index 535e5c310..c1bae8303 100644 --- a/freqtrade/analyze.py +++ b/freqtrade/analyze.py @@ -205,11 +205,11 @@ class Analyze(object): # just for debugging if 'trailing_stop' in self.config and self.config['trailing_stop']: - print( + logger.warning( "HIT STOP: current price at {:.6f}, stop loss is {:.6f}, " "initial stop loss was at {:.6f}, trade opened at {:.6f}".format( current_rate, trade.stop_loss, trade.initial_stop_loss, trade.open_rate)) - print("trailing stop saved us: {:.6f}".format(trade.stop_loss - trade.initial_stop_loss)) + logger.debug("trailing stop saved us: {:.6f}".format(trade.stop_loss - trade.initial_stop_loss)) logger.debug('Stop loss hit.') return True diff --git a/freqtrade/persistence.py b/freqtrade/persistence.py index 192052627..11823b09a 100644 --- a/freqtrade/persistence.py +++ b/freqtrade/persistence.py @@ -141,7 +141,7 @@ class Trade(_DECL_BASE): else: logger.debug("keeping current stop loss") - print( + logger.debug( "{} - current price {:.6f}, bought at {:.6f} and calculated " "stop loss is at: {:.6f} initial stop at {:.6f}. trailing stop loss saved us: {:.6f} " "and max observed rate was {:.6f}".format( From 749f05840583191cb69d5b6ef73f770c6cdc2f47 Mon Sep 17 00:00:00 2001 From: Gert Wohlgemuth Date: Sat, 12 May 2018 10:08:30 -0700 Subject: [PATCH 3/3] possible fixed the decimal error, which in non dry runs crashes the whole bot --- freqtrade/persistence.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/freqtrade/persistence.py b/freqtrade/persistence.py index 192052627..52aa17038 100644 --- a/freqtrade/persistence.py +++ b/freqtrade/persistence.py @@ -128,7 +128,7 @@ class Trade(_DECL_BASE): self.max_rate = current_price # no stop loss assigned yet - if self.stop_loss is None: + if self.stop_loss is None or self.stop_loss == 0: logger.debug("assigning new stop loss") self.stop_loss = new_loss self.initial_stop_loss = new_loss @@ -142,12 +142,12 @@ class Trade(_DECL_BASE): logger.debug("keeping current stop loss") print( - "{} - current price {:.6f}, bought at {:.6f} and calculated " - "stop loss is at: {:.6f} initial stop at {:.6f}. trailing stop loss saved us: {:.6f} " - "and max observed rate was {:.6f}".format( + "{} - current price {:.8f}, bought at {:.8f} and calculated " + "stop loss is at: {:.8f} initial stop at {:.8f}. trailing stop loss saved us: {:.8f} " + "and max observed rate was {:.8f}".format( self.pair, current_price, self.open_rate, self.initial_stop_loss, - self.stop_loss, self.stop_loss - self.initial_stop_loss, + self.stop_loss, float(self.stop_loss) - float(self.initial_stop_loss), self.max_rate ))