diff --git a/freqtrade/persistence.py b/freqtrade/persistence.py index 79903d66f..e3043089f 100644 --- a/freqtrade/persistence.py +++ b/freqtrade/persistence.py @@ -187,8 +187,8 @@ class Trade(_DECL_BASE): """ open_trade_price = self.calc_open_trade_price() close_trade_price = self.calc_close_trade_price( - rate=Decimal(rate or self.close_rate), - fee=Decimal(fee or self.fee) + rate=(rate or self.close_rate), + fee=(fee or self.fee) ) return float("{0:.8f}".format(close_trade_price - open_trade_price)) @@ -206,8 +206,8 @@ class Trade(_DECL_BASE): open_trade_price = self.calc_open_trade_price() close_trade_price = self.calc_close_trade_price( - rate=Decimal(rate or self.close_rate), - fee=Decimal(fee or self.fee) + rate=(rate or self.close_rate), + fee=(fee or self.fee) ) return float("{0:.8f}".format((close_trade_price / open_trade_price) - 1)) diff --git a/freqtrade/tests/test_persistence.py b/freqtrade/tests/test_persistence.py index 401de7acb..f6c5318ce 100644 --- a/freqtrade/tests/test_persistence.py +++ b/freqtrade/tests/test_persistence.py @@ -271,10 +271,6 @@ def test_calc_profit(limit_buy_order, limit_sell_order): # Lower than open rate assert trade.calc_profit(rate=0.00000123, fee=0.003) == -0.00089092 - # Only custom fee without sell order applied - with pytest.raises(TypeError): - trade.calc_profit(fee=0.003) - # Test when we apply a Sell order. Sell higher than open rate @ 0.00001173 trade.update(limit_sell_order) assert trade.calc_profit() == 0.00006217 @@ -299,10 +295,6 @@ def test_calc_profit_percent(limit_buy_order, limit_sell_order): # Get percent of profit with a custom rate (Lower than open rate) assert trade.calc_profit_percent(rate=0.00000123) == -0.88863827 - # Only custom fee without sell order applied - with pytest.raises(TypeError): - trade.calc_profit_percent(fee=0.003) - # Test when we apply a Sell order. Sell higher than open rate @ 0.00001173 trade.update(limit_sell_order) assert trade.calc_profit_percent() == 0.06201057