# Multi-Asset Order Flow Visualizer

## 🎯 What This Does

Visualize **order flow anomalies** across multiple crypto assets in real-time:
- **Bitcoin (BTC/USDT)**
- **Ethereum (ETH/USDT)**
- **Gold (XAU/USDT)**

## 📊 Features

### 1. Order Book Visualization
- **Bids (buyers)** in green
- **Asks (sellers)** in red
- **Spread** calculation
- Top 10 price levels

### 2. Trading Signals
- **ABSORPTION** ⭐ (highest quality)
- **SQUEEZE** (coiled spring)
- **EXHAUSTION** (reversal play)

### 3. Multi-Asset Comparison
- Switch between BTC, ETH, Gold
- Compare signals across assets
- Find best opportunities

## 🚀 Quick Start

### Option 1: Collect Live Data (Recommended)

```bash
# Collect 60s of data + generate signals
./scripts/run_multi_asset_collector.sh
```

This will:
1. Connect to Binance WebSocket
2. Collect order book snapshots for BTC, ETH, Gold
3. Generate trading signals
4. Update the visualizer UI

### Option 2: View Existing Data

If you already have Gold signals:

```bash
# Start web server
python3 scripts/serve_ui.py
```

Then open: http://localhost:8080/multi_asset_visualizer.html

## 📖 How to Use

1. **Select Asset** (BTC/ETH/Gold buttons)
2. **View Order Book** (bids/asks, spread)
3. **Check Signals** (entry/target/stop, confidence)
4. **Filter** by type, direction, confidence

## 🎨 Signal Cards

Each signal card shows:
- **Type**: ABSORPTION/SQUEEZE/EXHAUSTION
- **Direction**: Bullish (green) / Bearish (red)
- **Entry/Target/Stop**: Price levels
- **Confidence**: 0-100%
- **Risk-Reward**: Ratio (e.g., 4.0)

## 🔧 Scripts

- `collect_multi_asset.py` - WebSocket collector
- `generate_multi_asset_signals.py` - Signal generator
- `run_multi_asset_collector.sh` - All-in-one runner
- `serve_ui.py` - Web server

## 📁 Data Files

```
data/
├── binance_multi_asset.db          # Order book snapshots
└── signals_*.json                   # Trading signals per asset

outputs/
├── data/signals_*.json             # UI data files
└── multi_asset_visualizer.html     # Main UI
```

## 🎯 Next Steps

1. **Run collector**: `./scripts/run_multi_asset_collector.sh`
2. **Open UI**: http://localhost:8080/multi_asset_visualizer.html
3. **Explore signals** across BTC, ETH, Gold

## 📌 Notes

- **Data freshness**: Signals are only as fresh as the last collection
- **Price tolerance**: Auto-filters signals ±$20 from current price
- **Collection time**: 60 seconds default (adjust in script)

## 🚨 Trading Warning

This is a **visualizer** for educational purposes. Not financial advice!

- Start with paper trading
- Verify signals with other indicators
- Use proper risk management
- Never risk more than 1-2% per trade

---

**Happy Visualizing!** 📊
