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 margin
OKX = 4; // OKX
BITMEX;
DERIBIT;
BYBIT_SPOT;
BYBIT_LINEAR;
BYBIT_INVERSE;
BYBIT_OPTION;
KUCOIN_SPOT;
KUCOIN_FUTURES;
GATE_SPOT;
GATE_PERPETUAL;
GATE_DELIVERY;
GATE_OPTION;
COINBASE;
EXCHANGE_COUNT
}
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
uint64 seq_num = 3; // Message sequence number channel_id * 1e18 + exchange_seq_num.
// For Binance, the channel_id is 0 for trades, 1 for ticker, 2 for depth_5, 3 for depth_10, 4 for depth_20, 5 for full_depth
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
}