90 lines
3.3 KiB
Python
90 lines
3.3 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Demo: Data Stream Monitor for Model Input Capture
|
|
|
|
This script demonstrates how to use the DataStreamMonitor to capture
|
|
and stream all model input data in console-friendly text format.
|
|
|
|
Run this while the dashboard is running to see real-time data streaming.
|
|
"""
|
|
|
|
import sys
|
|
import time
|
|
from pathlib import Path
|
|
|
|
# Add project root to path
|
|
project_root = Path(__file__).resolve().parent
|
|
sys.path.insert(0, str(project_root))
|
|
|
|
def main():
|
|
print("=" * 80)
|
|
print("DATA STREAM MONITOR DEMO")
|
|
print("=" * 80)
|
|
print()
|
|
|
|
print("This demo shows how to control the data streaming system.")
|
|
print("Make sure the dashboard is running first with:")
|
|
print(" source venv/bin/activate && python run_clean_dashboard.py")
|
|
print()
|
|
|
|
print("Available commands:")
|
|
print("1. Start streaming: python data_stream_control.py start")
|
|
print("2. Stop streaming: python data_stream_control.py stop")
|
|
print("3. Save snapshot: python data_stream_control.py snapshot")
|
|
print("4. Switch to compact: python data_stream_control.py compact")
|
|
print("5. Switch to detailed: python data_stream_control.py detailed")
|
|
print("6. Check status: python data_stream_control.py status")
|
|
print()
|
|
|
|
print("Data streams captured:")
|
|
print("• OHLCV data (1m, 5m, 15m timeframes)")
|
|
print("• Real-time tick data")
|
|
print("• COB (Consolidated Order Book) data")
|
|
print("• Technical indicators")
|
|
print("• Model state vectors for each model")
|
|
print("• Recent predictions from all models")
|
|
print("• Training experiences and rewards")
|
|
print()
|
|
|
|
print("Output formats:")
|
|
print("• Detailed: Human-readable format with sections")
|
|
print("• Compact: JSON format for programmatic processing")
|
|
print()
|
|
|
|
print("""
|
|
================================================================================
|
|
DATA STREAM DEMO
|
|
================================================================================
|
|
|
|
The data stream is now managed by the TradingOrchestrator and starts
|
|
automatically when you run the dashboard:
|
|
|
|
python run_clean_dashboard.py
|
|
|
|
You should see periodic data samples in the dashboard console.
|
|
|
|
================================================================================
|
|
DATA STREAM SAMPLE - 14:30:15
|
|
================================================================================
|
|
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
|
|
COB: ETH/USDT | Imbalance:0.234 Spread:2.3bps Mid:4336.67
|
|
DQN State: 15 features | Price:4336.67
|
|
DQN Prediction: BUY (conf:0.78)
|
|
Training Exp: Action:1 Reward:0.0234 Done:False
|
|
================================================================================
|
|
""")
|
|
|
|
print("Example console output (Compact format):")
|
|
print('DATA_STREAM: {"timestamp":"2024-01-15T14:30:15","ohlcv_count":5,"ticks_count":12,"cob_count":8,"predictions_count":3,"experiences_count":7,"price":4336.67,"volume":125.8,"imbalance":0.234,"spread_bps":2.3}')
|
|
print()
|
|
|
|
print("To start streaming, run:")
|
|
print(" python data_stream_control.py start")
|
|
print()
|
|
print("The streaming will continue until you stop it with:")
|
|
print(" python data_stream_control.py stop")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|