Spaces:
Sleeping
Sleeping
Download trend_engine.py from Loading404/legion-ai: direct link, hf CLI and curl.
- Browser
- Download file 706 Bytes
-
https://huggingface.co/spaces/Loading404/legion-ai/resolve/main/trend_engine.py
- Command line
-
hf download hf://spaces/Loading404/legion-ai/trend_engine.py
-
curl -L -o trend_engine.py https://huggingface.co/spaces/Loading404/legion-ai/resolve/main/trend_engine.py
706 Bytes
| 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" | |