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 typing import Optional
|
||||
|
||||
from freqtrade.enums import TradingMode
|
||||
from freqtrade.enums.tradingmode import TradingMode
|
||||
from freqtrade.exceptions import OperationalException
|
||||
|
||||
|
||||
class LiqFormula(Enum):
|
||||
"""Equations to calculate liquidation price"""
|
||||
|
||||
BINANCE = "BINANCE"
|
||||
KRAKEN = "KRAKEN"
|
||||
BINANCE = "Binance"
|
||||
KRAKEN = "Kraken"
|
||||
FTX = "FTX"
|
||||
NONE = None
|
||||
|
||||
def __exception(self, trading_mode: TradingMode, freq_specific: Optional[bool] = True):
|
||||
"""
|
||||
@ -72,7 +73,7 @@ class LiqFormula(Enum):
|
||||
|
||||
trading_mode: TradingMode = k['trading_mode']
|
||||
|
||||
if trading_mode == TradingMode.SPOT:
|
||||
if trading_mode == TradingMode.SPOT or self.name == "NONE":
|
||||
return None
|
||||
|
||||
if self.name == "BINANCE":
|
||||
|
@ -5,61 +5,39 @@ from freqtrade.enums import LiqFormula, TradingMode
|
||||
|
||||
|
||||
def test_liquidation_formula():
|
||||
|
||||
spot = TradingMode.SPOT
|
||||
# cross_margin = TradingMode.CROSS_MARGIN
|
||||
# isolated_margin = TradingMode.ISOLATED_MARGIN
|
||||
# cross_futures = TradingMode.CROSS_FUTURES
|
||||
# isolated_futures = TradingMode.ISOLATED_FUTURES
|
||||
cross_margin = TradingMode.CROSS_MARGIN
|
||||
isolated_margin = TradingMode.ISOLATED_MARGIN
|
||||
cross_futures = TradingMode.CROSS_FUTURES
|
||||
isolated_futures = TradingMode.ISOLATED_FUTURES
|
||||
|
||||
assert LiqFormula.BINANCE(
|
||||
trading_mode=spot
|
||||
) is None
|
||||
# TODO-lev: Uncomment these assertions and make them real calculation tests
|
||||
# assert LiqFormula.BINANCE(
|
||||
# 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.NONE(trading_mode=spot) is None
|
||||
assert LiqFormula.NONE(trading_mode=cross_margin) is None
|
||||
assert LiqFormula.NONE(trading_mode=isolated_margin) is None
|
||||
assert LiqFormula.NONE(trading_mode=cross_futures) is None
|
||||
assert LiqFormula.NONE(trading_mode=isolated_futures) is None
|
||||
|
||||
assert LiqFormula.KRAKEN(
|
||||
trading_mode=spot
|
||||
) is None
|
||||
assert LiqFormula.BINANCE(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
|
||||
# )
|
||||
# TODO-lev: Replace 1.0 with real value
|
||||
# assert LiqFormula.BINANCE(trading_mode=cross_margin) == 1.0
|
||||
# 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(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
|
||||
# assert LiqFormula.KRAKEN(
|
||||
# trading_mode=cross_futures
|
||||
# ) == 1.0
|
||||
# LiqFormula.KRAKEN(
|
||||
# trading_mode=isolated_futures
|
||||
# )
|
||||
# assert LiqFormula.KRAKEN(trading_mode=cross_futures) == 1.0
|
||||
# LiqFormula.KRAKEN(trading_mode=isolated_futures)
|
||||
# asset exception thrown #TODO-lev: Check that exception is thrown
|
||||
|
||||
assert LiqFormula.FTX(
|
||||
trading_mode=spot
|
||||
) is None
|
||||
assert LiqFormula.FTX(trading_mode=spot) is None
|
||||
# TODO-lev: Uncomment these assertions and make them real calculation tests
|
||||
# assert LiqFormula.FTX(
|
||||
# trading_mode=cross_margin
|
||||
# ) == 1.0
|
||||
# assert LiqFormula.FTX(
|
||||
# trading_mode=isolated_margin
|
||||
# ) == 1.0
|
||||
# assert LiqFormula.FTX(
|
||||
# trading_mode=cross_futures
|
||||
# ) == 1.0
|
||||
# assert LiqFormula.FTX(
|
||||
# trading_mode=isolated_futures
|
||||
# ) == 1.0
|
||||
# assert LiqFormula.FTX(trading_mode=cross_margin) == 1.0
|
||||
# assert LiqFormula.FTX(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