
    tgj                    <    S SK Jr  S SKJr  SSKJr   " S S5      rg)    )annotations)datetime   )	QueueItemc                  \    \ rS rSrSS	S jjr            S
S jrSS jrSSS jjrSrg)OpportunityQueue   c                    Xl         0 U l        g N)max_size_items)selfr   s     ?/mnt/data/HANZ_v2.2_Realtime_Gateway/src/hanz_realtime/queue.py__init__OpportunityQueue.__init__	   s     8:    c                "   [        UUUUUS9U R                  X!4'   [        U R                  5      U R                  :  aL  U R	                  5       S U R                   nU Vs0 s H  owR
                  UR                  4U_M     snU l        g g s  snf )N)symbolmarketscorereason
updated_at)r   r   lenr   rankedr   r   )r   r   r   r   r   r   keepitems           r   upsertOpportunityQueue.upsert   s     )2!)
V$% t{{dmm+;;=4==1DHLMKK5t;MDK ,Ms    "Bc                >    U R                   R                  X4S 5        g r   )r   pop)r   r   r   s      r   removeOpportunityQueue.remove    s    ($/r   Nc                \    [        U R                  R                  5       S S9nUc  U$ US U $ )Nc                J    U R                   * U R                  U R                  4$ r   )r   r   r   )r   s    r   <lambda>)OpportunityQueue.ranked.<locals>.<lambda>&   s    tzzk4;;Dr   )key)sortedr   values)r   limititemss      r   r   OpportunityQueue.ranked#   s6    KK D
 u85%=8r   )r   r   )2   )r   intreturnNone)r   strr   r1   r   floatr   r1   r   r   r/   r0   )r   r1   r   r1   r/   r0   r   )r*   z
int | Noner/   zlist[QueueItem])	__name__
__module____qualname____firstlineno__r   r   r!   r   __static_attributes__ r   r   r   r      s\    ;NN N 	N
 N N 
N&09 9r   r   N)
__future__r   r   modelsr   r   r8   r   r   <module>r;      s    "   9  9r   