Merge remote-tracking branch 'upstream/feat/short' into todo-rpc

This commit is contained in:
aezo.teo 2021-11-14 21:21:59 +08:00
commit a08572e907
8 changed files with 31 additions and 67 deletions

View File

@ -23,6 +23,8 @@ class Bibox(Exchange):
@property
def _ccxt_config(self) -> Dict:
# Parameters to add directly to ccxt sync/async initialization.
return {"has": {"fetchCurrencies": False}}
config = {"has": {"fetchCurrencies": False}}
config.update(super()._ccxt_config)
return config
funding_fee_times: List[int] = [0, 8, 16] # hours of the day

View File

@ -27,6 +27,7 @@ class Binance(Exchange):
"trades_pagination": "id",
"trades_pagination_arg": "fromId",
"l2_limit_range": [5, 10, 20, 50, 100, 500, 1000],
"ccxt_futures_name": "future"
}
funding_fee_times: List[int] = [0, 8, 16] # hours of the day
# but the schedule won't check within this timeframe
@ -39,24 +40,6 @@ class Binance(Exchange):
# (TradingMode.FUTURES, Collateral.ISOLATED)
]
@property
def _ccxt_config(self) -> Dict:
# Parameters to add directly to ccxt sync/async initialization.
if self.trading_mode == TradingMode.MARGIN:
return {
"options": {
"defaultType": "margin"
}
}
elif self.trading_mode == TradingMode.FUTURES:
return {
"options": {
"defaultType": "future"
}
}
else:
return {}
def stoploss_adjust(self, stop_loss: float, order: Dict, side: str) -> bool:
"""
Verify stop_loss against stoploss-order value (limit or price)

View File

@ -21,6 +21,7 @@ class Bybit(Exchange):
_ft_has: Dict = {
"ohlcv_candle_limit": 200,
"ccxt_futures_name": "linear"
}
funding_fee_times: List[int] = [0, 8, 16] # hours of the day

View File

@ -69,6 +69,7 @@ class Exchange:
"trades_pagination_arg": "since",
"l2_limit_range": None,
"l2_limit_range_required": True, # Allow Empty L2 limit (kucoin)
"ccxt_futures_name": "swap"
}
_ft_has: Dict = {}
@ -234,7 +235,20 @@ class Exchange:
@property
def _ccxt_config(self) -> Dict:
# Parameters to add directly to ccxt sync/async initialization.
return {}
if self.trading_mode == TradingMode.MARGIN:
return {
"options": {
"defaultType": "margin"
}
}
elif self.trading_mode == TradingMode.FUTURES:
return {
"options": {
"defaultType": self._ft_has["ccxt_futures_name"]
}
}
else:
return {}
@property
def name(self) -> str:

View File

@ -36,24 +36,6 @@ class Gateio(Exchange):
# (TradingMode.FUTURES, Collateral.ISOLATED)
]
@property
def _ccxt_config(self) -> Dict:
# Parameters to add directly to ccxt sync/async initialization.
if self.trading_mode == TradingMode.MARGIN:
return {
"options": {
"defaultType": "margin"
}
}
elif self.trading_mode == TradingMode.FUTURES:
return {
"options": {
"defaultType": "swap"
}
}
else:
return {}
def validate_ordertypes(self, order_types: Dict) -> None:
super().validate_ordertypes(order_types)

View File

@ -26,21 +26,3 @@ class Okex(Exchange):
# (TradingMode.FUTURES, Collateral.CROSS),
# (TradingMode.FUTURES, Collateral.ISOLATED)
]
@property
def _ccxt_config(self) -> Dict:
# Parameters to add directly to ccxt sync/async initialization.
if self.trading_mode == TradingMode.MARGIN:
return {
"options": {
"defaultType": "margin"
}
}
elif self.trading_mode == TradingMode.FUTURES:
return {
"options": {
"defaultType": "swap"
}
}
else:
return {}

View File

@ -3253,16 +3253,16 @@ def test_validate_trading_mode_and_collateral(
("binance", "spot", {}),
("binance", "margin", {"options": {"defaultType": "margin"}}),
("binance", "futures", {"options": {"defaultType": "future"}}),
("kraken", "spot", {}),
("kraken", "margin", {}),
("kraken", "futures", {}),
("ftx", "spot", {}),
("ftx", "margin", {}),
("ftx", "futures", {}),
("bittrex", "spot", {}),
("gateio", "spot", {}),
("gateio", "margin", {"options": {"defaultType": "margin"}}),
("bibox", "spot", {"has": {"fetchCurrencies": False}}),
("bibox", "margin", {"has": {"fetchCurrencies": False}, "options": {"defaultType": "margin"}}),
("bibox", "futures", {"has": {"fetchCurrencies": False}, "options": {"defaultType": "swap"}}),
("bybit", "futures", {"options": {"defaultType": "linear"}}),
("ftx", "futures", {"options": {"defaultType": "swap"}}),
("gateio", "futures", {"options": {"defaultType": "swap"}}),
("hitbtc", "futures", {"options": {"defaultType": "swap"}}),
("kraken", "futures", {"options": {"defaultType": "swap"}}),
("kucoin", "futures", {"options": {"defaultType": "swap"}}),
("okex", "futures", {"options": {"defaultType": "swap"}}),
])
def test__ccxt_config(
default_conf,

View File

@ -8,7 +8,7 @@ from freqtrade.persistence.models import Trade
from .strats.strategy_test_v3 import StrategyTestV3
def test_strategy_test_v2_structure():
def test_strategy_test_v3_structure():
assert hasattr(StrategyTestV3, 'minimal_roi')
assert hasattr(StrategyTestV3, 'stoploss')
assert hasattr(StrategyTestV3, 'timeframe')
@ -21,7 +21,7 @@ def test_strategy_test_v2_structure():
(True, 'short'),
(False, 'long'),
])
def test_strategy_test_v2(result, fee, is_short, side):
def test_strategy_test_v3(result, fee, is_short, side):
strategy = StrategyTestV3({})
metadata = {'pair': 'ETH/BTC'}