
    >jR                         d dl mZ d dlmZ d dlmZ d dlmZmZm	Z	m
Z
mZmZ dded         fd	Zd
 Zd Zd Zd Zd Zd Zd ZdS )    )Decimal)Literal)OrderIntent)CopyObservationEvidenceGlobalStrategyContextMarketRegimeContextPromotionEvidenceStrategyCandidateevaluate_global_strategybuy#candidate_v76_strict_live_candidateside)r   sellc                     t          di d|ddddd| ddd	d
dddt          d          dd dd dt          d          dd dddddt          d          dt          d          S )Nstrategy_idsymbolzBTC/USDC:USDCcoinBTCr   reduce_onlyF
order_typemarkettifIocsizez0.001pricetrigger_price	stop_loss99000take_profitclient_order_idztest-1reasonconfirmed_retestrisk_usdz0.10estimated_notional_usd10 )r   r   )r   r   s     $tests/test_global_strategy_policy.pymake_intentr(      s       K U T	
 E 8 E W d d '""" D ! "!    't}}}!     c                  ,   t          dt          d          t          d          t          d          t          d          t          d          t          d          t          d          d	d

  
        }|                    |            t          di |S )N#   z4.2z1.148z1.3125r%   z1.2FT)
closed_tradestotal_net_pnllast_20_net_pnlwin_rate_pctprofit_factortop_coin_share_pctshort_scalp_share_pctmax_drawdown_usdreplay_onlysimulator_sanity_okr&   )dictr   updater	   	overridesdatas     r'   passing_promotionr=   $   s    ennT]]foo"4==%dmm    D 	KK	$$t$$$r)   c            
          t          t          ddd          t          ddddd	          ddddd
          }|                    |            t	          di |S )NbullishF	btc_trend	eth_trendchoppyE   T   r   im  T)cycles_completedexpected_cyclesallowed_signalsshadow_decisionsdata_quality_ok)market_regimecopy_observationreconcile_cleanstops_confirmedalerts_confirmedkill_switch_activelive_entries_blockedr&   )r8   r   r   r9   r   r:   s     r'   base_contextrR   5   s    )I[`aaa0"VXjk  C  UY  Z  Z  Z !  D 	KK	 ((4(((r)   c                      t          ddt          d          t                                } t          | t	                                }|j        du sJ |j        dk    sJ d|j        v sJ |j        dk    sJ d S )	Ncopy_direct_executorcopy)r   r   familyintent	promotionFresearch'copy_observation_has_no_allowed_signalscopy_research_only)	r
   r(   r=   r   rR   allowedstatusreasonsrecommended_mode	candidatedecisions     r'   Qtest_global_policy_blocks_copy_executor_when_observation_has_zero_allowed_signalsrd   C   s    !*'=>>>#%%	  I (	<>>BBHu$$$$?j((((48HHHHH$(<<<<<<<r)   c                  D   t          ddt          d          t                                } t          t	          ddd          	          }t          t	          d
dd          	          }dt          | |          j        v sJ dt          | |          j        v sJ d S )Nr   v76_anti_chaser   )r   rV   bearishFr@   )rK   mixedr?   Tmarket_regime_blocks_longmarket_regime_choppy_no_trade)r
   r(   r=   rR   r   r   r_   )rb   rg   rC   s      r'   @test_global_policy_blocks_long_trade_in_bearish_or_choppy_regimerk   S   s    !9&&&#%%	  I )<y\ens)t)t)tuuuG(;gYbko(p(p(pqqqF&*B9g*V*V*^^^^^*.FyRX.Y.Y.aaaaaaar)   c            	         t          ddt                      t                      t          d          dd          } t	          | t                                }|j        du sJ d|j        v sJ d|j        v sJ d|j        v sJ d S )	Nr   rf   z2.9Fr   rW   rX   rY   expected_move_vs_costanti_chase_okretest_confirmedexpected_move_below_cost_hurdleanti_chase_not_confirmedretest_not_confirmed)r
   r(   r=   r   r   rR   r]   r_   ra   s     r'   Ctest_global_policy_requires_cost_hurdle_and_anti_chase_confirmationrt   b   s    !9}}#%%%enn  I (	<>>BBHu$$$$,0@@@@@%)99999!X%5555555r)   c                  |   t          ddt                      t          dt          d          d          t          d          dd          } t	          d	d	d	
          }t          | |          }|j        d	u sJ d|j        v sJ d|j        v sJ d|j        v sJ d|j        v sJ d|j        v sJ d|j        v sJ d S )Nr   rf      z-0.1T)r.   r/   r6   4.5rm   F)rM   rN   rO   sample_too_smallpaper_total_pnl_not_positivereplay_only_not_promotablereconcile_not_cleanstops_not_confirmedalerts_not_confirmed)r
   r(   r=   r   rR   r   r]   r_   )rb   contextrc   s      r'   Itest_global_policy_blocks_live_until_promotion_and_safety_gates_are_greenr   u   s   !9}}#"GFOOaefff%enn  I 5%Z_```G'	7;;Hu$$$$!11111)X-====='8+;;;;; H$44444 H$44444!X%5555555r)   c                  h   t          ddt                      t                      t          d          ddt          d          d	  	        } t	          | t                                }|j        du sJ |j        dk    sJ |j        d	k    sJ |j	        d
         dk    sJ |j	        d         dk    sJ d S )Nr   rf   rw   T1   )	r   rW   rX   rY   rn   ro   rp   max_effective_leveragemax_open_positionstiny_live_preview_readytiny_live_previewr   r   )
r
   r(   r=   r   r   rR   r]   r^   r`   risk_limitsra   s     r'   Itest_global_policy_allows_tiny_live_preview_only_when_every_gate_is_greenr      s    !9}}#%%%enn&s||
 
 
I (	<>>BBHt####?77777$(;;;;; 89S@@@@ 45::::::r)   N)r   r   )decimalr   typingr   src.execution.order_intentr   %src.strategies.global_strategy_policyr   r   r   r	   r
   r   r(   r=   rR   rd   rk   rt   r   r   r&   r)   r'   <module>r      s&               2 2 2 2 2 2                gm,    *% % %") ) )= = = b b b6 6 6&6 6 6.; ; ; ; ;r)   