Initial commit - AHAD QUANT v1
This commit is contained in:
@@ -0,0 +1,165 @@
|
||||
@echo off
|
||||
title AHAD QUANT - Lancement
|
||||
color 0A
|
||||
|
||||
echo.
|
||||
echo ##############################################################
|
||||
echo AHAD QUANT - Forex AI Trading Bot
|
||||
echo (Lanceur v2 - installe TOUTES les dependances)
|
||||
echo ##############################################################
|
||||
echo.
|
||||
|
||||
cd /d "%~dp0"
|
||||
|
||||
:: ---------------------------------------------------------------------
|
||||
:: 1. Verifier que Python est disponible
|
||||
:: ---------------------------------------------------------------------
|
||||
python --version >nul 2>&1
|
||||
if errorlevel 1 goto :err_python
|
||||
echo [OK] Python detecte.
|
||||
echo.
|
||||
goto :check_files
|
||||
|
||||
:err_python
|
||||
echo [ERREUR] Python non trouve dans le PATH.
|
||||
echo Installe Python 3.10+ depuis https://python.org
|
||||
echo (coche bien "Add Python to PATH" pendant l'installation)
|
||||
pause
|
||||
exit /b 1
|
||||
|
||||
:: ---------------------------------------------------------------------
|
||||
:: 2. Verifier la presence des fichiers necessaires
|
||||
:: ---------------------------------------------------------------------
|
||||
:check_files
|
||||
if not exist "web_ui.py" goto :err_webui
|
||||
if not exist "requirements.txt" goto :err_reqs
|
||||
goto :setup_env
|
||||
|
||||
:err_webui
|
||||
echo [ERREUR] web_ui.py introuvable dans ce dossier.
|
||||
echo Place ce script dans le meme dossier que web_ui.py.
|
||||
pause
|
||||
exit /b 1
|
||||
|
||||
:err_reqs
|
||||
echo [ERREUR] requirements.txt introuvable dans ce dossier.
|
||||
pause
|
||||
exit /b 1
|
||||
|
||||
:: ---------------------------------------------------------------------
|
||||
:: 3. Copier .env.example vers .env si .env n'existe pas encore
|
||||
:: ---------------------------------------------------------------------
|
||||
:setup_env
|
||||
if exist ".env" goto :check_deps
|
||||
if not exist ".env.example" goto :check_deps
|
||||
echo [INFO] Aucun .env trouve - creation a partir de .env.example.
|
||||
copy /y ".env.example" ".env" >nul
|
||||
echo [INFO] Pense a verifier/adapter .env si besoin (onglet Config).
|
||||
echo.
|
||||
|
||||
:: ---------------------------------------------------------------------
|
||||
:: 4. Installer TOUTES les dependances de requirements.txt
|
||||
:: On ne reinstalle que si requirements.txt a change depuis la
|
||||
:: derniere fois (marqueur), pour ne pas perdre de temps a chaque
|
||||
:: lancement une fois que tout est deja installe.
|
||||
:: ---------------------------------------------------------------------
|
||||
:check_deps
|
||||
set "MARKER=.last_requirements_installed.txt"
|
||||
set "NEED_INSTALL=0"
|
||||
|
||||
if not exist "%MARKER%" set "NEED_INSTALL=1"
|
||||
if "%NEED_INSTALL%"=="1" goto :do_install
|
||||
|
||||
fc "requirements.txt" "%MARKER%" >nul 2>&1
|
||||
if errorlevel 1 set "NEED_INSTALL=1"
|
||||
if "%NEED_INSTALL%"=="1" goto :do_install
|
||||
|
||||
echo [1/3] Dependances deja installees (requirements.txt inchange).
|
||||
python -c "import fastapi, uvicorn" >nul 2>&1
|
||||
if errorlevel 1 goto :do_install
|
||||
echo [1/3] OK
|
||||
goto :launch_server
|
||||
|
||||
:do_install
|
||||
echo [1/3] Installation COMPLETE des dependances (requirements.txt)...
|
||||
echo lightgbm, xgboost, scikit-learn, torch, stable-baselines3,
|
||||
echo gymnasium, fastapi, uvicorn, watchdog, optuna, etc.
|
||||
echo.
|
||||
echo Premiere installation : 5 a 20 minutes selon la connexion
|
||||
echo (torch et stable-baselines3[extra] sont volumineux).
|
||||
echo Les lancements suivants seront quasi instantanes.
|
||||
echo.
|
||||
|
||||
python -m pip install --upgrade pip --quiet
|
||||
|
||||
python -m pip install -r requirements.txt
|
||||
if errorlevel 1 goto :err_install
|
||||
|
||||
copy /y "requirements.txt" "%MARKER%" >nul
|
||||
echo.
|
||||
echo [1/3] Toutes les dependances sont installees.
|
||||
goto :launch_server
|
||||
|
||||
:err_install
|
||||
echo.
|
||||
echo [ERREUR] L'installation des dependances a echoue.
|
||||
echo Causes possibles : pas de connexion internet, pip trop ancien,
|
||||
echo ou un paquet incompatible avec ta version de Python/Windows.
|
||||
echo.
|
||||
echo Relance manuellement pour voir le detail de l'erreur :
|
||||
echo pip install -r requirements.txt
|
||||
pause
|
||||
exit /b 1
|
||||
|
||||
:: ---------------------------------------------------------------------
|
||||
:: 5. Lancer web_ui.py en arriere-plan
|
||||
:: ---------------------------------------------------------------------
|
||||
:launch_server
|
||||
echo.
|
||||
echo [2/3] Demarrage de l'interface web...
|
||||
start "AHAD QUANT Server" /min python web_ui.py
|
||||
|
||||
:: ---------------------------------------------------------------------
|
||||
:: 6. Attendre que le serveur reponde reellement (sans goto imbrique
|
||||
:: dans une boucle for - structure classique avec labels, plus sure
|
||||
:: sur tous les Windows)
|
||||
:: ---------------------------------------------------------------------
|
||||
echo [3/3] Attente du demarrage du serveur...
|
||||
set "WAITCOUNT=0"
|
||||
|
||||
:wait_loop
|
||||
curl -s -o nul http://localhost:8080 >nul 2>&1
|
||||
if not errorlevel 1 goto :server_ready
|
||||
set /a WAITCOUNT+=1
|
||||
if %WAITCOUNT% GEQ 30 goto :wait_timeout
|
||||
timeout /t 1 /nobreak >nul
|
||||
goto :wait_loop
|
||||
|
||||
:wait_timeout
|
||||
echo [3/3] Le serveur met du temps a repondre - ouverture quand meme.
|
||||
echo Si la page ne charge pas, attends et rafraichis le navigateur.
|
||||
goto :open_browser
|
||||
|
||||
:server_ready
|
||||
echo [3/3] Serveur pret.
|
||||
|
||||
:open_browser
|
||||
start http://localhost:8080
|
||||
|
||||
echo.
|
||||
echo ================================================================
|
||||
echo Interface disponible sur : http://localhost:8080
|
||||
echo Ferme cette fenetre pour ARRETER le serveur.
|
||||
echo ================================================================
|
||||
echo.
|
||||
echo Appuie sur une touche pour arreter AHAD QUANT...
|
||||
pause >nul
|
||||
|
||||
:: ---------------------------------------------------------------------
|
||||
:: 7. Arreter le serveur a la fermeture
|
||||
:: ---------------------------------------------------------------------
|
||||
echo Arret en cours...
|
||||
taskkill /f /fi "WINDOWTITLE eq AHAD QUANT Server" >nul 2>&1
|
||||
taskkill /f /im python.exe /fi "WINDOWTITLE eq AHAD QUANT Server" >nul 2>&1
|
||||
echo AHAD QUANT arrete. Au revoir.
|
||||
timeout /t 2 /nobreak >nul
|
||||
Reference in New Issue
Block a user