mirror of
https://github.com/freqtrade/freqtrade.git
synced 2026-01-20 05:50:36 +00:00
Add margin_mode to pairlists callback
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class MarginMode(Enum):
|
||||
class MarginMode(str, Enum):
|
||||
"""
|
||||
Enum to distinguish between
|
||||
cross margin/futures margin_mode and
|
||||
|
||||
@@ -120,6 +120,8 @@ def handleExchangePayload(payload: ExchangeModePayloadMixin, config_loc: Config)
|
||||
config_loc['trading_mode'] = payload.trading_mode
|
||||
config_loc['candle_type_def'] = CandleType.get_default(
|
||||
config_loc.get('trading_mode', 'spot') or 'spot')
|
||||
if payload.margin_mode:
|
||||
config_loc['margin_mode'] = payload.margin_mode
|
||||
|
||||
|
||||
@router.get('/pairlists/evaluate/{jobid}', response_model=WhitelistEvaluateResponse,
|
||||
|
||||
@@ -4,12 +4,13 @@ from typing import Any, Dict, List, Optional, Union
|
||||
from pydantic import BaseModel
|
||||
|
||||
from freqtrade.constants import DATETIME_PRINT_FORMAT, IntOrInf
|
||||
from freqtrade.enums import OrderTypeValues, SignalDirection, TradingMode
|
||||
from freqtrade.enums import MarginMode, OrderTypeValues, SignalDirection, TradingMode
|
||||
from freqtrade.types import ValidExchangesType
|
||||
|
||||
|
||||
class ExchangeModePayloadMixin(BaseModel):
|
||||
trading_mode: Optional[TradingMode]
|
||||
margin_mode: Optional[MarginMode]
|
||||
exchange: Optional[str]
|
||||
|
||||
|
||||
|
||||
@@ -1762,6 +1762,7 @@ def test_api_pairlists_evaluate(botclient, tmpdir, mocker):
|
||||
"stake_currency": "BTC",
|
||||
"exchange": "randomExchange",
|
||||
"trading_mode": "futures",
|
||||
"margin_mode": "isolated",
|
||||
}
|
||||
rc = client_post(client, f"{BASE_URI}/pairlists/evaluate", body)
|
||||
assert_response(rc)
|
||||
@@ -1769,6 +1770,7 @@ def test_api_pairlists_evaluate(botclient, tmpdir, mocker):
|
||||
call_config = plm.call_args_list[0][0][1]
|
||||
assert call_config['exchange']['name'] == 'randomExchange'
|
||||
assert call_config['trading_mode'] == 'futures'
|
||||
assert call_config['margin_mode'] == 'isolated'
|
||||
|
||||
|
||||
def test_list_available_pairs(botclient):
|
||||
|
||||
Reference in New Issue
Block a user