added none to LiqFormula
This commit is contained in:
parent
9c8acd98c4
commit
14c345f6f6
@ -3,16 +3,17 @@ from enum import Enum
|
|||||||
# from math import ceil
|
# from math import ceil
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from freqtrade.enums import TradingMode
|
from freqtrade.enums.tradingmode import TradingMode
|
||||||
from freqtrade.exceptions import OperationalException
|
from freqtrade.exceptions import OperationalException
|
||||||
|
|
||||||
|
|
||||||
class LiqFormula(Enum):
|
class LiqFormula(Enum):
|
||||||
"""Equations to calculate liquidation price"""
|
"""Equations to calculate liquidation price"""
|
||||||
|
|
||||||
BINANCE = "BINANCE"
|
BINANCE = "Binance"
|
||||||
KRAKEN = "KRAKEN"
|
KRAKEN = "Kraken"
|
||||||
FTX = "FTX"
|
FTX = "FTX"
|
||||||
|
NONE = None
|
||||||
|
|
||||||
def __exception(self, trading_mode: TradingMode, freq_specific: Optional[bool] = True):
|
def __exception(self, trading_mode: TradingMode, freq_specific: Optional[bool] = True):
|
||||||
"""
|
"""
|
||||||
@ -72,7 +73,7 @@ class LiqFormula(Enum):
|
|||||||
|
|
||||||
trading_mode: TradingMode = k['trading_mode']
|
trading_mode: TradingMode = k['trading_mode']
|
||||||
|
|
||||||
if trading_mode == TradingMode.SPOT:
|
if trading_mode == TradingMode.SPOT or self.name == "NONE":
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if self.name == "BINANCE":
|
if self.name == "BINANCE":
|
||||||
|
@ -5,61 +5,39 @@ from freqtrade.enums import LiqFormula, TradingMode
|
|||||||
|
|
||||||
|
|
||||||
def test_liquidation_formula():
|
def test_liquidation_formula():
|
||||||
|
|
||||||
spot = TradingMode.SPOT
|
spot = TradingMode.SPOT
|
||||||
# cross_margin = TradingMode.CROSS_MARGIN
|
cross_margin = TradingMode.CROSS_MARGIN
|
||||||
# isolated_margin = TradingMode.ISOLATED_MARGIN
|
isolated_margin = TradingMode.ISOLATED_MARGIN
|
||||||
# cross_futures = TradingMode.CROSS_FUTURES
|
cross_futures = TradingMode.CROSS_FUTURES
|
||||||
# isolated_futures = TradingMode.ISOLATED_FUTURES
|
isolated_futures = TradingMode.ISOLATED_FUTURES
|
||||||
|
|
||||||
assert LiqFormula.BINANCE(
|
assert LiqFormula.NONE(trading_mode=spot) is None
|
||||||
trading_mode=spot
|
assert LiqFormula.NONE(trading_mode=cross_margin) is None
|
||||||
) is None
|
assert LiqFormula.NONE(trading_mode=isolated_margin) is None
|
||||||
# TODO-lev: Uncomment these assertions and make them real calculation tests
|
assert LiqFormula.NONE(trading_mode=cross_futures) is None
|
||||||
# assert LiqFormula.BINANCE(
|
assert LiqFormula.NONE(trading_mode=isolated_futures) is None
|
||||||
# trading_mode=cross_margin
|
|
||||||
# ) == 1.0 #Replace 1.0 with real value
|
|
||||||
# assert LiqFormula.BINANCE(
|
|
||||||
# trading_mode=isolated_margin
|
|
||||||
# ) == 1.0
|
|
||||||
# assert LiqFormula.BINANCE(
|
|
||||||
# trading_mode=cross_futures
|
|
||||||
# ) == 1.0
|
|
||||||
# assert LiqFormula.BINANCE(
|
|
||||||
# trading_mode=isolated_futures
|
|
||||||
# ) == 1.0
|
|
||||||
|
|
||||||
assert LiqFormula.KRAKEN(
|
assert LiqFormula.BINANCE(trading_mode=spot) is None
|
||||||
trading_mode=spot
|
|
||||||
) is None
|
|
||||||
# TODO-lev: Uncomment these assertions and make them real calculation tests
|
# TODO-lev: Uncomment these assertions and make them real calculation tests
|
||||||
# assert LiqFormula.KRAKEN(
|
# TODO-lev: Replace 1.0 with real value
|
||||||
# trading_mode=cross_margin
|
# assert LiqFormula.BINANCE(trading_mode=cross_margin) == 1.0
|
||||||
# ) == 1.0
|
# assert LiqFormula.BINANCE(trading_mode=isolated_margin) == 1.0
|
||||||
# LiqFormula.KRAKEN(
|
# assert LiqFormula.BINANCE(trading_mode=cross_futures) == 1.0
|
||||||
# trading_mode=isolated_margin
|
# assert LiqFormula.BINANCE(trading_mode=isolated_futures) == 1.0
|
||||||
# )
|
|
||||||
|
assert LiqFormula.KRAKEN(trading_mode=spot) is None
|
||||||
|
# TODO-lev: Uncomment these assertions and make them real calculation tests
|
||||||
|
# assert LiqFormula.KRAKEN(trading_mode=cross_margin) == 1.0
|
||||||
|
# LiqFormula.KRAKEN(trading_mode=isolated_margin)
|
||||||
# asset exception thrown #TODO-lev: Check that exception is thrown
|
# asset exception thrown #TODO-lev: Check that exception is thrown
|
||||||
# assert LiqFormula.KRAKEN(
|
# assert LiqFormula.KRAKEN(trading_mode=cross_futures) == 1.0
|
||||||
# trading_mode=cross_futures
|
# LiqFormula.KRAKEN(trading_mode=isolated_futures)
|
||||||
# ) == 1.0
|
|
||||||
# LiqFormula.KRAKEN(
|
|
||||||
# trading_mode=isolated_futures
|
|
||||||
# )
|
|
||||||
# asset exception thrown #TODO-lev: Check that exception is thrown
|
# asset exception thrown #TODO-lev: Check that exception is thrown
|
||||||
|
|
||||||
assert LiqFormula.FTX(
|
assert LiqFormula.FTX(trading_mode=spot) is None
|
||||||
trading_mode=spot
|
|
||||||
) is None
|
|
||||||
# TODO-lev: Uncomment these assertions and make them real calculation tests
|
# TODO-lev: Uncomment these assertions and make them real calculation tests
|
||||||
# assert LiqFormula.FTX(
|
# assert LiqFormula.FTX(trading_mode=cross_margin) == 1.0
|
||||||
# trading_mode=cross_margin
|
# assert LiqFormula.FTX(trading_mode=isolated_margin) == 1.0
|
||||||
# ) == 1.0
|
# assert LiqFormula.FTX(trading_mode=cross_futures) == 1.0
|
||||||
# assert LiqFormula.FTX(
|
# assert LiqFormula.FTX(trading_mode=isolated_futures) == 1.0
|
||||||
# trading_mode=isolated_margin
|
|
||||||
# ) == 1.0
|
|
||||||
# assert LiqFormula.FTX(
|
|
||||||
# trading_mode=cross_futures
|
|
||||||
# ) == 1.0
|
|
||||||
# assert LiqFormula.FTX(
|
|
||||||
# trading_mode=isolated_futures
|
|
||||||
# ) == 1.0
|
|
||||||
|
Loading…
Reference in New Issue
Block a user