
    'i                         d dl mZmZmZmZ d dlZ G d dej                        ZeZ	 G d dej                        Z
 G d dej                        Zy)	    )absolute_importdivisionprint_functionunicode_literalsNc                        e Zd ZdZdZd Zd Zy)	FixedSizea.  
    This sizer simply returns a fixed size for any operation.
    Size can be controlled by number of tranches that a system
    wishes to use to scale into trades by specifying the ``tranches``
    parameter.


    Params:
      - ``stake`` (default: ``1``)
      - ``tranches`` (default: ``1``)
    stake   )tranchesr   c                     | j                   j                  dkD  r?t        t        | j                   j                  | j                   j                  z              S | j                   j                  S Nr   pr   absintr   )selfcomminfocashdataisbuys        Y/var/www/app/trading-bot/venv/lib/python3.12/site-packages/backtrader/sizers/fixedsize.py
_getsizingzFixedSize._getsizing+   sE    66??Qs466<<$&&//9:;;66<<    c                     | j                   j                  dkD  rOt        t        | j                   j                  | j                   j                  z              | j                   _        y || j                   _        y r   r   )r   r   s     r   	setsizingzFixedSize.setsizing1   sG    66??Qs466<<$&&//#ABCDFFL DFFLr   N__name__
__module____qualname____doc__paramsr   r    r   r   r   r      s    
F !r   r   c                       e Zd ZdZdZd Zy)FixedReversera  This sizer returns the needes fixed size to reverse an open position or
    the fixed size to open one

      - To open a position: return the param ``stake``

      - To reverse a position: return 2 * ``stake``

    Params:
      - ``stake`` (default: ``1``)
    )r
   c                     | j                   j                  |      }| j                  j                  d|j                  dk7  z   z  }|S )Nr   r   )strategygetpositionr   r   size)r   r   r   r   r   positionr*   s          r   r   zFixedReverser._getsizingH   s;    ==,,T2vv||qHMMQ$678r   N)r   r    r!   r"   r#   r   r$   r   r   r&   r&   ;   s    	 Fr   r&   c                        e Zd ZdZdZd Zd Zy)FixedSizeTargeta  
    This sizer simply returns a fixed target size, useful when coupled
    with Target Orders and specifically ``cerebro.target_order_size()``.
    Size can be controlled by number of tranches that a system
    wishes to use to scale into trades by specifying the ``tranches``
    parameter.


    Params:
      - ``stake`` (default: ``1``)
      - ``tranches`` (default: ``1``)
    r	   c                 `   | j                   j                  dkD  rt        t        | j                   j                  | j                   j                  z              }t        | j                  j                  j                  |z   | j                   j                        S | j                   j                  S r   	r   r   r   r   r   minr(   r+   r*   )r   r   r   r   r   r*   s         r   r   zFixedSizeTarget._getsizing_   sn    66??Qs466<<$&&//9:;D..33d:TVV\\JJ66<<r   c                 x   | j                   j                  dkD  rt        t        | j                   j                  | j                   j                  z              }t        | j                  j                  j                  |z   | j                   j                        | j                   _        y || j                   _        y r   r/   )r   r   r*   s      r   r   zFixedSizeTarget.setsizingf   su    66??Qs466<<$&&//9:;D 6 6 ; ;d B#vv||-DFFL !DFFLr   Nr   r$   r   r   r-   r-   N   s    F !r   r-   )
__future__r   r   r   r   
backtraderbtSizerr   SizerFixr&   r-   r$   r   r   <module>r7      sK   ** * ! !: BHH &!bhh !r   