freqtrade_origin/freqtrade/rpc/api_server/webserver_bgwork.py

40 lines
889 B
Python
Raw Normal View History

from typing import Any, Dict, Literal, Optional, TypedDict
2023-05-31 05:00:20 +00:00
from uuid import uuid4
from freqtrade.exchange.exchange import Exchange
2023-05-31 05:00:20 +00:00
class JobsContainer(TypedDict):
category: Literal['pairlist']
is_running: bool
status: str
progress: Optional[float]
result: Any
error: Optional[str]
class ApiBG:
# Backtesting type: Backtesting
bt: Dict[str, Any] = {
'bt': None,
'data': None,
'timerange': None,
'last_config': {},
'bt_error': None,
}
bgtask_running: bool = False
# Exchange - only available in webserver mode.
exchanges: Dict[str, Exchange] = {}
2023-05-31 05:00:20 +00:00
# Generic background jobs
2023-05-31 05:00:20 +00:00
# TODO: Change this to TTLCache
jobs: Dict[str, JobsContainer] = {}
# Pairlist evaluate things
pairlist_running: bool = False
2023-05-31 05:00:20 +00:00
@staticmethod
def get_job_id() -> str:
return str(uuid4())