"""
=========================================
CV6 AI Trading OS
Paper Trading Validator
=========================================
"""

from app.paper_trading.paper_models import PaperTradeRequest


class PaperTradingValidator:

    @staticmethod
    def validate(request: PaperTradeRequest):

        if request.capital is not None and request.capital <= 0:
            raise ValueError(
                "Capital must be greater than zero."
            )

        if request.quantity <= 0:
            raise ValueError(
                "Quantity must be greater than zero."
            )

        if request.entry_price <= 0:
            raise ValueError(
                "Entry Price must be greater than zero."
            )

        if request.action.upper() not in [
            "BUY",
            "SELL"
        ]:
            raise ValueError(
                "Action must be BUY or SELL."
            )

        return True