From 241bfc409f20f43daed69b83222a163453cc383a Mon Sep 17 00:00:00 2001 From: Sam Germain Date: Thu, 5 Aug 2021 23:23:02 -0600 Subject: [PATCH 1/6] Added leverage enums --- freqtrade/enums/__init__.py | 3 +++ freqtrade/enums/collateral.py | 11 +++++++++++ freqtrade/enums/exchangename.py | 10 ++++++++++ freqtrade/enums/signaltype.py | 2 ++ freqtrade/enums/tradingmode.py | 11 +++++++++++ 5 files changed, 37 insertions(+) create mode 100644 freqtrade/enums/collateral.py create mode 100644 freqtrade/enums/exchangename.py create mode 100644 freqtrade/enums/tradingmode.py diff --git a/freqtrade/enums/__init__.py b/freqtrade/enums/__init__.py index 6099f7003..c60baad2a 100644 --- a/freqtrade/enums/__init__.py +++ b/freqtrade/enums/__init__.py @@ -1,8 +1,11 @@ # flake8: noqa: F401 from freqtrade.enums.backteststate import BacktestState +from freqtrade.enums.collateral import Collateral +from freqtrade.enums.exchangename import ExchangeName from freqtrade.enums.interestmode import InterestMode from freqtrade.enums.rpcmessagetype import RPCMessageType from freqtrade.enums.runmode import NON_UTIL_MODES, OPTIMIZE_MODES, TRADING_MODES, RunMode from freqtrade.enums.selltype import SellType from freqtrade.enums.signaltype import SignalTagType, SignalType from freqtrade.enums.state import State +from freqtrade.enums.tradingmode import TradingMode diff --git a/freqtrade/enums/collateral.py b/freqtrade/enums/collateral.py new file mode 100644 index 000000000..0a5988698 --- /dev/null +++ b/freqtrade/enums/collateral.py @@ -0,0 +1,11 @@ +from enum import Enum + + +class Collateral(Enum): + """ + Enum to distinguish between + cross margin/futures collateral and + isolated margin/futures collateral + """ + CROSS = "cross" + ISOLATED = "isolated" diff --git a/freqtrade/enums/exchangename.py b/freqtrade/enums/exchangename.py new file mode 100644 index 000000000..288754305 --- /dev/null +++ b/freqtrade/enums/exchangename.py @@ -0,0 +1,10 @@ +from enum import Enum + + +class ExchangeName(Enum): + """All the exchanges supported by freqtrade that support leverage""" + + BINANCE = "Binance" + KRAKEN = "Kraken" + FTX = "FTX" + OTHER = None diff --git a/freqtrade/enums/signaltype.py b/freqtrade/enums/signaltype.py index d2995d57a..09426b0e8 100644 --- a/freqtrade/enums/signaltype.py +++ b/freqtrade/enums/signaltype.py @@ -7,6 +7,8 @@ class SignalType(Enum): """ BUY = "buy" SELL = "sell" + SHORT = "short" + EXIT_SHORT = "exit_short" class SignalTagType(Enum): diff --git a/freqtrade/enums/tradingmode.py b/freqtrade/enums/tradingmode.py new file mode 100644 index 000000000..a8de60c19 --- /dev/null +++ b/freqtrade/enums/tradingmode.py @@ -0,0 +1,11 @@ +from enum import Enum + + +class TradingMode(Enum): + """ + Enum to distinguish between + spot, margin, futures or any other trading method + """ + SPOT = "spot" + MARGIN = "margin" + FUTURES = "futures" From 50d185ccd83071dbb4f0511943386cc1e35dc2ce Mon Sep 17 00:00:00 2001 From: Sam Germain Date: Fri, 6 Aug 2021 01:23:55 -0600 Subject: [PATCH 2/6] Added exchange_name variables to exchange classes --- freqtrade/exchange/binance.py | 3 +++ freqtrade/exchange/exchange.py | 3 +++ freqtrade/exchange/ftx.py | 3 +++ freqtrade/exchange/kraken.py | 3 +++ 4 files changed, 12 insertions(+) diff --git a/freqtrade/exchange/binance.py b/freqtrade/exchange/binance.py index 0c470cb24..3ca1c52fe 100644 --- a/freqtrade/exchange/binance.py +++ b/freqtrade/exchange/binance.py @@ -4,6 +4,7 @@ from typing import Dict import ccxt +from freqtrade.enums import ExchangeName from freqtrade.exceptions import (DDosProtection, InsufficientFundsError, InvalidOrderException, OperationalException, TemporaryError) from freqtrade.exchange import Exchange @@ -15,6 +16,8 @@ logger = logging.getLogger(__name__) class Binance(Exchange): + exchange_name: ExchangeName = ExchangeName.BINANCE + _ft_has: Dict = { "stoploss_on_exchange": True, "order_time_in_force": ['gtc', 'fok', 'ioc'], diff --git a/freqtrade/exchange/exchange.py b/freqtrade/exchange/exchange.py index c6f60e08a..9f35fa6c0 100644 --- a/freqtrade/exchange/exchange.py +++ b/freqtrade/exchange/exchange.py @@ -21,6 +21,7 @@ from pandas import DataFrame from freqtrade.constants import DEFAULT_AMOUNT_RESERVE_PERCENT, ListPairsWithTimeframes from freqtrade.data.converter import ohlcv_to_dataframe, trades_dict_to_list +from freqtrade.enums import ExchangeName from freqtrade.exceptions import (DDosProtection, ExchangeError, InsufficientFundsError, InvalidOrderException, OperationalException, PricingError, RetryableOrderError, TemporaryError) @@ -69,6 +70,8 @@ class Exchange: } _ft_has: Dict = {} + exchange_name: ExchangeName = ExchangeName.BINANCE + def __init__(self, config: Dict[str, Any], validate: bool = True) -> None: """ Initializes this module with the given config, diff --git a/freqtrade/exchange/ftx.py b/freqtrade/exchange/ftx.py index 6cd549d60..6c73b25ba 100644 --- a/freqtrade/exchange/ftx.py +++ b/freqtrade/exchange/ftx.py @@ -4,6 +4,7 @@ from typing import Any, Dict import ccxt +from freqtrade.enums import ExchangeName from freqtrade.exceptions import (DDosProtection, InsufficientFundsError, InvalidOrderException, OperationalException, TemporaryError) from freqtrade.exchange import Exchange @@ -16,6 +17,8 @@ logger = logging.getLogger(__name__) class Ftx(Exchange): + exchange_name: ExchangeName = ExchangeName.FTX + _ft_has: Dict = { "stoploss_on_exchange": True, "ohlcv_candle_limit": 1500, diff --git a/freqtrade/exchange/kraken.py b/freqtrade/exchange/kraken.py index 1b069aa6c..dc1613a92 100644 --- a/freqtrade/exchange/kraken.py +++ b/freqtrade/exchange/kraken.py @@ -4,6 +4,7 @@ from typing import Any, Dict import ccxt +from freqtrade.enums import ExchangeName from freqtrade.exceptions import (DDosProtection, InsufficientFundsError, InvalidOrderException, OperationalException, TemporaryError) from freqtrade.exchange import Exchange @@ -15,6 +16,8 @@ logger = logging.getLogger(__name__) class Kraken(Exchange): + exchange_name: ExchangeName = ExchangeName.KRAKEN + _params: Dict = {"trading_agreement": "agree"} _ft_has: Dict = { "stoploss_on_exchange": True, From aec82b4647415b80a2cd723f3da2b4d1af58800c Mon Sep 17 00:00:00 2001 From: Sam Germain Date: Fri, 6 Aug 2021 01:37:34 -0600 Subject: [PATCH 3/6] Added empty everage/__init__.py --- freqtrade/leverage/__init__.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 freqtrade/leverage/__init__.py diff --git a/freqtrade/leverage/__init__.py b/freqtrade/leverage/__init__.py new file mode 100644 index 000000000..9186b160e --- /dev/null +++ b/freqtrade/leverage/__init__.py @@ -0,0 +1 @@ +# flake8: noqa: F401 From 71963e65f1ef57453ff9b43d57ac9ff268130fcf Mon Sep 17 00:00:00 2001 From: Sam Germain Date: Sat, 7 Aug 2021 18:42:09 -0600 Subject: [PATCH 4/6] Removed ExchangeName Enum --- freqtrade/enums/__init__.py | 1 - freqtrade/enums/exchangename.py | 10 ---------- freqtrade/exchange/binance.py | 3 --- freqtrade/exchange/exchange.py | 3 --- freqtrade/exchange/ftx.py | 3 --- freqtrade/exchange/kraken.py | 3 --- 6 files changed, 23 deletions(-) delete mode 100644 freqtrade/enums/exchangename.py diff --git a/freqtrade/enums/__init__.py b/freqtrade/enums/__init__.py index c60baad2a..ef73dd82a 100644 --- a/freqtrade/enums/__init__.py +++ b/freqtrade/enums/__init__.py @@ -1,7 +1,6 @@ # flake8: noqa: F401 from freqtrade.enums.backteststate import BacktestState from freqtrade.enums.collateral import Collateral -from freqtrade.enums.exchangename import ExchangeName from freqtrade.enums.interestmode import InterestMode from freqtrade.enums.rpcmessagetype import RPCMessageType from freqtrade.enums.runmode import NON_UTIL_MODES, OPTIMIZE_MODES, TRADING_MODES, RunMode diff --git a/freqtrade/enums/exchangename.py b/freqtrade/enums/exchangename.py deleted file mode 100644 index 288754305..000000000 --- a/freqtrade/enums/exchangename.py +++ /dev/null @@ -1,10 +0,0 @@ -from enum import Enum - - -class ExchangeName(Enum): - """All the exchanges supported by freqtrade that support leverage""" - - BINANCE = "Binance" - KRAKEN = "Kraken" - FTX = "FTX" - OTHER = None diff --git a/freqtrade/exchange/binance.py b/freqtrade/exchange/binance.py index 3ca1c52fe..0c470cb24 100644 --- a/freqtrade/exchange/binance.py +++ b/freqtrade/exchange/binance.py @@ -4,7 +4,6 @@ from typing import Dict import ccxt -from freqtrade.enums import ExchangeName from freqtrade.exceptions import (DDosProtection, InsufficientFundsError, InvalidOrderException, OperationalException, TemporaryError) from freqtrade.exchange import Exchange @@ -16,8 +15,6 @@ logger = logging.getLogger(__name__) class Binance(Exchange): - exchange_name: ExchangeName = ExchangeName.BINANCE - _ft_has: Dict = { "stoploss_on_exchange": True, "order_time_in_force": ['gtc', 'fok', 'ioc'], diff --git a/freqtrade/exchange/exchange.py b/freqtrade/exchange/exchange.py index 9f35fa6c0..c6f60e08a 100644 --- a/freqtrade/exchange/exchange.py +++ b/freqtrade/exchange/exchange.py @@ -21,7 +21,6 @@ from pandas import DataFrame from freqtrade.constants import DEFAULT_AMOUNT_RESERVE_PERCENT, ListPairsWithTimeframes from freqtrade.data.converter import ohlcv_to_dataframe, trades_dict_to_list -from freqtrade.enums import ExchangeName from freqtrade.exceptions import (DDosProtection, ExchangeError, InsufficientFundsError, InvalidOrderException, OperationalException, PricingError, RetryableOrderError, TemporaryError) @@ -70,8 +69,6 @@ class Exchange: } _ft_has: Dict = {} - exchange_name: ExchangeName = ExchangeName.BINANCE - def __init__(self, config: Dict[str, Any], validate: bool = True) -> None: """ Initializes this module with the given config, diff --git a/freqtrade/exchange/ftx.py b/freqtrade/exchange/ftx.py index 6c73b25ba..6cd549d60 100644 --- a/freqtrade/exchange/ftx.py +++ b/freqtrade/exchange/ftx.py @@ -4,7 +4,6 @@ from typing import Any, Dict import ccxt -from freqtrade.enums import ExchangeName from freqtrade.exceptions import (DDosProtection, InsufficientFundsError, InvalidOrderException, OperationalException, TemporaryError) from freqtrade.exchange import Exchange @@ -17,8 +16,6 @@ logger = logging.getLogger(__name__) class Ftx(Exchange): - exchange_name: ExchangeName = ExchangeName.FTX - _ft_has: Dict = { "stoploss_on_exchange": True, "ohlcv_candle_limit": 1500, diff --git a/freqtrade/exchange/kraken.py b/freqtrade/exchange/kraken.py index dc1613a92..1b069aa6c 100644 --- a/freqtrade/exchange/kraken.py +++ b/freqtrade/exchange/kraken.py @@ -4,7 +4,6 @@ from typing import Any, Dict import ccxt -from freqtrade.enums import ExchangeName from freqtrade.exceptions import (DDosProtection, InsufficientFundsError, InvalidOrderException, OperationalException, TemporaryError) from freqtrade.exchange import Exchange @@ -16,8 +15,6 @@ logger = logging.getLogger(__name__) class Kraken(Exchange): - exchange_name: ExchangeName = ExchangeName.KRAKEN - _params: Dict = {"trading_agreement": "agree"} _ft_has: Dict = { "stoploss_on_exchange": True, From 658f138e30b06d89cb78b14d44a702c890756949 Mon Sep 17 00:00:00 2001 From: Sam Germain Date: Sat, 7 Aug 2021 20:08:52 -0600 Subject: [PATCH 5/6] Added short_tag to SignalTagType --- freqtrade/enums/signaltype.py | 1 + 1 file changed, 1 insertion(+) diff --git a/freqtrade/enums/signaltype.py b/freqtrade/enums/signaltype.py index 09426b0e8..fcebd9f0e 100644 --- a/freqtrade/enums/signaltype.py +++ b/freqtrade/enums/signaltype.py @@ -16,3 +16,4 @@ class SignalTagType(Enum): Enum for signal columns """ BUY_TAG = "buy_tag" + SHORT_TAG = "short_tag" From 4630f698301cf90e5596a8c9c1d6c5196ba74973 Mon Sep 17 00:00:00 2001 From: Sam Germain Date: Sun, 8 Aug 2021 01:36:59 -0600 Subject: [PATCH 6/6] Removed short, exit_short from enums --- freqtrade/enums/signaltype.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/freqtrade/enums/signaltype.py b/freqtrade/enums/signaltype.py index fcebd9f0e..d2995d57a 100644 --- a/freqtrade/enums/signaltype.py +++ b/freqtrade/enums/signaltype.py @@ -7,8 +7,6 @@ class SignalType(Enum): """ BUY = "buy" SELL = "sell" - SHORT = "short" - EXIT_SHORT = "exit_short" class SignalTagType(Enum): @@ -16,4 +14,3 @@ class SignalTagType(Enum): Enum for signal columns """ BUY_TAG = "buy_tag" - SHORT_TAG = "short_tag"