
    %j	                     h    d dl Zd dlmc mZ d dlmZ d dlm	Z	 d dl
mZ d dlmZ d Zd Zd Zd	 ZdS )
    N)Decimal)HyperliquidTestnetExecutor)OrderIntent)HyperliquidAssetMetac                  T   t          d i ddddddddd	d
dddddt          d          dt          d          dd dt          d          dt          d          dddddt          d          dt          d          }|                    |            t          d i |S )!Nstrategy_id)candidate_v76_hl_confirmed_squeeze_hybridsymbolzBTC/USDC:USDCcoinBTCsidebuyreduce_onlyF
order_typelimittifAlosizez0.010009pricez
99999.9876trigger_price	stop_loss99000take_profit105000client_order_idz	v76-BTC-1reasonpayload_smokerisk_usdz1.25estimated_notional_usd1000 )dictr   updater   )	overridesbases     ^/home/agent/projects/CryptoTradingBot/Crypto_Agent/tests/test_hyperliquid_executor_payloads.py_intentr'      s+      ?? U U	
 E 7 E Z    l### d '""" H%%% $     'v!D$ 	KK	    c                 	   |                      dd           t          d dd          }|                    t                      t	          ddd          t          d	          
          }|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         }d}||k    }	|	slt          j        d|	fd||f          t          j        |          t          j        |          dz  }
dd|
iz  }t          t          j        |                    d x}x}	}|j        d         }d}||k    }	|	slt          j        d|	fd||f          t          j        |          t          j        |          dz  }
dd|
iz  }t          t          j        |                    d x}x}	}|j        d         }d}||k    }	|	slt          j        d|	fd||f          t          j        |          t          j        |          dz  }
dd|
iz  }t          t          j        |                    d x}x}	}|j        d         }d}||k    }	|	slt          j        d|	fd||f          t          j        |          t          j        |          dz  }
dd|
iz  }t          t          j        |                    d x}x}	}|j        d         }d}||k    }	|	slt          j        d|	fd||f          t          j        |          t          j        |          dz  }
dd|
iz  }t          t          j        |                    d x}x}	}|j        d         }d}||u }	|	slt          j        d|	fd ||f          t          j        |          t          j        |          dz  }
dd|
iz  }t          t          j        |                    d x}x}	}|j        d         }d}||u }	|	slt          j        d|	fd ||f          t          j        |          t          j        |          dz  }
dd|
iz  }t          t          j        |                    d x}x}	}d S )!N
CTB_HL_ENVtestnet
TESTNET OKTexchangeexpected_confirmationdry_runr   r      10min_notional_usdisz0%(py2)s
{%(py2)s = %(py0)s.accepted
} is %(py5)sresultpy0py2py5assert %(py7)spy7r   )==)z%(py1)s == %(py4)s)py1py4zassert %(py6)spy6r   z0.01000r   99999r   r   r   r   r   )z%(py1)s is %(py4)s)setenvr   prepare_payloadr'   r   r   accepted
@pytest_ar_call_reprcompare@py_builtinslocals_should_repr_global_name	_safereprAssertionError_format_explanationpayloadstop_loss_payloadtake_profit_payload)monkeypatchexecutorr8   @py_assert1@py_assert4@py_assert3@py_format6@py_format8@py_assert0@py_assert2@py_format5@py_format7s               r&   Btest_testnet_executor_builds_rounded_payload_without_exchange_callr]      s   |Y///)4|eijjjH%%gii1EeQPQ1R1Relmqerer%ssF?"d"?d""""""""""?d""""""""""""6"""""6""""""?""""d""""""""""""""""""""""""""">&!*U*!U**********!U*****!****U***************************>&!.Y.!Y..........!Y.....!....Y...........................>'"-g-"g----------"g-----"----g--------------------------->,'272'72222222222'722222'22227222222222222222222222222222>% )E) E)))))))))) E))))) ))))E)))))))))))))))))))))))))))#M2:d:2d::::::::::2d:::::2::::d:::::::::::::::::::::::::::%m4<<4<<<<<<<<<<4<<<<<4<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<r(   c                    |                      dd           t          d dd          }|                    t                      t	          ddd          t          d	          
          }|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}}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*   mainnetr,   Tr-   r   r   r1   r2   r3   Fr5   r7   r8   r9   r=   r>   testnet_env_requiredinz/%(py1)s in %(py5)s
{%(py5)s = %(py3)s.reasons
}r@   py3r<   )rD   r   rE   r'   r   r   rF   rG   rH   rI   rJ   rK   rL   rM   rN   reasons
rR   rS   r8   rT   rU   rV   rW   rX   rY   rZ   s
             r&   )test_testnet_executor_rejects_mainnet_envrh   /   s&   |Y///)4|eijjjH%%gii1EeQPQ1R1Relmqerer%ssF?#e#?e##########?e############6#####6######?####e###########################!3V^3!^3333333333!^33333!33333333333V33333V333333^33333333333333333333333333333r(   c                    |                      dd           t          d dd          }|                    t          t	          d                    t          dd	d
          t	          d                    }|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}}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*   r+   r,   Tr-   z0.00001)r   r   r   r1   r2   r3   Fr5   r7   r8   r9   r=   r>   min_notionalra   rc   rd   )rD   r   rE   r'   r   r   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rf   rg   s
             r&   *test_testnet_executor_rejects_min_notionalrk   9   sJ   |Y///)4|eijjjH%%g793E3E&F&F&FH\]bdeghHiHi  }D  EI  }J  }J%  K  KF?#e#?e##########?e############6#####6######?####e###########################+V^+>^++++++++++>^+++++>+++++++++++V+++++V++++++^+++++++++++++++++++++++++++++r(   )builtinsrI   _pytest.assertion.rewrite	assertionrewriterG   decimalr   *src.execution.hyperliquid_testnet_executorr   src.execution.order_intentr   src.hyperliquid.roundingr   r'   r]   rh   rk   r!   r(   r&   <module>rt      s                        Q Q Q Q Q Q 2 2 2 2 2 2 9 9 9 9 9 9  .= = = 4 4 4, , , , ,r(   