mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-13 03:33:55 +00:00
feat: add hyperopt-loss api endpoint
This commit is contained in:
parent
faac205464
commit
0bf30aaa6b
|
@ -456,6 +456,15 @@ class ExchangeListResponse(BaseModel):
|
|||
exchanges: list[ValidExchangesType]
|
||||
|
||||
|
||||
class HyperoptLoss(BaseModel):
|
||||
name: str
|
||||
description: str
|
||||
|
||||
|
||||
class HyperoptLossListResponse(BaseModel):
|
||||
loss_functions: list[HyperoptLoss]
|
||||
|
||||
|
||||
class PairListResponse(BaseModel):
|
||||
name: str
|
||||
description: str
|
||||
|
|
|
@ -27,6 +27,7 @@ from freqtrade.rpc.api_server.api_schemas import (
|
|||
ForceExitPayload,
|
||||
FreqAIModelListResponse,
|
||||
Health,
|
||||
HyperoptLossListResponse,
|
||||
Locks,
|
||||
LocksPayload,
|
||||
Logs,
|
||||
|
@ -82,7 +83,8 @@ logger = logging.getLogger(__name__)
|
|||
# 2.33: Additional weekly/monthly metrics
|
||||
# 2.34: new entries/exits/mix_tags endpoints
|
||||
# 2.35: pair_candles and pair_history endpoints as Post variant
|
||||
API_VERSION = 2.35
|
||||
# 2.40: Add hyperopt-loss endpoint
|
||||
API_VERSION = 2.40
|
||||
|
||||
# Public API, requires no auth.
|
||||
router_public = APIRouter()
|
||||
|
@ -456,6 +458,28 @@ def list_exchanges(config=Depends(get_config)):
|
|||
}
|
||||
|
||||
|
||||
@router.get("/hyperopt-loss", response_model=HyperoptLossListResponse, tags=["strategy"])
|
||||
def list_hyperoptloss(
|
||||
config=Depends(get_config),
|
||||
):
|
||||
import textwrap
|
||||
|
||||
from freqtrade.resolvers.hyperopt_resolver import HyperOptLossResolver
|
||||
|
||||
loss_functions = HyperOptLossResolver.search_all_objects(config, False)
|
||||
loss_functions = sorted(loss_functions, key=lambda x: x["name"])
|
||||
|
||||
return {
|
||||
"loss_functions": [
|
||||
{
|
||||
"name": x["name"],
|
||||
"description": textwrap.dedent((x["class"].__doc__ or "").strip()),
|
||||
}
|
||||
for x in loss_functions
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@router.get("/freqaimodels", response_model=FreqAIModelListResponse, tags=["freqai"])
|
||||
def list_freqaimodels(config=Depends(get_config)):
|
||||
from freqtrade.resolvers.freqaimodel_resolver import FreqaiModelResolver
|
||||
|
|
Loading…
Reference in New Issue
Block a user