
    'i                     \    d dl mZmZmZmZ ddlmZ ddlmZ  G d d eee	            Z
e
Zy)    )absolute_importdivisionprint_functionunicode_literals   )with_metaclass)
MetaParamsc                   *    e Zd ZdZdZdZd Zd Zd Zy)SizeraQ  This is the base class for *Sizers*. Any *sizer* should subclass this
    and override the ``_getsizing`` method

    Member Attribs:

      - ``strategy``: will be set by the strategy in which the sizer is working

        Gives access to the entire api of the strategy, for example if the
        actual data position would be needed in ``_getsizing``::

           position = self.strategy.getposition(data)

      - ``broker``: will be set by the strategy in which the sizer is working

        Gives access to information some complex sizers may need like portfolio
        value, ..
    Nc                     | j                   j                  |      }| j                  || j                   j                         ||      S N)brokergetcommissioninfo
_getsizinggetcash)selfdataisbuycomminfos       N/var/www/app/trading-bot/venv/lib/python3.12/site-packages/backtrader/sizer.py	getsizingzSizer.getsizing2   s8    ;;006x)<)<)>eLL    c                     t         )a  This method has to be overriden by subclasses of Sizer to provide
        the sizing functionality

        Params:
          - ``comminfo``: The CommissionInfo instance that contains
            information about the commission for the data and allows
            calculation of position value, operation cost, commision for the
            operation

          - ``cash``: current available cash in the *broker*

          - ``data``: target of the operation

          - ``isbuy``: will be ``True`` for *buy* operations and ``False``
            for *sell* operations

        The method has to return the actual size (an int) to be executed. If
        ``0`` is returned nothing will be executed.

        The absolute value of the returned value will be used

        )NotImplementedError)r   r   cashr   r   s        r   r   zSizer._getsizing6   s
    . "!r   c                      || _         || _        y r   )strategyr   )r   r   r   s      r   setz	Sizer.setO   s     r   )	__name__
__module____qualname____doc__r   r   r   r   r    r   r   r   r      s#    " HFM"2r   r   N)
__future__r   r   r   r   	utils.py3r   metabaser	   objectr   	SizerBaser#   r   r   <module>r)      s2   ** * &  4N:v. 4n 	r   