From e7684b446b3c737a01da2d88dd0be08a4f4b78d8 Mon Sep 17 00:00:00 2001 From: misagh Date: Tue, 4 Dec 2018 17:05:35 +0100 Subject: [PATCH] capital in trade extracted to a separated argument --- freqtrade/edge/__init__.py | 10 +++++++--- freqtrade/freqtradebot.py | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/freqtrade/edge/__init__.py b/freqtrade/edge/__init__.py index a212c9849..49acbd3e7 100644 --- a/freqtrade/edge/__init__.py +++ b/freqtrade/edge/__init__.py @@ -160,19 +160,23 @@ class Edge(): return True - def stake_amount(self, pair: str, free_capital: float, total_capital: float) -> float: + def stake_amount(self, pair: str, free_capital: float, + total_capital: float, capital_in_trade: float) -> float: stoploss = self.stoploss(pair) - available_capital = total_capital * self._capital_percentage + available_capital = (total_capital + capital_in_trade) * self._capital_percentage allowed_capital_at_risk = available_capital * self._allowed_risk max_position_size = abs(allowed_capital_at_risk / stoploss) position_size = min(max_position_size, free_capital) if pair in self._cached_pairs: logger.info( 'winrate: %s, expectancy: %s, position size: %s, pair: %s,' + ' capital in trade: %s, free capital: %s, total capital: %s,' ' stoploss: %s, available capital: %s.', self._cached_pairs[pair].winrate, self._cached_pairs[pair].expectancy, - position_size, pair, stoploss, available_capital + position_size, pair, + capital_in_trade, free_capital, total_capital, + stoploss, available_capital ) return round(position_size, 15) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index 6baef76bc..d782f4342 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -305,7 +305,7 @@ class FreqtradeBot(object): return self.edge.stake_amount( pair, self.wallets.get_free(self.config['stake_currency']), - self.wallets.get_total(self.config['stake_currency']) + + self.wallets.get_total(self.config['stake_currency']), Trade.total_open_trades_stakes() ) else: