
    6j                     T    d dl mZ d dlmZ d Zd Zd Zd Zd Zd Z	d	 Z
d
 Zd ZdS )    )Path)	BotConfigc                      ddl m}  t          ddd          }g d} | d|d	d
dt                      i d|	  	        }|j        du sJ |j        dk    sJ |j        dk    sJ d S )Nr   should_enter_flash_crash      @  <   flash_crash_trigger_pctmin_volume_24hcooldown_minutes)g      ?      Y@)       @g     X@)      @     W@BTCr     r        @	coinhistorycurrent_price
volume_24hbaseline_priceopen_positions	cooldownsnow_tscfgTflash_crashg      )strategyr   r   setenterreasondrop_pctr   r    r   decisions       tests/test_strategy_risk.py3test_flash_crash_entry_signal_allows_qualified_dumpr*      s    111111
CXZ
[
[
[C666G''uu
 
 
H >T!!!!?m++++$$$$$$    c                      ddl m}  t          ddd          }ddg} | d	|d
ddt                      d	did|	  	        }|j        du sJ |j        dk    sJ d S )Nr   r   r   r	   r
   r   r   )r   r   r   r   r   r   g     V@r   r   Fcooldown)r"   r   r   r#   r$   r%   r'   s       r)   4test_flash_crash_entry_signal_blocks_recent_cooldownr.      s    111111
CXZ
[
[
[C[)G''uu'"
 
 
H >U""""?j((((((r+   c            
          ddl m}  t          ddddd          }g d	} | d
|ddt                      i d|          }|j        du sJ |j        dk    sJ |j        dk    sJ |j        dk    sJ d S )Nr   (should_enter_volatility_squeeze_breakoutvolatility_squeeze_breakout   333333??r	   strategy_familysqueeze_lookback_tickssqueeze_max_band_width_pctsqueeze_breakout_pctr   )r   )r   gfffffY@)r   gX@)      @g33333Y@)      @gX@g      @r   SOLgfffff&Y@r   r   r   r   r   r   r   r   r   r    Tsqueeze_breakout)r"   r1   r   r#   r$   r%   r&   required_drop_pct)r1   r    compressed_then_breakoutr(   s       r)   >test_squeeze_breakout_entry_requires_compression_then_breakoutrC   3   s    AAAAAA
5 #&!  C      87(uu	 	 	H >T!!!!?00000q    %------r+   c            
          ddl m}  t          ddddd          }g d	} | d
|ddt                      i d|          }|j        du sJ |j        dk    sJ d S )Nr   r0   r2   r3   r4   r5   r	   r6   )r   )r        Y@)r   g     `X@)r;   g     Y@)r<   g     X@r=   r>   rE   r   r   r?   Fnot_compressed)r"   r1   r   r#   r$   r%   )r1   r    	wide_chopr(   s       r)   &test_squeeze_breakout_blocks_wide_choprH   W   s    AAAAAA
5 #&!  C cbbI77uu	 	 	H >U""""?.......r+   c                      ddl m} m} t          dd          } | ddd	          } |dd
d|d|          }|j        du sJ |j                            d          sJ d S )Nr   PositionStateexit_long_position   r   dead_fish_time_limit_minsmax_hard_stop_pct        r   g     @X@entry_tshigh_px	atr_sl_pxg     X@   i  entry_px
current_pxleveragestater   r    Tz	Dead Fish)r"   rK   rL   r   closer%   
startswithrK   rL   r    r[   r(   s        r)   9test_exit_decision_closes_dead_fish_long_after_time_limitr_   r   s    ::::::::
bC
H
H
HCM3FFFE!!5TAUZcjpstttH>T!!!!?%%k2222222r+   c                      ddl m} m} t          dd          } | ddd	          } |dd
d|d|          }|j        du sJ d|j        v sJ d S )Nr   rJ   rM   r   rN   rQ   r   g      T@rR   g9X@rV   r
   rW   TzSL Hit)r"   rK   rL   r   r\   r%   r^   s        r)   +test_exit_decision_closes_long_on_hard_stopra   ~   s    ::::::::
bC
H
H
HCM3FFFE!!5TAUZceknoooH>T!!!!x&&&&&&r+   c                     ddl m} | dz  }|                    d            |dd|t                                }|j        du sJ |j        dk    sJ d S )	Nr   	risk_gateKILL_SWITCHstoprQ   daily_pnl_usddaily_trade_countkill_switch_pathr    Fkill_switch)riskrd   
write_textr   allowedr%   )tmp_pathrd   rk   results       r)   -test_risk_blocks_when_kill_switch_file_existsrq      s~    ]*K6"""YSAP[ajalalmmmF>U""""=M))))))r+   c                      ddl m}  t          d          } | ddt          d          |          }|j        du sJ |j        d	k    sJ d S )
Nr   rc   g      9@)max_daily_loss_usdg(\9z/tmp/not-presentrg   Fdaily_loss_limit)rl   rd   r   r   rn   r%   )rd   r    rp   s      r)   !test_risk_blocks_daily_loss_limitru      st    
t
,
,
,CYVqSWXjSkSkqtuuuF>U""""=.......r+   c                      ddl m} m} d} | |          }|dk    sJ  |||          du sJ  |d|          du sJ  |d|          du sJ d S )	Nr   )expected_confirmationvalidate_panic_confirmation0x1234567890abcdefzCLOSE ALL cdefTz	CLOSE ALLFzCLOSE ALL beef)panic_guardrw   rx   )rw   rx   walletexpecteds       r)   <test_panic_guard_requires_exact_wallet_specific_confirmationr}      s    NNNNNNNN!F$$V,,H'''''&&x88D@@@@&&{F;;uDDDD&&'7@@EIIIIIIr+   N)pathlibr   configr   r*   r.   rC   rH   r_   ra   rq   ru   r}    r+   r)   <module>r      s               % % %.) ) ),!. !. !.H/ / /6	3 	3 	3	' 	' 	'	* 	* 	*/ / /	J 	J 	J 	J 	Jr+   