feat: Add initial data-download api schema

This commit is contained in:
Matthias
2024-10-24 06:05:19 +02:00
parent 7ef93e92e6
commit f23da7ea75

View File

@@ -1,9 +1,15 @@
from datetime import date, datetime from datetime import date, datetime
from typing import Any from typing import Any
from pydantic import AwareDatetime, BaseModel, RootModel, SerializeAsAny from pydantic import (
AwareDatetime,
BaseModel,
RootModel,
SerializeAsAny,
model_validator,
)
from freqtrade.constants import IntOrInf from freqtrade.constants import DL_DATA_TIMEFRAMES, IntOrInf
from freqtrade.enums import MarginMode, OrderTypeValues, SignalDirection, TradingMode from freqtrade.enums import MarginMode, OrderTypeValues, SignalDirection, TradingMode
from freqtrade.ft_types import ValidExchangesType from freqtrade.ft_types import ValidExchangesType
@@ -482,6 +488,21 @@ class PairListsPayload(ExchangeModePayloadMixin, BaseModel):
stake_currency: str stake_currency: str
class DownloadDataPayload(ExchangeModePayloadMixin, BaseModel):
pairs: list[str]
stake_currency: str
timeframes: Optional[list[str]] = DL_DATA_TIMEFRAMES
days: Optional[int] = None
timerange: Optional[str] = None
@model_validator(mode="before")
def check_mutually_exclusive(cls, values):
timeframes, days = values.get("timerange"), values.get("days")
if timeframes and days:
raise ValueError("Only one of timeframes or days can be provided, not both.")
return values
class FreqAIModelListResponse(BaseModel): class FreqAIModelListResponse(BaseModel):
freqaimodels: list[str] freqaimodels: list[str]