diff --git a/freqtrade/constants.py b/freqtrade/constants.py index c6b8f0e62..ee104325b 100644 --- a/freqtrade/constants.py +++ b/freqtrade/constants.py @@ -39,6 +39,8 @@ DEFAULT_DATAFRAME_COLUMNS = ['date', 'open', 'high', 'low', 'close', 'volume'] # Don't modify sequence of DEFAULT_TRADES_COLUMNS # it has wide consequences for stored trades files DEFAULT_TRADES_COLUMNS = ['timestamp', 'id', 'type', 'side', 'price', 'amount', 'cost'] +TRADING_MODES = ['spot', 'margin', 'futures'] +COLLATERAL_TYPES = ['cross', 'isolated'] LAST_BT_RESULT_FN = '.last_result.json' FTHYPT_FILEVERSION = 'fthypt_fileversion' @@ -146,6 +148,8 @@ CONF_SCHEMA = { 'sell_profit_offset': {'type': 'number'}, 'ignore_roi_if_buy_signal': {'type': 'boolean'}, 'ignore_buying_expired_candle_after': {'type': 'number'}, + 'trading_mode': {'type': 'string', 'enum': TRADING_MODES}, + 'collateral_type': {'type': 'string', 'enum': COLLATERAL_TYPES}, 'bot_name': {'type': 'string'}, 'unfilledtimeout': { 'type': 'object', @@ -193,7 +197,7 @@ CONF_SCHEMA = { 'required': ['price_side'] }, 'custom_price_max_distance_ratio': { - 'type': 'number', 'minimum': 0.0 + 'type': 'number', 'minimum': 0.0 }, 'order_types': { 'type': 'object', diff --git a/tests/test_freqtradebot.py b/tests/test_freqtradebot.py index 319e25e71..6d784d9d1 100644 --- a/tests/test_freqtradebot.py +++ b/tests/test_freqtradebot.py @@ -11,7 +11,7 @@ import arrow import pytest from freqtrade.constants import CANCEL_REASON, MATH_CLOSE_PREC, UNLIMITED_STAKE_AMOUNT -from freqtrade.enums import RPCMessageType, RunMode, SellType, SignalDirection, State, TradingMode +from freqtrade.enums import RPCMessageType, RunMode, SellType, SignalDirection, State from freqtrade.exceptions import (DependencyException, ExchangeError, InsufficientFundsError, InvalidOrderException, OperationalException, PricingError, TemporaryError) @@ -3564,7 +3564,7 @@ def test_ignore_roi_if_buy_signal(default_conf_usdt, limit_order, limit_order_op @ pytest.mark.parametrize("is_short,val1,val2", [ (False, 1.5, 1.1), (True, 0.5, 0.9) - ]) +]) def test_trailing_stop_loss(default_conf_usdt, limit_order_open, is_short, val1, val2, fee, caplog, mocker) -> None: patch_RPCManager(mocker) @@ -4668,19 +4668,19 @@ def test_leverage_prep(): @pytest.mark.parametrize('trading_mode,calls,t1,t2', [ - (TradingMode.SPOT, 0, "2021-09-01 00:00:00", "2021-09-01 08:00:00"), - (TradingMode.MARGIN, 0, "2021-09-01 00:00:00", "2021-09-01 08:00:00"), - (TradingMode.FUTURES, 31, "2021-09-01 00:00:02", "2021-09-01 08:00:01"), - (TradingMode.FUTURES, 32, "2021-09-01 00:00:00", "2021-09-01 08:00:01"), - (TradingMode.FUTURES, 32, "2021-09-01 00:00:02", "2021-09-01 08:00:02"), - (TradingMode.FUTURES, 33, "2021-09-01 00:00:00", "2021-09-01 08:00:02"), - (TradingMode.FUTURES, 33, "2021-08-31 23:59:59", "2021-09-01 08:00:02"), - (TradingMode.FUTURES, 33, "2021-08-31 23:59:59", "2021-09-01 08:00:03"), - (TradingMode.FUTURES, 33, "2021-08-31 23:59:59", "2021-09-01 08:00:04"), - (TradingMode.FUTURES, 33, "2021-08-31 23:59:59", "2021-09-01 08:00:05"), - (TradingMode.FUTURES, 33, "2021-08-31 23:59:59", "2021-09-01 08:00:06"), - (TradingMode.FUTURES, 33, "2021-08-31 23:59:59", "2021-09-01 08:00:07"), - (TradingMode.FUTURES, 33, "2021-08-31 23:59:58", "2021-09-01 08:00:07"), + ('spot', 0, "2021-09-01 00:00:00", "2021-09-01 08:00:00"), + ('margin', 0, "2021-09-01 00:00:00", "2021-09-01 08:00:00"), + ('futures', 31, "2021-09-01 00:00:02", "2021-09-01 08:00:01"), + ('futures', 32, "2021-09-01 00:00:00", "2021-09-01 08:00:01"), + ('futures', 32, "2021-09-01 00:00:02", "2021-09-01 08:00:02"), + ('futures', 33, "2021-09-01 00:00:00", "2021-09-01 08:00:02"), + ('futures', 33, "2021-08-31 23:59:59", "2021-09-01 08:00:02"), + ('futures', 33, "2021-08-31 23:59:59", "2021-09-01 08:00:03"), + ('futures', 33, "2021-08-31 23:59:59", "2021-09-01 08:00:04"), + ('futures', 33, "2021-08-31 23:59:59", "2021-09-01 08:00:05"), + ('futures', 33, "2021-08-31 23:59:59", "2021-09-01 08:00:06"), + ('futures', 33, "2021-08-31 23:59:59", "2021-09-01 08:00:07"), + ('futures', 33, "2021-08-31 23:59:58", "2021-09-01 08:00:07"), ]) def test_update_funding_fees(mocker, default_conf, trading_mode, calls, time_machine, t1, t2):