INNER CODE UNIT · Python
_validate_tp_levels
codedpro/mt5-trade-split-manager · server.py:66
def _validate_tp_levels(cls, v: List[float]) -> List[float]:
if not 1 <= len(v) <= 10:
raise ValueError(f"tp_levels must contain 1 to 10 prices (got {len(v)})")
return v
@model_validator(mode="after")
def _validate_volume_split(self) -> "OrderCommand":
# An omitted split is filled in with the default at send time.
if self.volume_split is None:
return self
split = self.volume_split
if len(split) != len(self.tp_levels):
raise ValueError(
f"volume_split length ({len(split)}) must match tp_levels "
f"length ({len(self.tp_levels)})"
)
if any(x < 0 for x in split):
raise ValueError("volume_split entries must all be >= 0")