
    'i                         d dl mZmZmZmZ d dlmZmZ d dlm	Z	  G d d ee	e
            Z G d d ee	e
            Z G d d	 ee	e
            Zy
)    )absolute_importdivisionprint_functionunicode_literals)MAXINTwith_metaclass)
MetaParamsc                       e Zd ZdZdZd Zy)	FixedSizea  Returns the execution size for a given order using a *percentage* of the
    volume in a bar.

    This percentage is set with the parameter ``perc``

    Params:

      - ``size`` (default: ``None``)  maximum size to be executed. The actual
        volume of the bar at execution time is also a limit if smaller than the
        size

        If the value of this parameter evaluates to False, the entire volume
        of the bar will be used to match the order
    ))sizeNc                     | j                   j                  xs t        }t        |j                  j
                  |   t        |j                  j                        |f      S )N)	pr   r   mindatavolumeabsexecutedremsize)selforderpriceagor   s        P/var/www/app/trading-bot/venv/lib/python3.12/site-packages/backtrader/fillers.py__call__zFixedSize.__call__/   sD    vv{{$fEJJ%%c*C0F0F,GNOO    N__name__
__module____qualname____doc__paramsr    r   r   r   r      s     FPr   r   c                       e Zd ZdZdZd Zy)FixedBarPerca0  Returns the execution size for a given order using a *percentage* of the
    volume in a bar.

    This percentage is set with the parameter ``perc``

    Params:

      - ``perc`` (default: ``100.0``) (valied values: ``0.0 - 100.0``)

        Percentage of the volume bar to use to execute an order
    )perc      Y@c                     |j                   j                  |   | j                  j                  z  dz  }t	        |t        |j                  j                              S )Nd   )r   r   r   r&   r   r   r   r   )r   r   r   r   maxsizes        r   r   zFixedBarPerc.__call__B   sD    ::$$S)DFFKK7C?7C 6 6788r   Nr   r"   r   r   r$   r$   4   s    
  F9r   r$   c                       e Zd ZdZdZd Zy)BarPointPercan  Returns the execution size for a given order. The volume will be
    distributed uniformly in the range *high*-*low* using ``minmov`` to
    partition.

    From the allocated volume for the given price, the ``perc`` percentage will
    be used

    Params:

      - ``minmov`` (default: ``0.01``)

        Minimum price movement. Used to partition the range *high*-*low* to
        proportionally distribute the volume amongst possible prices

      - ``perc`` (default: ``100.0``) (valied values: ``0.0 - 100.0``)

        Percentage of the volume allocated to the order execution price to use
        for matching

    ))minmovNr%   c                 B   |j                   }| j                  j                  }d}|r%|j                  |   |j                  |   z
  |z   |z  }|j
                  |   |z  | j                  j                  z  dz  }t        |t        |j                  j                              S )N   r'   )r   r   r-   highlowr   r&   r   r   r   r   )r   r   r   r   r   r-   parts	alloc_vols           r   r   zBarPointPerc.__call__c   s    zzYYs^dhhsm3f<GEkk#&.$&&++=%G	 9c%.."8"89::r   Nr   r"   r   r   r,   r,   I   s    (F
;r   r,   N)
__future__r   r   r   r   backtrader.utils.py3r   r   backtrader.metabaser	   objectr   r$   r,   r"   r   r   <module>r8      sR   ** * 8 *Pz62 P,9>*f5 9*&;>*f5 &;r   