# 🌐 3D Order Flow Graph Visualization

## ✅ **COMPLETE! Interactive 3D Graph Ready**

### 🎯 **What You Can Do:**

**1. Explore Price Levels in 3D**
- 🟢 **Green spheres** = Buyers (bid volume > ask volume)
- 🔴 **Red spheres** = Sellers (ask volume > bid volume)
- 🟠 **Orange spheres** = High imbalance (> 2.0)
- 🔵 **Blue spheres** = Neutral market

**2. Interact with the Graph:**
- **Mouse drag** = Rotate camera
- **Scroll** = Zoom in/out
- **Hover** = See price level details
- **Auto-rotate** = Enabled by default

**3. Filter and Customize:**
- Choose asset (Gold/Bitcoin/Ethereum)
- Switch view modes (3D/2D/Force-directed)
- Filter by minimum volume
- Toggle buyers/sellers/signals/edges

**4. See Real-Time Statistics:**
- Total price levels
- Relationships between levels
- Buy/Sell volume
- Price range
- Market imbalance

---

## 🚀 **How to Access:**

**Direct URL:**
```
http://of.llm.astrona.me/outputs/order_flow_3d_visualizer.html
```

**From Main Dashboard:**
```
http://of.llm.astrona.me/outputs/main.html
```
Click the **🌐 3D Graph** button in the navigation bar.

---

## 📊 **Graph Data:**

### **Entities (Nodes):**
- **22,470** BTC price levels
- **14,595** ETH price levels
- **XAUTUSDT** Gold price levels

Each node shows:
- Price level
- Bid/Ask volume
- Total volume
- Imbalance ratio
- Wall strength
- Snapshots seen

### **Relationships (Edges):**
- **21,472** BTC relationships
- **14,522** ETH relationships
- **XAUTUSDT** Gold relationships

Edges connect adjacent price levels (within $10)

### **Trading Signals:**
- Top 10 signals per asset integrated into graph
- Connected to nearest price level
- Shows: Entry, Target, Stop, Confidence, Risk-Reward

---

## 🔧 **Technical Details:**

### **Frontend:**
- **Three.js** for 3D rendering
- **OrbitControls** for camera interaction
- **Raycaster** for mouse hover detection
- **Responsive design** with dark theme

### **Backend:**
- **SQLite** database with 24M+ order book levels
- **Python** graph builder (aggregates by price)
- **Auto-rebuilds** every 5 minutes (optional)
- **JSON** format for fast loading

### **File Locations:**
- Visualizer: `/outputs/order_flow_3d_visualizer.html`
- Graph data: `/data/order_flow_graph_3d_*.json`
- Builder script: `/scripts/build_3d_graph.py`
- Auto-rebuild: `/scripts/auto_rebuild_3d_graph.sh`

---

## 🎮 **Controls Reference:**

### **Mouse Controls:**
- **Left click + drag** = Rotate
- **Right click + drag** = Pan
- **Scroll wheel** = Zoom
- **Hover** = Show tooltip

### **UI Controls:**
- **Asset selector** = Switch between BTC/ETH/Gold
- **View mode** = 3D network / 2D price levels / Force-directed
- **Volume filter** = Show only high-volume levels
- **Checkboxes** = Toggle buyers/sellers/signals/edges
- **Reload button** = Rebuild graph from latest data
- **Reset camera** = Return to default view

---

## 📈 **Graph Metrics Explained:**

### **Imbalance:**
- Ratio of bid volume to ask volume
- > 2.0 = Strong buying pressure (orange)
- < 0.5 = Strong selling pressure (red)
- ~1.0 = Balanced market (blue/green)

### **Wall Strength:**
- Volume concentration at price level
- Higher = More orders at this level
- Indicates support/resistance

### **Persistence:**
- How often this level appears in snapshots
- Higher = More reliable level
- Shows market memory

---

## 🔄 **Updating the Graph:**

### **Manual Update:**
```bash
cd /home/ubuntu/.hermes/workspace/projects/ORDER_FLOW_GRAPH/scripts
python3 build_3d_graph.py
```

### **Auto-Update (Every 5 min):**
```bash
cd /home/ubuntu/.hermes/workspace/projects/ORDER_FLOW_GRAPH/scripts
./auto_rebuild_3d_graph.sh &
```

### **Via Web:**
Click the **🔄 Reload Graph** button in the visualizer (requires cron job setup)

---

## 🎯 **Use Cases:**

### **Pattern Discovery:**
- Find support/resistance levels
- Identify price clusters
- See market structure

### **Order Flow Analysis:**
- Track buyer/seller pressure
- Spot absorption zones
- Find breakout levels

### **Signal Validation:**
- Check if signals align with order flow
- See signal context in 3D
- Understand market state

### **Multi-Asset Comparison:**
- Compare BTC/ETH/Gold structures
- Find correlations
- Spot divergences

---

## ✅ **Status:**

**All systems operational:**
- ✅ 3D visualizer deployed
- ✅ Graph data built for all assets
- ✅ Navigation links added to all dashboards
- ✅ Real-time order book data flowing
- ✅ Trading signals integrated
- ✅ Interactive controls working

**Open your 3D graph now:** http://of.llm.astrona.me/outputs/order_flow_3d_visualizer.html

🌐 **Explore the market in 3D!** 🚀
