API Reference

l2_book.proto

syntax = "proto3";

package liquidityTech.md;

option go_package = "md/pb";

message L2BookProto {
    enum Exchange
    {
      EXCHANGE_NONE = 0;
      BINANCE_SPOT = 1;     // Binance Spot
      BINANCE_USDM = 2;     // Binance USD margin
      BINANCE_COINM = 3;    // Binance Coin margi
      OKX = 4;  
      BITMEX = 5;
      DERIBIT = 6;
      BYBIT_SPOT = 7;
      BYBIT_LINEAR = 8;
      BYBIT_INVERSE = 9;
      BYBIT_OPTION = 10;
      KUCOIN_SPOT = 11;
      KUCOIN_FUTURES = 12;
      GATE_SPOT = 13;
      GATE_PERPETUAL = 14;
      GATE_DELIVERY = 15;
      GATE_OPTION = 16;
      COINBASE = 17;
      EXCHANGE_COUNT = 18;
    }
  
    enum Side
    {
      BUY = 0;    
      SELL = 1;   
      SIDE_NONE = 2;
    }
    // Trading State
    enum TradingState
    {
      NORMAL = 0; // Normal trading
      CLOSE = 1;  // Stop trading
    }

    // Update Type
    enum UpdateType
    {
      ADD = 0;    // Quantity of a level increases
      DELETE = 1; // Quantity of a level decreases
      MODIFY = 2;
      TRADE = 3;  // Trade update
      UPDATE_TYPE_NONE = 4;
    }

    message PriceLevel{
        double price = 1;   // Price
        double qty = 2;     // Quantity
    }
    
    message Update{
        double price = 1;     // Price
        double qty = 2;       // Quantity
        Side side = 3;        // Buy or sell direction. passive side for trade
        UpdateType type = 4;  // UpdateType Type, see UpdateType
        uint32 level = 5;     // Level of the order book
    }

    uint64 exchange_ts = 1;               // Exchange timestamp
    uint64 local_ts = 2;                  // Local timestamp
    /**
     * Binance: 
     * 0 for trades, 
     * 1 for ticker, 
     * 2 for depth_5, 
     * 3 for depth_10, 
     * 4 for depth_20, 
     * 5 for full_depth
     * 
     * OKX:
     * 0 for trades, 
     * 1 for ticker, 
     * 2 for depth_1, 
     * 3 for depth_5, 
     * 4 for full_depth
     *
     * Bybit:
     * 0 for trades, 
     * 1 for ticker, 
     * 2 for depth_1, 
     * 3 for depth_25, 
     * 4 for depth_50, 
     * 5 for depth_100, 
     * 6 for depth_200, 
     * 7 for depth_500,
     * 8 for full_depth
     */ 
    uint64 seq_num = 3;// Message sequence number channel_id * 1e18 + exchange_seq_num. 
    double ltp = 4;    // Last traded price
    double ttv = 5;    // Total traded volume (price * quantity) since RapidMarket starts
    double ttq = 6;    // Total traded quantity since RapidMarket starts
    string symbol = 7;                    // Trading symbol
    uint32 book_id = 8;                   // currently not used and set to 0
    Exchange exchange = 9;                // Exchange
    TradingState trading_state = 10;      // Trading state
    repeated PriceLevel levels_bids = 11; // Bid levels, up to 50 levels
    repeated PriceLevel levels_asks = 12; // Ask levels, up to 50 levels
    repeated Update updates = 13;         // Updates, up to 50 items
}