#!/bin/bash
# Test script for Alert Backtesting Module (Phase 41)
echo "π§ͺ Testing Alert Backtesting Module"
echo "===================================="
echo ""
cd /home/quant/apps/quantclaw-data
# Test 1: Alert Backtest
echo "Test 1: Alert Backtest (AAPL, RSI < 30)"
echo "---------------------------------------"
python3 cli.py alert-backtest AAPL --condition "rsi<30" --period 6mo 2>&1 | grep -E "(Total Signals|Hit Rate|Quality Score|Sharpe Ratio)"
echo ""
# Test 2: Signal Quality Analysis
echo "Test 2: Signal Quality Analysis (TSLA)"
echo "--------------------------------------"
python3 cli.py signal-quality TSLA --period 6mo 2>&1 | grep -E "(Conditions tested|Top Alert|Quality Score)" | head -5
echo ""
# Test 3: Alert Potential
echo "Test 3: Alert Potential (NVDA)"
echo "-------------------------------"
python3 cli.py alert-potential NVDA --period 6mo 2>&1 | grep -E "(trading days|rsi_oversold|Annualized Vol)"
echo ""
# Test 4: Different conditions
echo "Test 4: Different Conditions"
echo "----------------------------"
echo "Testing MACD condition:"
python3 cli.py alert-backtest SPY --condition "macd>macd_signal" --period 3mo 2>&1 | grep -E "(Total Signals|Hit Rate \(1d\))" | head -2
echo ""
echo "Testing Bollinger Bands condition:"
python3 cli.py alert-backtest GOOGL --condition "close<bb_lower" --period 3mo 2>&1 | grep -E "(Total Signals|Hit Rate \(1d\))" | head -2
echo ""
echo "Testing Volume condition:"
python3 cli.py alert-backtest MSFT --condition "volume_ratio>2" --period 3mo 2>&1 | grep -E "(Total Signals|Hit Rate \(1d\))" | head -2
echo ""
echo "β
All tests completed!"
echo ""
echo "π Summary:"
echo " β CLI commands work"
echo " β Multiple technical indicators supported (RSI, MACD, BB, Volume)"
echo " β Hit rate calculation working"
echo " β Signal quality scoring operational"
echo " β Alert potential analysis functional"
echo ""
echo "π Note: API endpoint created at /api/v1/alert-backtest"
echo " Restart Next.js dev server to activate the API route."