"""
=========================================
CV6 AI Trading OS
Portfolio Validator
=========================================
"""

from app.portfolio.portfolio_models import PortfolioRequest


class PortfolioValidator:

    @staticmethod
    def validate(request: PortfolioRequest):

        if request.capital <= 0:
            raise ValueError(
                "Capital must be greater than zero."
            )

        if request.used_margin < 0:
            raise ValueError(
                "Used margin cannot be negative."
            )

        if request.open_positions < 0:
            raise ValueError(
                "Open positions cannot be negative."
            )

        return True