INNER CODE UNIT · Python

_validate_volume_split

codedpro/mt5-trade-split-manager · server.py:72

    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")
        if not any(x > 0 for x in split):
            raise ValueError("volume_split must have at least one entry > 0")
        total = sum(split)
        if not 0.99 <= total <= 1.01:
            raise ValueError(
                f"volume_split must sum to ~1.0 within [0.99, 1.01] (got {total:.4f})"

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…