Extract ExchangePayload updating
This commit is contained in:
@@ -8,8 +8,8 @@ from freqtrade.constants import Config
|
|||||||
from freqtrade.enums import CandleType
|
from freqtrade.enums import CandleType
|
||||||
from freqtrade.exceptions import OperationalException
|
from freqtrade.exceptions import OperationalException
|
||||||
from freqtrade.rpc.api_server.api_schemas import (BackgroundTaskStatus, BgJobStarted,
|
from freqtrade.rpc.api_server.api_schemas import (BackgroundTaskStatus, BgJobStarted,
|
||||||
PairListsPayload, PairListsResponse,
|
ExchangeModePayloadMixin, PairListsPayload,
|
||||||
WhitelistEvaluateResponse)
|
PairListsResponse, WhitelistEvaluateResponse)
|
||||||
from freqtrade.rpc.api_server.deps import get_config, get_exchange
|
from freqtrade.rpc.api_server.deps import get_config, get_exchange
|
||||||
from freqtrade.rpc.api_server.webserver_bgwork import ApiBG
|
from freqtrade.rpc.api_server.webserver_bgwork import ApiBG
|
||||||
|
|
||||||
@@ -85,12 +85,7 @@ def pairlists_evaluate(payload: PairListsPayload, background_tasks: BackgroundTa
|
|||||||
config_loc = deepcopy(config)
|
config_loc = deepcopy(config)
|
||||||
config_loc['stake_currency'] = payload.stake_currency
|
config_loc['stake_currency'] = payload.stake_currency
|
||||||
config_loc['pairlists'] = payload.pairlists
|
config_loc['pairlists'] = payload.pairlists
|
||||||
if payload.exchange:
|
handleExchangePayload(payload, config_loc)
|
||||||
config_loc['exchange']['name'] = payload.exchange
|
|
||||||
if payload.trading_mode:
|
|
||||||
config_loc['trading_mode'] = payload.trading_mode
|
|
||||||
config_loc['candle_type_def'] = CandleType.get_default(
|
|
||||||
config_loc.get('trading_mode', 'spot') or 'spot')
|
|
||||||
# TODO: overwrite blacklist? make it optional and fall back to the one in config?
|
# TODO: overwrite blacklist? make it optional and fall back to the one in config?
|
||||||
# Outcome depends on the UI approach.
|
# Outcome depends on the UI approach.
|
||||||
config_loc['exchange']['pair_blacklist'] = payload.blacklist
|
config_loc['exchange']['pair_blacklist'] = payload.blacklist
|
||||||
@@ -114,6 +109,19 @@ def pairlists_evaluate(payload: PairListsPayload, background_tasks: BackgroundTa
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def handleExchangePayload(payload: ExchangeModePayloadMixin, config_loc: Config):
|
||||||
|
"""
|
||||||
|
Handle exchange and trading mode payload.
|
||||||
|
Updates the configuration with the payload values.
|
||||||
|
"""
|
||||||
|
if payload.exchange:
|
||||||
|
config_loc['exchange']['name'] = payload.exchange
|
||||||
|
if payload.trading_mode:
|
||||||
|
config_loc['trading_mode'] = payload.trading_mode
|
||||||
|
config_loc['candle_type_def'] = CandleType.get_default(
|
||||||
|
config_loc.get('trading_mode', 'spot') or 'spot')
|
||||||
|
|
||||||
|
|
||||||
@router.get('/pairlists/evaluate/{jobid}', response_model=WhitelistEvaluateResponse,
|
@router.get('/pairlists/evaluate/{jobid}', response_model=WhitelistEvaluateResponse,
|
||||||
tags=['pairlists'])
|
tags=['pairlists'])
|
||||||
def pairlists_evaluate_get(jobid: str):
|
def pairlists_evaluate_get(jobid: str):
|
||||||
|
|||||||
@@ -7,6 +7,11 @@ from freqtrade.constants import DATETIME_PRINT_FORMAT, IntOrInf
|
|||||||
from freqtrade.enums import OrderTypeValues, SignalDirection, TradingMode
|
from freqtrade.enums import OrderTypeValues, SignalDirection, TradingMode
|
||||||
|
|
||||||
|
|
||||||
|
class ExchangeModePayloadMixin(BaseModel):
|
||||||
|
trading_mode: Optional[TradingMode]
|
||||||
|
exchange: Optional[str]
|
||||||
|
|
||||||
|
|
||||||
class Ping(BaseModel):
|
class Ping(BaseModel):
|
||||||
status: str
|
status: str
|
||||||
|
|
||||||
@@ -428,12 +433,10 @@ class PairListsResponse(BaseModel):
|
|||||||
pairlists: List[PairListResponse]
|
pairlists: List[PairListResponse]
|
||||||
|
|
||||||
|
|
||||||
class PairListsPayload(BaseModel):
|
class PairListsPayload(ExchangeModePayloadMixin, BaseModel):
|
||||||
pairlists: List[Dict[str, Any]]
|
pairlists: List[Dict[str, Any]]
|
||||||
blacklist: List[str]
|
blacklist: List[str]
|
||||||
stake_currency: str
|
stake_currency: str
|
||||||
trading_mode: Optional[TradingMode]
|
|
||||||
exchange: Optional[str]
|
|
||||||
|
|
||||||
|
|
||||||
class FreqAIModelListResponse(BaseModel):
|
class FreqAIModelListResponse(BaseModel):
|
||||||
|
|||||||
Reference in New Issue
Block a user