bbgo_origin/pkg/pb/bbgo.proto

281 lines
5.6 KiB
Protocol Buffer
Raw Normal View History

2022-02-14 08:16:32 +00:00
syntax = "proto3";
2022-04-08 11:21:57 +00:00
package bbgo;
2022-02-14 08:16:32 +00:00
2022-02-18 06:26:48 +00:00
option go_package = "../pb";
2022-02-14 08:16:32 +00:00
2022-04-08 11:21:57 +00:00
service MarketDataService {
rpc Subscribe(SubscribeRequest) returns (stream MarketData) {}
2022-04-08 11:21:57 +00:00
rpc QueryKLines(QueryKLinesRequest) returns (QueryKLinesResponse) {}
}
service UserDataService {
rpc Subscribe(UserDataRequest) returns (stream UserData) {}
2022-04-08 11:21:57 +00:00
}
service TradingService {
// request-response
rpc SubmitOrder(SubmitOrderRequest) returns (SubmitOrderResponse) {}
rpc CancelOrder(CancelOrderRequest) returns (CancelOrderResponse) {}
rpc QueryOrder(QueryOrderRequest) returns (QueryOrderResponse) {}
rpc QueryOrders(QueryOrdersRequest) returns (QueryOrdersResponse) {}
rpc QueryTrades(QueryTradesRequest) returns (QueryTradesResponse) {}
2022-02-14 08:16:32 +00:00
}
2022-03-07 04:06:16 +00:00
enum Event {
2022-04-08 11:21:57 +00:00
UNKNOWN = 0;
SUBSCRIBED = 1;
UNSUBSCRIBED = 2;
SNAPSHOT = 3;
UPDATE = 4;
AUTHENTICATED = 5;
ERROR = 99;
2022-03-07 04:06:16 +00:00
}
enum Channel {
2022-04-08 11:21:57 +00:00
BOOK = 0;
TRADE = 1;
TICKER = 2;
KLINE = 3;
BALANCE = 4;
2022-04-13 07:29:23 +00:00
ORDER = 5;
2022-03-07 04:06:16 +00:00
}
enum Side {
2022-04-08 11:21:57 +00:00
BUY = 0;
SELL = 1;
2022-03-07 04:06:16 +00:00
}
enum OrderType {
2022-04-08 11:21:57 +00:00
MARKET = 0;
LIMIT = 1;
STOP_MARKET = 2;
STOP_LIMIT = 3;
POST_ONLY = 4;
IOC_LIMIT = 5;
2022-03-07 04:06:16 +00:00
}
2022-02-23 04:29:01 +00:00
message Empty {}
2022-02-23 04:41:11 +00:00
message Error {
2022-04-08 11:21:57 +00:00
int64 error_code = 1;
string error_message = 2;
2022-02-23 04:41:11 +00:00
}
message UserDataRequest {
string session = 1;
}
message UserData {
string session = 1;
string exchange = 2;
Channel channel = 3; // trade, order, balance
Event event = 4; // snapshot, update ...
repeated Balance balances = 5;
repeated Trade trades = 6;
repeated Order orders = 7;
}
2022-02-19 20:08:52 +00:00
message SubscribeRequest {
2022-04-08 11:21:57 +00:00
repeated Subscription subscriptions = 1;
2022-02-14 08:16:32 +00:00
}
2022-02-19 20:08:52 +00:00
message Subscription {
2022-04-08 11:21:57 +00:00
string exchange = 1;
Channel channel = 2; // book, trade, ticker
string symbol = 3;
2022-04-12 07:53:40 +00:00
string depth = 4; // depth is for book, valid values are full, medium, 1, 5 and 20
string interval = 5; // interval is for kline channel
2022-02-14 08:16:32 +00:00
}
message MarketData {
2022-04-12 08:55:42 +00:00
string session = 1;
string exchange = 2;
string symbol = 3;
Channel channel = 4; // book, trade, ticker, user
Event event = 5; // snapshot or update
2022-04-12 08:55:42 +00:00
Depth depth = 6; // depth: used by book
KLine kline = 7;
Ticker ticker = 9; // market ticker
repeated Trade trades = 8; // market trades
2022-04-12 08:55:42 +00:00
int64 subscribed_at = 12;
Error error = 13;
2022-02-23 04:19:23 +00:00
}
2022-04-12 08:55:42 +00:00
2022-02-23 04:19:23 +00:00
message Depth {
2022-04-08 11:21:57 +00:00
string exchange = 1;
string symbol = 2;
repeated PriceVolume asks = 3;
repeated PriceVolume bids = 4;
2022-02-14 08:16:32 +00:00
}
message PriceVolume {
2022-04-12 08:55:42 +00:00
string price = 1;
string volume = 2;
2022-02-14 08:16:32 +00:00
}
2022-02-19 20:08:52 +00:00
// https://maicoin.github.io/max-websocket-docs/#/private_channels?id=trade-response
// https://maicoin.github.io/max-websocket-docs/#/public_trade?id=success-response
message Trade {
string session = 1;
string exchange = 2;
string symbol = 3;
string id = 4;
string price = 5;
string quantity = 6;
int64 created_at = 7;
Side side = 8;
string fee_currency = 9;
string fee = 10;
bool maker = 11;
2022-02-19 20:08:52 +00:00
}
// https://maicoin.github.io/max-websocket-docs/#/public_ticker?id=success-response
message Ticker {
2022-04-08 11:21:57 +00:00
string exchange = 1;
string symbol = 2;
double open = 3;
double high = 4;
double low = 5;
double close = 6;
double volume = 7;
2022-02-19 20:08:52 +00:00
}
// https://maicoin.github.io/max-websocket-docs/#/private_channels?id=snapshot
message Order {
2022-04-08 11:21:57 +00:00
string exchange = 1;
string symbol = 2;
string id = 3;
Side side = 4;
OrderType order_type = 5;
2022-04-13 07:29:23 +00:00
string price = 6;
string stop_price = 7;
2022-04-08 11:21:57 +00:00
string status = 9;
2022-04-13 07:29:23 +00:00
string quantity = 11;
string executed_quantity = 12;
2022-04-08 11:21:57 +00:00
string client_order_id = 14;
int64 group_id = 15;
2022-04-13 07:29:23 +00:00
int64 created_at = 10;
2022-02-19 20:08:52 +00:00
}
message SubmitOrder {
2022-04-15 06:53:50 +00:00
string session = 1;
string exchange = 2;
string symbol = 3;
Side side = 4;
2022-04-15 06:58:07 +00:00
string price = 6;
string quantity = 5;
string stop_price = 7;
2022-04-15 06:53:50 +00:00
OrderType order_type = 8;
string client_order_id = 9;
int64 group_id = 10;
}
2022-02-19 20:08:52 +00:00
// https://maicoin.github.io/max-websocket-docs/#/private_channels?id=account-response
2022-02-14 08:16:32 +00:00
message Balance {
2022-04-15 06:53:50 +00:00
string session = 1;
string exchange = 2;
string currency = 3;
string available = 4;
string locked = 5;
string borrowed = 6;
2022-02-14 08:16:32 +00:00
}
message SubmitOrderRequest {
2022-04-15 06:53:50 +00:00
string session = 1;
repeated SubmitOrder submit_orders = 2;
2022-02-14 08:16:32 +00:00
}
message SubmitOrderResponse {
2022-04-15 06:53:50 +00:00
string session = 1;
repeated Order orders = 2;
Error error = 3;
2022-02-14 08:16:32 +00:00
}
message CancelOrderRequest {
2022-04-15 06:53:50 +00:00
string session = 1;
2022-04-08 11:21:57 +00:00
string id = 2;
string client_order_id = 3;
2022-02-14 08:16:32 +00:00
}
message CancelOrderResponse {
2022-04-08 11:21:57 +00:00
Order order = 1;
Error error = 2;
2022-02-14 08:16:32 +00:00
}
message QueryOrderRequest {
2022-04-15 06:53:50 +00:00
string session = 1;
2022-04-08 11:21:57 +00:00
string id = 2;
string client_order_id = 3;
2022-02-14 08:16:32 +00:00
}
message QueryOrderResponse {
2022-04-08 11:21:57 +00:00
Order order = 1;
Error error = 2;
2022-02-14 08:16:32 +00:00
}
2022-02-19 20:08:52 +00:00
message QueryOrdersRequest {
2022-04-15 06:53:50 +00:00
string session = 1;
2022-04-08 11:21:57 +00:00
string symbol = 2;
repeated string state = 3;
string order_by = 4;
int64 group_id = 5;
bool pagination = 6;
int64 page = 7;
int64 limit = 8;
int64 offset = 9;
}
2022-02-14 08:16:32 +00:00
2022-02-19 20:08:52 +00:00
message QueryOrdersResponse {
2022-04-08 11:21:57 +00:00
repeated Order orders = 1;
Error error = 2;
}
2022-02-14 08:16:32 +00:00
message QueryTradesRequest {
2022-04-08 11:21:57 +00:00
string exchange = 1;
string symbol = 2;
int64 timestamp = 3;
int64 from = 4;
int64 to = 5;
string order_by = 6;
bool pagination = 7;
int64 page = 8;
int64 limit = 9;
int64 offset = 10;
2022-02-14 08:16:32 +00:00
}
message QueryTradesResponse {
2022-04-08 11:21:57 +00:00
repeated Trade trades = 1;
Error error = 2;
}
2022-02-19 20:41:39 +00:00
message QueryKLinesRequest {
2022-04-08 11:21:57 +00:00
string exchange = 1;
string symbol = 2;
string interval = 3; // time period of K line in minute
int64 start_time = 4;
int64 end_time = 5;
int64 limit = 6;
2022-02-19 20:41:39 +00:00
}
message QueryKLinesResponse {
2022-04-08 11:21:57 +00:00
repeated KLine klines = 1;
Error error = 2;
2022-02-19 20:41:39 +00:00
}
message KLine {
2022-04-12 08:55:42 +00:00
string session = 1;
string exchange = 2;
string symbol = 3;
2022-04-13 04:41:36 +00:00
string open = 4;
string high = 5;
string low = 6;
string close = 7;
string volume = 8;
string quote_volume = 9;
2022-04-12 08:55:42 +00:00
int64 start_time = 10;
int64 end_time = 11;
2022-04-13 04:41:36 +00:00
bool closed = 12;
2022-02-19 20:41:39 +00:00
}