mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-13 03:33:55 +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 csv
|
||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
from typing import Any, Dict, List
|
from typing import Any, Dict, List, Union
|
||||||
|
|
||||||
import rapidjson
|
import rapidjson
|
||||||
from colorama import Fore, Style
|
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.exchange import list_available_exchanges, market_is_active
|
||||||
from freqtrade.misc import parse_db_uri_for_logging, plural
|
from freqtrade.misc import parse_db_uri_for_logging, plural
|
||||||
from freqtrade.resolvers import ExchangeResolver, StrategyResolver
|
from freqtrade.resolvers import ExchangeResolver, StrategyResolver
|
||||||
|
from freqtrade.types import ValidExchangesType
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
@ -38,13 +39,16 @@ def start_list_exchanges(args: Dict[str, Any]) -> None:
|
||||||
'comment': 'Reason',
|
'comment': 'Reason',
|
||||||
}
|
}
|
||||||
|
|
||||||
def build_entry(exchange, valid):
|
def build_entry(exchange: ValidExchangesType, valid: bool):
|
||||||
valid_entry = {'valid': exchange['valid']} if valid else {}
|
valid_entry = {'valid': exchange['valid']} if valid else {}
|
||||||
result = {
|
result: Dict[str, Union[str, bool]] = {
|
||||||
'name': exchange['name'],
|
'name': exchange['name'],
|
||||||
**valid_entry,
|
**valid_entry,
|
||||||
'supported': 'Official' if exchange['supported'] else '',
|
'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'],
|
'comment': exchange['comment'],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,11 +65,11 @@ def _build_exchange_list_entry(
|
||||||
'valid': valid,
|
'valid': valid,
|
||||||
'supported': exchange_name.lower() in SUPPORTED_EXCHANGES,
|
'supported': exchange_name.lower() in SUPPORTED_EXCHANGES,
|
||||||
'comment': comment,
|
'comment': comment,
|
||||||
'trade_modes': ['spot'],
|
'trade_modes': [{'trading_mode': 'spot', 'margin_mode': ''}],
|
||||||
}
|
}
|
||||||
if resolved := exchangeClasses.get(exchange_name.lower()):
|
if resolved := exchangeClasses.get(exchange_name.lower()):
|
||||||
supported_modes = ['spot'] + [
|
supported_modes = [{'trading_mode': 'spot', 'margin_mode': ''}] + [
|
||||||
f"{mm.value} {tm.value}"
|
{'trading_mode': tm.value, 'margin_mode': mm.value}
|
||||||
for tm, mm in resolved['class']._supported_trading_mode_margin_pairs
|
for tm, mm in resolved['class']._supported_trading_mode_margin_pairs
|
||||||
]
|
]
|
||||||
result.update({
|
result.update({
|
||||||
|
|
|
@ -26,6 +26,5 @@ class OrderBook(TypedDict):
|
||||||
|
|
||||||
Tickers = Dict[str, Ticker]
|
Tickers = Dict[str, Ticker]
|
||||||
|
|
||||||
|
|
||||||
# pair, timeframe, candleType, OHLCV, drop last?,
|
# pair, timeframe, candleType, OHLCV, drop last?,
|
||||||
OHLCVResponse = Tuple[str, str, CandleType, List, bool]
|
OHLCVResponse = Tuple[str, str, CandleType, List, bool]
|
||||||
|
|
|
@ -2,9 +2,14 @@
|
||||||
from typing import List, TypedDict
|
from typing import List, TypedDict
|
||||||
|
|
||||||
|
|
||||||
|
class TradeModeType(TypedDict):
|
||||||
|
trading_mode: str
|
||||||
|
margin_mode: str
|
||||||
|
|
||||||
|
|
||||||
class ValidExchangesType(TypedDict):
|
class ValidExchangesType(TypedDict):
|
||||||
name: str
|
name: str
|
||||||
valid: bool
|
valid: bool
|
||||||
supported: bool
|
supported: bool
|
||||||
comment: str
|
comment: str
|
||||||
trade_modes: List[str]
|
trade_modes: List[TradeModeType]
|
||||||
|
|
|
@ -1593,8 +1593,14 @@ def test_api_exchanges(botclient):
|
||||||
"supported": True,
|
"supported": True,
|
||||||
"comment": "",
|
"comment": "",
|
||||||
"trade_modes": [
|
"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,
|
"supported": False,
|
||||||
"comment": "",
|
"comment": "",
|
||||||
"trade_modes": [
|
"trade_modes": [
|
||||||
"spot",
|
{
|
||||||
]
|
"trading_mode": "spot",
|
||||||
|
"margin_mode": ""
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user