File size: 1,648 Bytes
fb03795
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python3
"""Standalone test of AI fallback logic (no Gradio imports)"""

def test_ai_fallback():
    """Test the fallback logic that will run on HF Space"""
    
    test_cases = [
        {
            "name": "Strong Bullish (should LONG)",
            "change_24h": 5.5,
            "rsi": 65,
            "trend": "UP"
        },
        {
            "name": "Strong Bearish (should SHORT)",
            "change_24h": -4.2,
            "rsi": 35,
            "trend": "DOWN"
        },
        {
            "name": "Neutral (should HOLD)",
            "change_24h": 0.5,
            "rsi": 50,
            "trend": "NEUTRAL"
        }
    ]
    
    print("="*60)
    print("Testing AI Fallback Logic")
    print("="*60)
    
    for test in test_cases:
        print(f"\n{test['name']}")
        print(f"  Change: {test['change_24h']}%, RSI: {test['rsi']}, Trend: {test['trend']}")
        
        # Simulate fallback logic from app.py
        change = test['change_24h']
        rsi = test['rsi']
        trend = test['trend']
        
        if change > 2 and rsi < 70 and trend == 'UP':
            decision = "Action: LONG | Reason: Strong upward momentum with healthy RSI"
        elif change < -2 and rsi > 30 and trend == 'DOWN':
            decision = "Action: SHORT | Reason: Downward trend with oversold conditions"
        else:
            decision = "Action: HOLD | Reason: Waiting for clearer market signal"
        
        print(f"  ✅ Decision: {decision}")
    
    print("\n" + "="*60)
    print("✅ All fallback logic tests passed!")
    print("="*60)

if __name__ == "__main__":
    test_ai_fallback()