
    i                     <    d Z ddlZddlmZ d Zedk(  r e        yy)u+   
Test FreqAI avec données réelles du bot
    N)get_freqai_managerc            	      2   t        d       t        d       t        d       t               } | st        d       y t        d       d}g }g }t        j                  j	                  d       t        d      D ]r  }t        j                  j                  dd	      }|d
|z   z  }|j                  |       dd
t        j                  j                  dd      z   z  }|j                  |       t t        d       t        d       t        d       | j                  d||ddd      \  }}t        dt        j                  |      d       t        dt        j                  |      d       t        dt        j                  |      d       t        d|dd          t        d|rdnd        |rLt        dt        |dd              t        d t        |d!d      d       t        d"t        |d#d              t        d$       t        d%       t        d       |j                         }	|	d&   d'z  |	d&<   | j                  d(||	d)d*d      \  }}t        d+t        j                  |	d d&       d       t        d,|	d&   d       t        d-|	d&   t        j                  |	d d&       z  d.d/       t        d|rdnd        |rit        dt        |dd              t        d t        |d!d      d       t        d"t        |d#d              t        |d0d       }
|
rt        d1|
        t        d$       t        d2       t        d       |j                         }|d3   d4z  |d&<   |j                         }|d&   d5z  |d&<   | j                  d6||d7d8d      \  }}t        d9|d3   d       t        d:|d&   d       t        d;|d&   |d3   z  d
z
  dz  d.d<       t        d=|d&   t        j                  |d d&       z  d.d/       t        d|rdnd        |rit        dt        |dd              t        d t        |d!d      d       t        d"t        |d#d              t        |d0d       }
|
rt        d1|
        t        d$       t        d>       t        d       |j                         }|d3   d?z  |d&<   |j                         }|d&   d@z  |d&<   | j                  dA||dBdCd      \  }}t        d9|d3   d       t        d:|d&   d       t        dD|d&   |d3   z  d
z
  dz  d.d<       t        d=|d&   t        j                  |d d&       z  d.d/       t        d|rdnd        |rit        dt        |dd              t        d t        |d!d      d       t        d"t        |d#d              t        |d0d       }
|
rt        d1|
        t        d$       t        dE       t        d       t        dF       y )GNzF======================================================================u&   🧪 TEST FREQAI - DONNÉES RÉALISTESu!   ❌ FreqAI Manager non disponibleu    
✅ FreqAI Manager initialisé
d   *   2   r   g{Gz?   i  g?u   📊 TEST 1: 50 points normaux
NORMALCOINg      J@g?T)symbolpricesvolumesrsibb_positionblock_on_outlierz   Prix moyen: z.2fu      Prix écart-type: z   Volume moyen: z.0fz   Derniers prix: u   
   Résultat: u   🚫 BLOQUÉu   ✅ AUTORISÉu      Méthode: methodzN/Az
   Score: scorez   Raison: reasonzG
======================================================================u5   📊 TEST 2: 49 points normaux + 1 VOLUME SPIKE (15x)   VOLUMESPIKEg      Q@g      ?z   Volume normal: z   Volume actuel: z
   Ratio: z.1fxdetailsu      Détails: u*   📊 TEST 3: 49 points normaux + PUMP +25%g      ?   PUMPCOINg      V@g?u      Prix précédent: z   Prix actuel: z   Variation: +%z   Volume: u+   📊 TEST 4: 49 points normaux + CRASH -20%g?
   	CRASHCOINg      (@g333333ӿz   Variation: u   📊 RÉSUMÉu  
Le système FreqAI a besoin d'au moins 30 points de données pour détecter les outliers.

✅ FONCTIONNALITÉS ACTIVES:
   • Isolation Forest (sklearn)
   • Z-Score sur prix et volumes
   • Détection volume spike (>5x)
   • Détection flash crash
   • Détection pump & dump

🎯 PROTECTION EN TEMPS RÉEL:
   Le bot accumule les données de chaque symbole.
   Dès 30+ points, FreqAI bloque automatiquement les trades suspects.
    )printr   nprandomseedrangenormalappendshould_check_outliersmeanstdgetattrcopy)manager
base_pricenormal_pricesnormal_volumesichangevolumeshould_blockanalysisspike_volumesr   pump_pricespump_volumescrash_pricescrash_volumess                  ./test_freqai_realtime.pytest_with_realistic_datar:      s   	&M	
23	&M "G12	
./ JMNIINN22Y &!!!T*1v:.
Z( RYY--a556f%& 
&M	
*+	&M$:: ; L( 
OBGGM237
89	!"&&"7!<
=>	bggn5c:
;<	}RS12
34	|^Q
RSgh%@ABC
78Wa8=>?GHh>?@A 
-	
AB	&M"'')M%b)B.M"$:: ; L( 
rww}Sb'9:3?
@A	}R05
67	J}R(s1C)DDSI
KL	|^Q
RSgh%@ABC
78Wa8=>?GHh>?@A(It4M'+, 
-	
67	&M$$&K!"o,KO!&&(L#B'!+L$:: ; L( 
!+b/#!6
78	[_S1
23	Ok"ok"o=a?DcJ!
LM	KR(cr1B)CCCH
JK	|^Q
RSgh%@ABC
78Wa8=>?GHh>?@A(It4M'+, 
-	
78	&M %%'L#B'$.L"'')M%b)B.M"$:: ; L( 
!,r"23!7
89	\"-c2
34	N\"-l2.>>q@#EsK1
MN	Kb)"''-2D*EEcJ!
LM	|^Q
RSgh%@ABC
78Wa8=>?GHh>?@A(It4M'+, 
-	/	&M	  	    __main__)__doc__numpyr    freqai_integrationr   r:   __name__ r;   r9   <module>rB      s.     1h	T z r;   