o
     áÚj³  ã                   @   s~   d Z i dd“dd“dd“dd“d	d
“dd“dd“dd“dd“dd“dd“dd“dd“dd“dd“dd“Zdd „ Zd$d"d#„Zd!S )%a“  
r7_setup.py -- [2026-10-23] The user's setup R7 "PULLBACK IN A MORNING UPTREND, NOT EXTENDED" (from the CRML 10/3/2025
practice chart, ATR 9.9%: a choppy morning climb 8.24 -> 8.79 in steps; the 9:43 high 8.61, pullback on heavy selling
(9:45 2.5x 20% buyers, 9:48 3.4x 36%) to 8.33 -- a higher low above the morning low -- then 9:49 turned up with 69% buyers;
the user's entry "9:48 pullback" -> buy 9:50 open ~8.44, +2% at 9:51). Different from FRMI 9:45 (dropped by the user):
CRML was only +1.3..2.5% over the open, not extended.
  1 UPTREND    a recent high (made within high_age (15) bars) >= max(trend_pct 1.5%, trend_atr 0.2 x ATR %) over the open
  2 PULLBACK   from that high down >= max(pb_pct 1%, pb_atr 0.15 x ATR %) and no more than pb_max (80%) of the climb from the
               morning low to the high
  3 HIGHER LOW the pullback low is above the morning low (the low before the high)
  4 TURN       the trigger bar closes above the bar before with buyers >= turn_bs (60%)
  5 NOT EXTENDED  <= max_open (3%) over the open and <= max_vwap (2%) over VWAP at the trigger (S6 / A1 / A5)
  6 ROOM       the recent high >= room_pct (1.5%) above the close
  7 HOLDS VWAP the turn bar closes at or above VWAP (min_vwap 0%) -- [10/23, RIOT 3/24/26 10:17: a slow drift that broke
               under VWAP, flat turn bar -> -1% first; CRML: fast flush, stayed above VWAP, +1.1% turn bar]
  8 REAL TURN  the turn bar gains >= turn_gain (0.3%) from its own open
  safety       >= min_spm shares/min; 9:40-11:00; cool-down 10 min (one trigger per pullback)
When R7 is true these v2 rules do NOT apply: the 15-min buy share / steady trend (the pullback breaks them). Untested.
Úhigh_ageé   Ú	trend_pctg      ø?Ú	trend_atrgš™™™™™É?Úpb_pctg      ð?Úpb_atrg333333Ã?Úpb_maxgš™™™™™é?Úturn_bsg333333ã?Úmax_openg      @Úmax_vwapg       @Úroom_pctÚmin_spmiÐ  Úfirst_mé
   Úlast_méZ   ÚcooldownÚmin_vwapg        Ú	turn_gaing333333Ó?c                 C   sZ   ddl m }m} ddlm} t| |ƒs| | |j¡} |  |dƒ¡} | jd d | j	 d S )Né    )ÚdatetimeÚtimezone)ÚZoneInfozAmerica/New_Yorké	   é<   é   )
r   r   Úzoneinfor   Ú
isinstanceÚfromtimestampÚutcÚ
astimezoneÚhourÚminute)Útr   r   r   © r#   úr7_setup.pyÚ_minute   s   
r%   Nc                    sˆ  i t ¥|pi ¥}|pi }tˆ ƒ}||d k s ||d ks |dk r$di fS | d¡r8| d¡r8|d |d  d nd }|s@di fS |d |d	 }}ˆ d
 d }	tttd
|d |d  ƒ|d ƒƒ}
t|
‡ fdd„d�}ˆ | d }|tdd„ ˆ d |d … D ƒƒk rˆdddifS ||	 d d }|t|d |d | ƒk r¨ddd|d›d�ifS ˆ |d |d … ˆ d g }tdd„ |D ƒƒ}tdd„ ˆ d |d … D ƒƒ}|| d d }|t|d |d | ƒk rïddd |d›d!�ifS || |d" ||  k�rddd#|| ||  d$›d%�ifS ||k�rddd&ifS || ||  }ˆ d d' }|ˆ d( d' k�s=|�r=|| | |d) k �rCddd*ifS td+d„ ˆ D ƒƒ}td,d„ ˆ D ƒƒ}|�r\|| n|}||	 d d |d- k�sx|| d d |d. k�r“ddd/||	 d d d0›d1|| d d d0›d2�ifS || d d |d3 k �r±ddd4|| d d d0›d5�ifS |ˆ d d  d d |d6 k �r×ddd7|ˆ d d  d d d8›d5�ifS || d d }||d9 k �rñddd:|d›d;�ifS td<d„ ˆ d=d … D ƒƒd> |d? k �rddd@ifS dA|tˆ |t|ƒ dBdC„ |D ƒ 	|¡  dD ƒ|t
|dEƒ|t
|dEƒt
||	 d d dEƒt
|| d d dEƒdFœfS )GNr   r   é   FÚatr14Ú
prev_closeéd   ÚbuyÚsellr   Úoé   r   c                    s   ˆ |  d S )NÚhr#   )Új©Údoner#   r$   Ú<lambda>0   s    zcheck.<locals>.<lambda>)Úkeyr.   c                 s   ó   � | ]}|d  V  qdS )r.   Nr#   ©Ú.0Úxr#   r#   r$   Ú	<genexpr>2   ó   € zcheck.<locals>.<genexpr>Úwhy_notz1 not at the day highr   r   z1 no uptrend (z.1fz% over the open)éÿÿÿÿc                 s   r4   ©ÚlNr#   r5   r#   r#   r$   r8   9   r9   c                 s   r4   r<   r#   r5   r#   r#   r$   r8   :   r9   r   r   z2 pullback z% too smallr   z2 pullback too deep (z.0%z of the climb)z3 no higher lowÚcéþÿÿÿr   z4 no turn barc                 s   s4   � | ]}|d  |d  |d  d |d  V  qdS )r.   r=   r>   é   ÚvNr#   r5   r#   r#   r$   r8   I   s   €2 c                 s   r4   ©rA   Nr#   r5   r#   r#   r$   r8   I   r9   r	   r
   z5 extended (z+.1fz% open, z% VWAP)r   z7 under VWAP (z%)r   z8 weak turn bar (z+.2fr   z6 room ú%c                 s   r4   rB   r#   r5   r#   r#   r$   r8   T   r9   éûÿÿÿé   r   ÚthinTc                 S   s   g | ]}|d  ‘qS )r=   r#   r5   r#   r#   r$   Ú
<listcomp>V   s    zcheck.<locals>.<listcomp>r"   é   )ÚsupportÚ	support_mÚhighÚpullbackÚmorning_lowÚroomÚvs_openÚvs_vwap)ÚDEFAULTSÚlenÚgetÚlistÚrangeÚmaxÚminÚsumr%   ÚindexÚround)r1   ÚflowÚrefÚmr>   ÚnÚatrpÚfbÚfsÚOÚwinÚjhÚHÚclimbÚafterÚpblÚmlowÚpbÚt_ÚPÚpvÚcvÚvwaprN   r#   r0   r$   Úcheck#   sb    ,$""
.$46""*(.(þrp   )N)Ú__doc__rQ   r%   rp   r#   r#   r#   r$   Ú<module>   s0    &ÿÿÿÿÿÿþþýý	