
    'i
                     N    d dl mZmZmZmZ d dl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)PositionsValuea  This analyzer reports the value of the positions of the current set of
    datas

    Params:

      - timeframe (default: ``None``)
        If ``None`` then the timeframe of the 1st data of the system will be
        used

      - compression (default: ``None``)

        Only used for sub-day timeframes to for example work on an hourly
        timeframe by specifying "TimeFrame.Minutes" and 60 as compression

        If ``None`` then the compression of the 1st data of the system will be
        used

      - headers (default: ``False``)

        Add an initial key to the dictionary holding the results with the names
        of the datas ('Datetime' as key

      - cash (default: ``False``)

        Include the actual cash as an extra position (for the header 'cash'
        will be used as name)

    Methods:

      - get_analysis

        Returns a dictionary with returns as values and the datetime points for
        each return as keys
    ))headersF)cashFc                 |   | j                   j                  rbt        | j                        D cg c]  \  }}|j                  xs d|z   }}}|dg| j                   j
                  z  z   | j                  d<   t        d | j                  D              }|t        j                  j                  k\  | _        y c c}}w )NzData%dr
   Datetimec              3   4   K   | ]  }|j                     y wN)
_timeframe).0ds     \/var/www/app/trading-bot/venv/lib/python3.12/site-packages/backtrader/analyzers/positions.py	<genexpr>z'PositionsValue.start.<locals>.<genexpr>J   s     2!2s   )pr	   	enumeratedatas_namer
   retsminbt	TimeFrameDays_usedate)selfir   r	   tfs        r   startzPositionsValue.startD   s    66>>#,TZZ#8:1a ww.(Q,. :G :$+vh.D$DDIIj!2tzz22bll///:s   B8c                    | j                   D cg c](  }| j                  j                  j                  |g      * }}| j                  j
                  r3|j                  | j                  j                  j                                | j                  r2|| j                  | j                  j                  j                         <   y || j                  | j                  j                  j                         <   y c c}w r   )r   strategybroker	get_valuer   r
   appendget_cashr   r   datetimedate)r   r   pvalss      r   nextzPositionsValue.nextM   s    >BjjI%%//4II66;;LL--6689==7<DIIdmm,,1134;@DIIdmm,,5578 Js   -C7N)__name__
__module____qualname____doc__paramsr!   r+        r   r   r      s    !DF
0Ar2   r   )	
__future__r   r   r   r   
backtraderr   Analyzerr   r1   r2   r   <module>r6      s&   ** * 9AR[[ 9Ar2   