mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 08:33:07 +00:00
Add NoDBContext to pairlist evaluation functions
This commit is contained in:
@@ -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,11 +25,12 @@ 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 = {}
|
||||||
for curr in quote_currencies:
|
with FtNoDBContext():
|
||||||
config['stake_currency'] = curr
|
for curr in quote_currencies:
|
||||||
pairlists = PairListManager(exchange, config)
|
config['stake_currency'] = curr
|
||||||
pairlists.refresh_pairlist()
|
pairlists = PairListManager(exchange, config)
|
||||||
results[curr] = pairlists.whitelist
|
pairlists.refresh_pairlist()
|
||||||
|
results[curr] = pairlists.whitelist
|
||||||
|
|
||||||
for curr, pairlist in results.items():
|
for curr, pairlist in results.items():
|
||||||
if not args.get('print_one_column', False) and not args.get('list_pairs_print_json', False):
|
if not args.get('print_one_column', False) and not args.get('list_pairs_print_json', False):
|
||||||
|
|||||||
@@ -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,16 +58,16 @@ 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()
|
||||||
ApiBG.jobs[job_id]['result'] = {
|
ApiBG.jobs[job_id]['result'] = {
|
||||||
'method': pairlists.name_list,
|
'method': pairlists.name_list,
|
||||||
'length': len(pairlists.whitelist),
|
'length': len(pairlists.whitelist),
|
||||||
'whitelist': pairlists.whitelist
|
'whitelist': pairlists.whitelist
|
||||||
}
|
}
|
||||||
ApiBG.jobs[job_id]['status'] = 'success'
|
ApiBG.jobs[job_id]['status'] = 'success'
|
||||||
except (OperationalException, Exception) as e:
|
except (OperationalException, Exception) as e:
|
||||||
logger.exception(e)
|
logger.exception(e)
|
||||||
ApiBG.jobs[job_id]['error'] = str(e)
|
ApiBG.jobs[job_id]['error'] = str(e)
|
||||||
|
|||||||
Reference in New Issue
Block a user