mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
Split trademode response value into trade_mode and margin-mode
This commit is contained in:
parent
72f4e1475c
commit
ac7419e975
|
@ -1,7 +1,7 @@
|
|||
import csv
|
||||
import logging
|
||||
import sys
|
||||
from typing import Any, Dict, List
|
||||
from typing import Any, Dict, List, Union
|
||||
|
||||
import rapidjson
|
||||
from colorama import Fore, Style
|
||||
|
@ -14,6 +14,7 @@ from freqtrade.exceptions import OperationalException
|
|||
from freqtrade.exchange import list_available_exchanges, market_is_active
|
||||
from freqtrade.misc import parse_db_uri_for_logging, plural
|
||||
from freqtrade.resolvers import ExchangeResolver, StrategyResolver
|
||||
from freqtrade.types import ValidExchangesType
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -38,13 +39,16 @@ def start_list_exchanges(args: Dict[str, Any]) -> None:
|
|||
'comment': 'Reason',
|
||||
}
|
||||
|
||||
def build_entry(exchange, valid):
|
||||
def build_entry(exchange: ValidExchangesType, valid: bool):
|
||||
valid_entry = {'valid': exchange['valid']} if valid else {}
|
||||
result = {
|
||||
result: Dict[str, Union[str, bool]] = {
|
||||
'name': exchange['name'],
|
||||
**valid_entry,
|
||||
'supported': 'Official' if exchange['supported'] else '',
|
||||
'trade_modes': ', '.join(exchange['trade_modes']),
|
||||
'trade_modes': ', '.join(
|
||||
(f"{a['margin_mode']} " if a['margin_mode'] else '') + a['trading_mode']
|
||||
for a in exchange['trade_modes']
|
||||
),
|
||||
'comment': exchange['comment'],
|
||||
}
|
||||
|
||||
|
|
|
@ -65,11 +65,11 @@ def _build_exchange_list_entry(
|
|||
'valid': valid,
|
||||
'supported': exchange_name.lower() in SUPPORTED_EXCHANGES,
|
||||
'comment': comment,
|
||||
'trade_modes': ['spot'],
|
||||
'trade_modes': [{'trading_mode': 'spot', 'margin_mode': ''}],
|
||||
}
|
||||
if resolved := exchangeClasses.get(exchange_name.lower()):
|
||||
supported_modes = ['spot'] + [
|
||||
f"{mm.value} {tm.value}"
|
||||
supported_modes = [{'trading_mode': 'spot', 'margin_mode': ''}] + [
|
||||
{'trading_mode': tm.value, 'margin_mode': mm.value}
|
||||
for tm, mm in resolved['class']._supported_trading_mode_margin_pairs
|
||||
]
|
||||
result.update({
|
||||
|
|
|
@ -26,6 +26,5 @@ class OrderBook(TypedDict):
|
|||
|
||||
Tickers = Dict[str, Ticker]
|
||||
|
||||
|
||||
# pair, timeframe, candleType, OHLCV, drop last?,
|
||||
OHLCVResponse = Tuple[str, str, CandleType, List, bool]
|
||||
|
|
|
@ -2,9 +2,14 @@
|
|||
from typing import List, TypedDict
|
||||
|
||||
|
||||
class TradeModeType(TypedDict):
|
||||
trading_mode: str
|
||||
margin_mode: str
|
||||
|
||||
|
||||
class ValidExchangesType(TypedDict):
|
||||
name: str
|
||||
valid: bool
|
||||
supported: bool
|
||||
comment: str
|
||||
trade_modes: List[str]
|
||||
trade_modes: List[TradeModeType]
|
||||
|
|
|
@ -1593,8 +1593,14 @@ def test_api_exchanges(botclient):
|
|||
"supported": True,
|
||||
"comment": "",
|
||||
"trade_modes": [
|
||||
"spot",
|
||||
"isolated futures",
|
||||
{
|
||||
"trading_mode": "spot",
|
||||
"margin_mode": ""
|
||||
},
|
||||
{
|
||||
"trading_mode": "futures",
|
||||
"margin_mode": "isolated"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -1605,8 +1611,11 @@ def test_api_exchanges(botclient):
|
|||
"supported": False,
|
||||
"comment": "",
|
||||
"trade_modes": [
|
||||
"spot",
|
||||
]
|
||||
{
|
||||
"trading_mode": "spot",
|
||||
"margin_mode": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user