Add NoDBContext to pairlist evaluation functions

This commit is contained in:
Matthias
2024-01-10 20:08:23 +01:00
parent 3caf964c46
commit 883f508544
2 changed files with 18 additions and 15 deletions

View File

@@ -15,6 +15,7 @@ def start_test_pairlist(args: Dict[str, Any]) -> None:
""" """
Test Pairlist configuration Test Pairlist configuration
""" """
from freqtrade.persistence import FtNoDBContext
from freqtrade.plugins.pairlistmanager import PairListManager from freqtrade.plugins.pairlistmanager import PairListManager
config = setup_utils_configuration(args, RunMode.UTIL_EXCHANGE) config = setup_utils_configuration(args, RunMode.UTIL_EXCHANGE)
@@ -24,6 +25,7 @@ def start_test_pairlist(args: Dict[str, Any]) -> None:
if not quote_currencies: if not quote_currencies:
quote_currencies = [config.get('stake_currency')] quote_currencies = [config.get('stake_currency')]
results = {} results = {}
with FtNoDBContext():
for curr in quote_currencies: for curr in quote_currencies:
config['stake_currency'] = curr config['stake_currency'] = curr
pairlists = PairListManager(exchange, config) pairlists = PairListManager(exchange, config)

View File

@@ -7,6 +7,7 @@ from fastapi.exceptions import HTTPException
from freqtrade.constants import Config 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.persistence import FtNoDBContext
from freqtrade.rpc.api_server.api_schemas import (BackgroundTaskStatus, BgJobStarted, from freqtrade.rpc.api_server.api_schemas import (BackgroundTaskStatus, BgJobStarted,
ExchangeModePayloadMixin, PairListsPayload, ExchangeModePayloadMixin, PairListsPayload,
PairListsResponse, WhitelistEvaluateResponse) PairListsResponse, WhitelistEvaluateResponse)
@@ -57,7 +58,7 @@ def __run_pairlist(job_id: str, config_loc: Config):
ApiBG.jobs[job_id]['is_running'] = True ApiBG.jobs[job_id]['is_running'] = True
from freqtrade.plugins.pairlistmanager import PairListManager from freqtrade.plugins.pairlistmanager import PairListManager
with FtNoDBContext():
exchange = get_exchange(config_loc) exchange = get_exchange(config_loc)
pairlists = PairListManager(exchange, config_loc) pairlists = PairListManager(exchange, config_loc)
pairlists.refresh_pairlist() pairlists.refresh_pairlist()