data stream working

This commit is contained in:
Dobromir Popov
2025-09-02 17:59:12 +03:00
parent 8068e554f3
commit c55175c44d
8 changed files with 1000 additions and 132 deletions

View File

@@ -7,6 +7,16 @@
python check_stream.py status
```
### Show OHLCV Data with Indicators
```bash
python check_stream.py ohlcv
```
### Show COB Data with Price Buckets
```bash
python check_stream.py cob
```
### Generate Snapshot
```bash
python check_stream.py snapshot
@@ -16,58 +26,79 @@ python check_stream.py snapshot
### Stream Status Output
- ✅ Dashboard is running
- 💡 Guidance message
- 📝 Data stream location note
- Console output examples to look for
- 📊 Health status
- 🔄 Stream connection and streaming status
- 📈 Total samples and active streams
- 🟢/🔴 Buffer sizes for each data type
### OHLCV Data Output
- 📊 Data for 1s, 1m, 1h, 1d timeframes
- Records count and latest timestamp
- Current price and technical indicators:
- RSI (Relative Strength Index)
- MACD (Moving Average Convergence Divergence)
- SMA20 (Simple Moving Average 20-period)
### COB Data Output
- 📊 Order book data with price buckets
- Mid price, spread, and imbalance
- Price buckets in $1 increments
- Bid/ask volumes for each bucket
### Snapshot Output
- ✅ Snapshot saved: `data_snapshots/snapshot_YYYYMMDD_HHMMSS.json`
- 📝 Note about data location
- ✅ Snapshot saved with filepath
- 📅 Timestamp of creation
## How It Works
## API Endpoints
The script connects to your **running dashboard** instead of creating a new instance:
The dashboard exposes these REST API endpoints:
1. **Checks if dashboard is running** at `http://127.0.0.1:8050`
2. **Provides guidance** on where to find the data stream
3. **Generates snapshots** with current timestamp and metadata
- `GET /api/health` - Health check
- `GET /api/stream-status` - Data stream status
- `GET /api/ohlcv-data?symbol=ETH/USDT&timeframe=1m&limit=300` - OHLCV data with indicators
- `GET /api/cob-data?symbol=ETH/USDT&limit=300` - COB data with price buckets
- `POST /api/snapshot` - Generate data snapshot
## Where to Find Live Data
## Data Available
The **data stream is active inside the dashboard console**. Look for output like:
### OHLCV Data (300 points each)
- **1s**: Real-time tick data
- **1m**: 1-minute candlesticks
- **1h**: 1-hour candlesticks
- **1d**: Daily candlesticks
```
OHLCV (1m): ETH/USDT | O:4335.67 H:4338.92 L:4334.21 C:4336.67 V:125.8
TICK: ETH/USDT | Price:4336.67 Vol:0.0456 Side:buy
DQN Prediction: BUY (conf:0.78)
Training Exp: Action:1 Reward:0.0234 Done:False
```
### Technical Indicators
- SMA (Simple Moving Average) 20, 50
- EMA (Exponential Moving Average) 12, 26
- RSI (Relative Strength Index)
- MACD (Moving Average Convergence Divergence)
- Bollinger Bands (Upper, Middle, Lower)
- Volume ratio
### COB Data (300 points)
- **Price buckets**: $1 increments around mid price
- **Order book levels**: Bid/ask volumes and counts
- **Market microstructure**: Spread, imbalance, total volumes
## When Data Appears
Data will show in the dashboard console when:
1. **Market data is flowing** (OHLCV, ticks, COB)
2. **Models are making predictions**
3. **Training is active**
## Snapshot Contents
Snapshots contain:
- Timestamp
- Dashboard status
- Empty data arrays (data is in dashboard console)
- Note about checking console for live data
Data will be available when:
1. **Dashboard is running** (`python run_clean_dashboard.py`)
2. **Market data is flowing** (OHLCV, ticks, COB)
3. **Models are making predictions**
4. **Training is active**
## Usage Tips
- **Start dashboard first**: `python run_clean_dashboard.py`
- **Check status** to confirm dashboard is running
- **Watch dashboard console** for live data stream
- **Generate snapshots** to capture timestamps and metadata
- **Check status** to confirm data is flowing
- **Use OHLCV command** to see price data with indicators
- **Use COB command** to see order book microstructure
- **Generate snapshots** to capture current state
- **Wait for market activity** to see data populate
## Files Created
- `check_stream.py` - Status and snapshot commands
- `check_stream.py` - API client for data access
- `data_snapshots/` - Directory for saved snapshots
- `snapshot_*.json` - Timestamped snapshot files with metadata
- `snapshot_*.json` - Timestamped snapshot files with full data