Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
193 lines (153 sloc) 4.39 KB
syntax = "proto3";
// Package ProtobufMarkets contains definitions for market update messages;
// the main wrapper messages is a MarketUpdateMessage.
package ProtobufMarkets;
// Market represents a currency pair on a particular exchange.
message Market {
// Prefer integer ids to string slugs (far fewer bytes)
uint64 exchangeId = 3;
uint64 currencyPairId = 4;
// New IDs from SQL; TODO remove 1,2,3,4 when migrationt o 5,6 is complete
uint64 marketId = 5;
// Deprecated
string exchange = 1;
string currencyPair = 2;
}
// Order represents an ask or a bid.
message Order {
string priceStr = 3;
string amountStr = 4;
// Deprecated
float price = 1;
float amount = 2;
}
// Trade is a single trade in TradesUpdate
message Trade {
// Exchange-specific ID
string externalId = 11;
int64 timestamp = 2;
int64 timestampMillis = 5;
int64 timestampNano = 10;
string priceStr = 8;
string amountStr = 9;
// Deprecated
float price = 3;
float amount = 4;
double priceDouble = 6;
double amountDouble = 7;
int64 id = 1;
}
// MarketUpdateMessage is the primary message for market updates; it wraps all
// other more specific update types.
message MarketUpdateMessage {
reserved 8;
Market market = 9;
oneof Update {
OrderBookUpdate orderBookUpdate = 2;
OrderBookDeltaUpdate orderBookDeltaUpdate = 3;
OrderBookSpreadUpdate orderBookSpreadUpdate = 11;
TradesUpdate tradesUpdate = 4;
IntervalsUpdate intervalsUpdate = 5;
SummaryUpdate summaryUpdate = 6;
SparklineUpdate sparklineUpdate = 7;
}
}
// OrderBookUpdate represents a snapshot of the order book: a set of asks and
// bids for the particular aggregation modulus.
message OrderBookUpdate {
// Aggregation modulus is a value which all bids and asks in this particular
// OrderBookUpdate are divisible by. E.g. could be 1 (no aggregation), 5, 10,
// 50, 100, etc. Exact possible values are set for each market individually.
string aggregationModulusStr = 4;
int32 seqNum = 5;
repeated Order bids = 1;
repeated Order asks = 2;
// Deprecated
float aggregationModulus = 3;
}
// OrderBookDeltaUpdate represents a delta which needs to be applied to the
// local order book.
message OrderBookDeltaUpdate {
// Aggregation modulus is a value which all bids and asks in this particular
// OrderBookUpdate are divisible by. E.g. could be 1 (no aggregation), 5, 10,
// 50, 100, etc. Exact possible values are set for each market individually.
float aggregationModulus = 3;
string aggregationModulusStr = 4;
int32 seqNum = 5;
message OrderDeltas {
// Either add a new order at a particular price, or replace existing one
// (with the new amount)
repeated Order set = 1;
// TODO: I see we don't really use deltas, and just use set?
repeated Order delta = 2;
// Remove order at a particular price
repeated float remove = 3 [packed = false];
repeated string removeStr = 4;
}
// Deltas for bids
OrderDeltas bids = 1;
// Deltas for asks
OrderDeltas asks = 2;
}
// OrderBookSpreadUpdate represents only the best bid & ask
message OrderBookSpreadUpdate {
int64 timestamp = 1;
Order bid = 2;
Order ask = 3;
}
// TradesUpdate represents a set of new trades.
message TradesUpdate {
repeated Trade trades = 1;
}
// Interval represents a single OHLC candle.
message Interval {
message OHLC {
string openStr = 5;
string highStr = 6;
string lowStr = 7;
string closeStr = 8;
// Deprecated
float open = 1;
float high = 2;
float low = 3;
float close = 4;
}
int64 closetime = 1;
int32 period = 4;
OHLC ohlc = 2;
string volumeBaseStr = 6;
string volumeQuoteStr = 7;
// Deprecated
float volumeBase = 3;
float volumeQuote = 5;
}
// IntervalsUpdate represents a set of new Intervals (OHLC candles)
message IntervalsUpdate {
repeated Interval intervals = 1;
}
// SummaryUpdate is a market summary update
message SummaryUpdate {
reserved 1;
string lastStr = 10;
string highStr = 11;
string lowStr = 12;
string volumeBaseStr = 13;
string volumeQuoteStr = 14;
string changeAbsoluteStr = 15;
string changePercentStr = 16;
int32 numTrades = 8;
// Deprecated
float last = 2;
float high = 3;
float low = 4;
float volumeBase = 5;
float volumeQuote = 9;
float changeAbsolute = 6;
float changePercent = 7;
}
message SparklineUpdate {
reserved 1;
int64 time = 2;
float price = 3;
string priceStr = 4;
}