From 3e3ed947cc67d0093de093029db79275e2250e24 Mon Sep 17 00:00:00 2001 From: misagh Date: Fri, 21 Sep 2018 21:46:18 +0200 Subject: [PATCH] =?UTF-8?q?added=20=E2=80=9Cmax=5Ftrade=5Fduration?= =?UTF-8?q?=E2=80=9D=20config=20+=20using=20=E2=80=9Cremove=5Fdumps?= =?UTF-8?q?=E2=80=9D=20config?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.json.example | 3 ++- freqtrade/edge/__init__.py | 30 ++++++++---------------------- freqtrade/tests/conftest.py | 3 +++ 3 files changed, 13 insertions(+), 23 deletions(-) diff --git a/config.json.example b/config.json.example index 175a537f1..f90b4f470 100644 --- a/config.json.example +++ b/config.json.example @@ -55,8 +55,9 @@ "process_throttle_secs": 1800, "total_capital_in_stake_currency": 0.5, "allowed_risk": 0.01, - "maximum_winrate": 0.80, + "maximum_winrate": 0.80, "min_trade_number": 15, + "max_trade_duration_minute": 1440, "remove_pumps": true, "minimum_delta": 1 }, diff --git a/freqtrade/edge/__init__.py b/freqtrade/edge/__init__.py index 9668e1a44..46cdaaf32 100644 --- a/freqtrade/edge/__init__.py +++ b/freqtrade/edge/__init__.py @@ -43,11 +43,13 @@ class Edge(): self.get_timeframe = Backtesting.get_timeframe self.populate_buy_trend = self.strategy.populate_buy_trend self.populate_sell_trend = self.strategy.populate_sell_trend + + self.edge_config = self.config.get('edge', {}) self._last_updated = None self._cached_pairs = [] - self._total_capital = self.config['edge']['total_capital_in_stake_currency'] - self._allowed_risk = self.config['edge']['allowed_risk'] + self._total_capital = self.edge_config['total_capital_in_stake_currency'] + self._allowed_risk = self.edge_config['allowed_risk'] ### # @@ -303,7 +305,7 @@ class Edge(): ################################### # Removing pairs having less than min_trades_number - min_trades_number = 50 + min_trades_number = self.edge_config.get('min_trade_number', 15) results = results.groupby('pair').filter(lambda x: len(x) > min_trades_number) ################################### @@ -319,11 +321,12 @@ class Edge(): avg = results[["profit_abs"]].mean() # # Removing Pumps - results = results[results.profit_abs < float(avg + 2*std)] + if self.edge_config.get('remove_pumps', True): + results = results[results.profit_abs < float(avg + 2*std)] ########################################################################## # Removing trades having a duration more than X minutes (set in config) - max_trade_duration = 24*60 + max_trade_duration = self.edge_config.get('max_trade_duration_minute', 1440) results = results[results.trade_duration < max_trade_duration] ####################################################################### @@ -906,23 +909,6 @@ class Edge(): return (allowed_dollars_at_risk / symbol_strategy_stop_loss) - ### stake amount is the same as position size - ### calculate position size - # print("\n~~~~~~~~ Position Size ~~~~~~~~") - # print("bid price is ", bid_price) - # print("stop trigger is ", stop_trigger_price) - - # allowed_dollars_at_risk = total_capital * allowed_risk - # print("allowed capital at risk ", round(allowed_dollars_at_risk, 5)) - - # position_size = (allowed_dollars_at_risk / symbol_strategy_stop_loss) - # print("position_size in dollars", round(position_size, 5 )) - - # buy_amount = position_size / bid_price - # print("amount of tokens to buy ", round(buy_amount,5)) - - # check_risk = (buy_amount * (bid_price - stop_trigger_price)) - # print("check risk capital ", round(check_risk, 5), "** Should not be more than allowed capital at risk") def stoploss(self, pair: str) -> float: info = [x for x in self._cached_pairs if x[0] == pair][0] diff --git a/freqtrade/tests/conftest.py b/freqtrade/tests/conftest.py index 09c746df2..8a3f71f51 100644 --- a/freqtrade/tests/conftest.py +++ b/freqtrade/tests/conftest.py @@ -130,8 +130,11 @@ def default_conf(): "edge": { "enabled": False, "process_throttle_secs": 1800, + "total_capital_in_stake_currency": 0.5, + "allowed_risk": 0.01, "maximum_winrate": 0.80, "min_trade_number": 15, + "max_trade_duration_minute": 1440, "remove_pumps": True, "minimum_delta": 1 },