Skip to content

Data Flow

Binance CLOB Pipeline

sequenceDiagram
    participant Binance
    participant WSM as WebSocketManager
    participant API as API Gateway
    participant Store as State Store
    participant WM as WorkManager

    Binance->>WSM: depthUpdate (100ms)
    WSM->>API: SaveState (every 10s)
    API->>Store: btcusdt-orderbook
    Note over WSM: Also publishes to Dapr pub/sub

    loop Every 2s
        WM->>API: GetState
        API->>Store: query
        Store-->>API: latest snapshot
        API-->>WM: order book data
        WM->>WM: Calculate imbalance
    end

State Keys

Key Written By Content
examples/btcusdt-orderbook binance_clob_example.py Top 20 bids/asks + spread
examples/btcusd-orderbook alpaca_clob_example.py Top 20 bids/asks + spread
examples/btcusdt-imbalance orderflow_imbalance_worker.py Weighted imbalance + pressure signal

Pub/Sub Topics

Topic Publisher Subscribers
btcusdt-depth binance_clob_example.py Downstream consumers
btcusd-orderbook alpaca_clob_example.py Downstream consumers
btcusdt-imbalance (output target) Monitoring, trading systems