From 24cf0446468be71f2979b27affa66bd1f036745b Mon Sep 17 00:00:00 2001 From: Matthias Date: Fri, 27 May 2022 08:18:04 +0000 Subject: [PATCH] Fix bybit spot mode --- freqtrade/exchange/bybit.py | 14 ++++++++++++++ tests/exchange/test_exchange.py | 1 + 2 files changed, 15 insertions(+) diff --git a/freqtrade/exchange/bybit.py b/freqtrade/exchange/bybit.py index 484b8b9d3..1c4bb858b 100644 --- a/freqtrade/exchange/bybit.py +++ b/freqtrade/exchange/bybit.py @@ -29,3 +29,17 @@ class Bybit(Exchange): # (TradingMode.FUTURES, MarginMode.CROSS), # (TradingMode.FUTURES, MarginMode.ISOLATED) ] + + @property + def _ccxt_config(self) -> Dict: + # Parameters to add directly to ccxt sync/async initialization. + # ccxt defaults to swap mode. + config = {} + if self.trading_mode == TradingMode.SPOT: + config.update({ + "options": { + "defaultType": "spot" + } + }) + config.update(super()._ccxt_config) + return config diff --git a/tests/exchange/test_exchange.py b/tests/exchange/test_exchange.py index 9da2dbc11..708a0e889 100644 --- a/tests/exchange/test_exchange.py +++ b/tests/exchange/test_exchange.py @@ -3819,6 +3819,7 @@ def test_validate_trading_mode_and_margin_mode( ("bibox", "spot", {"has": {"fetchCurrencies": False}}), ("bibox", "margin", {"has": {"fetchCurrencies": False}, "options": {"defaultType": "margin"}}), ("bibox", "futures", {"has": {"fetchCurrencies": False}, "options": {"defaultType": "swap"}}), + ("bybit", "spot", {"options": {"defaultType": "spot"}}), ("bybit", "futures", {"options": {"defaultType": "linear"}}), ("ftx", "futures", {"options": {"defaultType": "swap"}}), ("gateio", "futures", {"options": {"defaultType": "swap"}}),