Compare commits

..

3 Commits

Author SHA1 Message Date
Matthias
851c5dad30 Version bump 2022.4.2 2022-05-03 20:37:29 +02:00
Matthias
5b76ae452f Fix fee handling for futures trades 2022-05-03 20:35:30 +02:00
Matthias
2c750fdb09 Reduce no stake amount verbosity
closes #6768
2022-05-03 20:35:22 +02:00
4 changed files with 24 additions and 10 deletions

View File

@@ -1,5 +1,5 @@
""" Freqtrade bot """
__version__ = '2022.4.1'
__version__ = '2022.4.2'
if 'dev' in __version__:
try:

View File

@@ -1613,7 +1613,9 @@ class Exchange:
order['fee']['cost'] / safe_value_fallback2(order, order, 'filled', 'amount'), 8)
elif fee_curr in self.get_pair_quote_currency(order['symbol']):
# Quote currency - divide by cost
return round(order['fee']['cost'] / order['cost'], 8) if order['cost'] else None
return round(self._contracts_to_amount(
order['symbol'], order['fee']['cost']) / order['cost'],
8) if order['cost'] else None
else:
# If Fee currency is a different currency
if not order['cost']:
@@ -1628,7 +1630,8 @@ class Exchange:
fee_to_quote_rate = self._config['exchange'].get('unknown_fee_rate', None)
if not fee_to_quote_rate:
return None
return round((order['fee']['cost'] * fee_to_quote_rate) / order['cost'], 8)
return round((self._contracts_to_amount(
order['symbol'], order['fee']['cost']) * fee_to_quote_rate) / order['cost'], 8)
def extract_cost_curr_rate(self, order: Dict) -> Tuple[float, str, Optional[float]]:
"""

View File

@@ -599,7 +599,6 @@ class FreqtradeBot(LoggingMixin):
pair, price, stake_amount, trade_side, enter_tag, trade)
if not stake_amount:
logger.info(f"No stake amount to enter a trade for {pair}.")
return False
if pos_adjust:

View File

@@ -4151,7 +4151,10 @@ def test__order_contracts_to_amount(
'cost': 60.0,
'filled': None,
'remaining': 30.0,
'fee': 0.06,
'fee': {
'currency': 'USDT',
'cost': 0.06,
},
'fees': [{
'currency': 'USDT',
'cost': 0.06,
@@ -4178,7 +4181,10 @@ def test__order_contracts_to_amount(
'cost': 80.0,
'filled': None,
'remaining': 40.0,
'fee': 0.08,
'fee': {
'currency': 'USDT',
'cost': 0.08,
},
'fees': [{
'currency': 'USDT',
'cost': 0.08,
@@ -4212,12 +4218,18 @@ def test__order_contracts_to_amount(
'info': {},
},
]
order1_bef = orders[0]
order2_bef = orders[1]
order1 = exchange._order_contracts_to_amount(deepcopy(order1_bef))
order2 = exchange._order_contracts_to_amount(deepcopy(order2_bef))
assert order1['amount'] == order1_bef['amount'] * contract_size
assert order1['cost'] == order1_bef['cost'] * contract_size
order1 = exchange._order_contracts_to_amount(orders[0])
order2 = exchange._order_contracts_to_amount(orders[1])
assert order2['amount'] == order2_bef['amount'] * contract_size
assert order2['cost'] == order2_bef['cost'] * contract_size
# Don't fail
exchange._order_contracts_to_amount(orders[2])
assert order1['amount'] == 30.0 * contract_size
assert order2['amount'] == 40.0 * contract_size
@pytest.mark.parametrize('pair,contract_size,trading_mode', [