
    :&ja	                     R    d dl Zd dlmc mZ d dlmZ d dlm	Z	m
Z
mZ d Zd Zd ZdS )    N)Decimal)LocalOrderRecordReconcilerSnapshotreconcile_hyperliquid_statec            	      
   t          dddddidddddd	gg 
          } t          | dddi          }|j        }d}||u }|st          j        d|fd||f          dt          j                    v st          j        |          rt          j        |          ndt          j        |          t          j        |          dz  }dd|iz  }t          t          j
        |                    d x}x}}|j        }d}||k    }|st          j        d|fd||f          dt          j                    v st          j        |          rt          j        |          ndt          j        |          t          j        |          dz  }dd|iz  }t          t          j
        |                    d x}x}}d}|j        }||v }|st          j        d|fd||f          t          j        |          dt          j                    v st          j        |          rt          j        |          ndt          j        |          dz  }dd|iz  }t          t          j
        |                    d x}x}}d}|j        }||v }|st          j        d|fd||f          t          j        |          dt          j                    v st          j        |          rt          j        |          ndt          j        |          dz  }dd|iz  }t          t          j
        |                    d x}x}}d}|j        }||v }|st          j        d|fd||f          t          j        |          dt          j                    v st          j        |          rt          j        |          ndt          j        |          dz  }dd|iz  }t          t          j
        |                    d x}x}}d}|j        }||v }|st          j        d|fd||f          t          j        |          dt          j                    v st          j        |          rt          j        |          ndt          j        |          dz  }dd|iz  }t          t          j
        |                    d x}x}}d |j        D             }t          |          }|sdd t          j                    v st          j        t                    rt          j        t                    nd t          j        |          t          j        |          d!z  }	t          t          j
        |	                    d x}}d S )"NBTCz0.02longcoinszisideTtriggerbuyz0.01)r   
reduceOnly	orderTyper   sz	positionsopen_orderslocal_ordersi  i max_position_notional_usdmids)is)z9%(py2)s
{%(py2)s = %(py0)s.block_new_entries
} is %(py5)sresultpy0py2py5assert %(py7)spy7CRITICAL==)z0%(py2)s
{%(py2)s = %(py0)s.severity
} == %(py5)sz+exchange_position_without_local_journal:BTCinz.%(py1)s in %(py5)s
{%(py5)s = %(py3)s.alerts
}py1py3r   stop_wrong_direction:BTCstop_wrong_size:BTCzposition_exposure_exceeded:BTCc              3   .   K   | ]}|d          dk    V  dS )actionprepare_telegram_alertN ).0r.   s     X/home/agent/projects/CryptoTradingBot/Crypto_Agent/tests/test_reconciler_v76_extended.py	<genexpr>zltest_reconciler_flags_exchange_position_without_local_journal_and_bad_stop_direction_size.<locals>.<genexpr>   s-      eevh#;;eeeeee    z,assert %(py4)s
{%(py4)s = %(py0)s(%(py2)s)
}any)r   r   py4)r   r   block_new_entries
@pytest_ar_call_reprcompare@py_builtinslocals_should_repr_global_name	_safereprAssertionError_format_explanationseverityalertsrecommended_actionsr5   )
snapshotr   @py_assert1@py_assert4@py_assert3@py_format6@py_format8@py_assert0@py_assert2@py_format5s
             r2   Ytest_reconciler_flags_exchange_position_without_local_journal_and_bad_stop_direction_sizerL      s[   !5HHI#4iY^flmmn  H )TY^`fXghhhF#+t+#t++++++++++#t++++++++++++6+++++6++++++#++++t+++++++++++++++++++++++++++?(j(?j((((((((((?j((((((((((((6(((((6((((((?((((j(((((((((((((((((((((((((((8IFMI8MIIIIIIIIII8MIIIII8IIIIIIIIIIIFIIIIIFIIIIIIMIIIIIIIIIIIIIIIIIIIIIIIIIII%66%6666666666%66666%6666666666666666666666666666666666666666666666666 1FM1 M1111111111 M11111 11111111111F11111F111111M111111111111111111111111111+<v}<+}<<<<<<<<<<+}<<<<<+<<<<<<<<<<<v<<<<<v<<<<<<}<<<<<<<<<<<<<<<<<<<<<<<<<<<ee&Jdeeee3eeeeeeeeeeeeeeee3eeeee3eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeer4   c            	      t   t          i ddddddgt          ddd	          g
          } t          |           }d}|j        }||v }|st	          j        d|fd||f          t	          j        |          dt          j                    v st	          j	        |          rt	          j        |          ndt	          j        |          dz  }dd|iz  }t          t	          j        |                    d x}x}}d}|j        }||v }|st	          j        d|fd||f          t	          j        |          dt          j                    v st	          j	        |          rt	          j        |          ndt	          j        |          dz  }dd|iz  }t          t	          j        |                    d x}x}}d S )NETHFlimitr   )r   r   r   r   deadmanProtectedr   entry-1entry)r   client_order_id
order_roler   z4local_journal_position_without_exchange_position:BTCr%   r'   r   r(   r    r!   zentry_order_without_deadman:ETH)r   r   r   rA   r8   r9   r=   r:   r;   r<   r>   r?   )rC   r   rI   rE   rJ   rG   rH   s          r2   Wtest_reconciler_flags_local_journal_without_exchange_position_and_entry_without_deadmanrU      s   !#5wX]sxyyz&E9Y`aaab  H )22FARV]RA]RRRRRRRRRRA]RRRRRARRRRRRRRRRRVRRRRRVRRRRRR]RRRRRRRRRRRRRRRRRRRRRRRRRRR,==,==========,=====,===================================================r4   c                     t          dddddidddddddgt          dd	d
t          d                    g          } t          | dddi          }|j        }d}||k    }|st          j        d|fd||f          dt          j                    v st          j	        |          rt          j
        |          ndt          j
        |          t          j
        |          dz  }dd|iz  }t          t          j        |                    d x}x}}d}|j        }||v}|st          j        d|fd||f          t          j
        |          dt          j                    v st          j	        |          rt          j
        |          ndt          j
        |          dz  }dd|iz  }t          t          j        |                    d x}x}}d}|j        }||v}|st          j        d|fd||f          t          j
        |          dt          j                    v st          j	        |          rt          j
        |          ndt          j
        |          dz  }dd|iz  }t          t          j        |                    d x}x}}d}|j        }||v}|st          j        d|fd||f          t          j
        |          dt          j                    v st          j	        |          rt          j
        |          ndt          j
        |          dz  }dd|iz  }t          t          j        |                    d x}x}}d S )Nr   z0.00024r	   r
   TA61608)r   r   r   r   origSzlimitPxrQ   rR   )r   rS   rT   sizer   d   i0  r   r   r#   )z;%(py2)s
{%(py2)s = %(py0)s.stops_missing_count
} == %(py5)sr   r   r    r!   zposition_without_stop:BTC)not in)z2%(py1)s not in %(py5)s
{%(py5)s = %(py3)s.alerts
}r(   r+   r,   )r   r   r   r   stops_missing_countr8   r9   r:   r;   r<   r=   r>   r?   rA   )	rC   r   rD   rE   rF   rG   rH   rI   rJ   s	            r2   Otest_reconciler_accepts_hyperliquid_reduce_only_stop_payload_without_order_typer_   %   s	   !5FKKL#4Iajw~  A&E9Y`gnoxgygyzzz{  H )SX]_dWefffF%**%**********%************6*****6******%*******************************&;fm;&m;;;;;;;;;;&m;;;;;&;;;;;;;;;;;f;;;;;f;;;;;;m;;;;;;;;;;;;;;;;;;;;;;;;;;;%:V]:%]::::::::::%]:::::%:::::::::::V:::::V::::::]::::::::::::::::::::::::::: 55 5555555555 55555 555555555555555555555555555555555555555555555555555r4   )builtinsr:   _pytest.assertion.rewrite	assertionrewriter8   decimalr   )src.reconciliation.hyperliquid_reconcilerr   r   r   rL   rU   r_   r0   r4   r2   <module>rf      s                        w w w w w w w w w wf f f$
> 
> 
>6 6 6 6 6r4   