Spaces:
Sleeping

File size: 706 Bytes
abc5564
 
 
9dc4124
abc5564
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9dc4124
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
import json
import os

MEMORY_FILE = "/tmp/memory.json"  # ✅ writable path on HF

def load_history():
    if os.path.exists(MEMORY_FILE):
        with open(MEMORY_FILE, "r") as f:
            return json.load(f)
    return []

def save_history(history):
    with open(MEMORY_FILE, "w") as f:
        json.dump(history, f)

def detect_trend(price):
    history = load_history()
    history.append(price)
    history = history[-5:]
    save_history(history)

    if len(history) < 5:
        return "⏳ Gathering..."
    if price > max(history[:-1]):
        return "📈 Leg Up Detected"
    elif price < min(history[:-1]):
        return "📉 Leg Down Forming"
    else:
        return "📊 Sideways"