2023-06-02 07:50:40 +00:00
|
|
|
from typing import Any, Dict, Literal, Optional, TypedDict
|
2023-05-31 05:00:20 +00:00
|
|
|
from uuid import uuid4
|
|
|
|
|
2023-06-02 07:50:40 +00:00
|
|
|
from freqtrade.exchange.exchange import Exchange
|
|
|
|
|
2023-05-31 05:00:20 +00:00
|
|
|
|
|
|
|
class JobsContainer(TypedDict):
|
2024-05-12 14:51:11 +00:00
|
|
|
category: Literal["pairlist"]
|
2023-05-31 05:00:20 +00:00
|
|
|
is_running: bool
|
|
|
|
status: str
|
|
|
|
progress: Optional[float]
|
|
|
|
result: Any
|
|
|
|
error: Optional[str]
|
2023-05-21 07:08:52 +00:00
|
|
|
|
|
|
|
|
2023-06-29 12:16:10 +00:00
|
|
|
class ApiBG:
|
2023-05-21 07:08:52 +00:00
|
|
|
# Backtesting type: Backtesting
|
2023-05-21 07:12:02 +00:00
|
|
|
bt: Dict[str, Any] = {
|
2024-05-12 14:51:11 +00:00
|
|
|
"bt": None,
|
|
|
|
"data": None,
|
|
|
|
"timerange": None,
|
|
|
|
"last_config": {},
|
|
|
|
"bt_error": None,
|
2023-05-21 07:08:52 +00:00
|
|
|
}
|
2023-05-21 07:12:02 +00:00
|
|
|
bgtask_running: bool = False
|
2023-05-21 07:08:52 +00:00
|
|
|
# Exchange - only available in webserver mode.
|
2023-06-02 07:50:40 +00:00
|
|
|
exchanges: Dict[str, Exchange] = {}
|
2023-05-31 05:00:20 +00:00
|
|
|
|
|
|
|
# Generic background jobs
|
2023-06-02 07:50:40 +00:00
|
|
|
|
2023-05-31 05:00:20 +00:00
|
|
|
# TODO: Change this to TTLCache
|
|
|
|
jobs: Dict[str, JobsContainer] = {}
|
2023-05-21 07:38:14 +00:00
|
|
|
# Pairlist evaluate things
|
|
|
|
pairlist_running: bool = False
|
2023-05-31 05:00:20 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def get_job_id() -> str:
|
|
|
|
return str(uuid4())
|