2022-02-14 08:16:32 +00:00
|
|
|
syntax = "proto3";
|
|
|
|
|
2022-02-18 06:26:48 +00:00
|
|
|
package pb;
|
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
|
|
|
|
|
|
|
service BBGO {
|
|
|
|
// should support streaming
|
2022-04-07 04:04:27 +00:00
|
|
|
rpc Subscribe(SubscribeRequest) returns (stream SubscribeResponse) {}
|
|
|
|
rpc SubscribeUserData(Empty) returns (stream SubscribeResponse) {}
|
2022-02-14 08:16:32 +00:00
|
|
|
|
|
|
|
// request-response
|
2022-02-21 03:38:43 +00:00
|
|
|
rpc SubmitOrder(SubmitOrderRequest) returns (SubmitOrderResponse) {}
|
2022-02-14 08:16:32 +00:00
|
|
|
rpc CancelOrder(CancelOrderRequest) returns (CancelOrderResponse) {}
|
|
|
|
rpc QueryOrder(QueryOrderRequest) returns (QueryOrderResponse) {}
|
2022-02-19 20:08:52 +00:00
|
|
|
rpc QueryOrders(QueryOrdersRequest) returns (QueryOrdersResponse) {}
|
2022-02-14 08:16:32 +00:00
|
|
|
rpc QueryTrades(QueryTradesRequest) returns (QueryTradesResponse) {}
|
2022-02-21 03:38:43 +00:00
|
|
|
rpc QueryKLines(QueryKLinesRequest) returns (QueryKLinesResponse) {}
|
2022-02-14 08:16:32 +00:00
|
|
|
}
|
|
|
|
|
2022-03-07 04:06:16 +00:00
|
|
|
enum Event {
|
|
|
|
ERROR = 0;
|
|
|
|
SUBSCRIBED = 1;
|
|
|
|
UNSUBSCRIBED = 2;
|
|
|
|
SNAPSHOT = 3;
|
|
|
|
UPDATE = 4;
|
|
|
|
AUTHENTICATED = 5;
|
|
|
|
ORDER_SNAPSHOT = 6;
|
|
|
|
ORDER_UPDATE = 7;
|
|
|
|
TRADE_SNAPSHOT = 8;
|
|
|
|
TRADE_UPDATE = 9;
|
|
|
|
ACCOUNT_SNAPSHOT = 10;
|
|
|
|
ACCOUNT_UPDATE = 11;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum Channel {
|
|
|
|
BOOK = 0;
|
|
|
|
TRADE = 1;
|
|
|
|
TICKER = 2;
|
|
|
|
USER = 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum Side {
|
|
|
|
BUY = 0;
|
|
|
|
SELL = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum OrderType {
|
|
|
|
MARKET = 0;
|
|
|
|
LIMIT = 1;
|
|
|
|
STOP_MARKET = 2;
|
|
|
|
STOP_LIMIT = 3;
|
|
|
|
POST_ONLY = 4;
|
|
|
|
IOC_LIMIT = 5;
|
|
|
|
}
|
|
|
|
|
2022-02-23 04:29:01 +00:00
|
|
|
message Empty {}
|
|
|
|
|
2022-02-23 04:41:11 +00:00
|
|
|
message Error {
|
|
|
|
int64 error_code = 1;
|
|
|
|
string error_message = 2;
|
|
|
|
}
|
|
|
|
|
2022-02-19 20:08:52 +00:00
|
|
|
message SubscribeRequest {
|
|
|
|
repeated Subscription subscriptions = 1;
|
2022-02-14 08:16:32 +00:00
|
|
|
}
|
|
|
|
|
2022-02-19 20:08:52 +00:00
|
|
|
message Subscription {
|
2022-02-14 08:16:32 +00:00
|
|
|
string exchange = 1;
|
2022-03-07 04:06:16 +00:00
|
|
|
Channel channel = 2; // book, trade, ticker
|
2022-02-21 03:38:43 +00:00
|
|
|
string symbol = 3;
|
2022-02-19 20:08:52 +00:00
|
|
|
int64 depth = 4;
|
2022-02-14 08:16:32 +00:00
|
|
|
}
|
|
|
|
|
2022-02-19 20:08:52 +00:00
|
|
|
message SubscribeResponse {
|
|
|
|
string exchange = 1;
|
2022-02-23 04:26:45 +00:00
|
|
|
string symbol = 2;
|
2022-03-07 04:06:16 +00:00
|
|
|
Channel channel = 3; // book, trade, ticker, user
|
|
|
|
Event event = 4; // snapshot, update, order_snapshot, ...
|
2022-02-23 04:19:23 +00:00
|
|
|
Depth depth = 5;
|
|
|
|
repeated Trade trades = 6;
|
|
|
|
Ticker ticker = 7;
|
|
|
|
repeated Order orders = 8;
|
|
|
|
repeated Balance balances = 9;
|
2022-02-23 04:21:49 +00:00
|
|
|
int64 subscribed_at = 10;
|
2022-02-23 04:41:11 +00:00
|
|
|
Error error = 11;
|
2022-02-23 04:19:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
message Depth {
|
|
|
|
string exchange = 1;
|
|
|
|
string symbol = 2;
|
|
|
|
repeated PriceVolume asks = 3;
|
|
|
|
repeated PriceVolume bids = 4;
|
2022-02-14 08:16:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
message PriceVolume {
|
|
|
|
int64 price = 1;
|
|
|
|
int64 volume = 2;
|
|
|
|
}
|
|
|
|
|
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 {
|
2022-02-21 04:53:39 +00:00
|
|
|
string exchange = 1;
|
2022-02-23 04:26:45 +00:00
|
|
|
string symbol = 2;
|
2022-03-09 05:12:47 +00:00
|
|
|
string id = 3;
|
2022-02-23 04:26:45 +00:00
|
|
|
double price = 4;
|
|
|
|
double volume = 5;
|
2022-02-21 04:53:39 +00:00
|
|
|
int64 created_at = 6;
|
2022-03-07 04:06:16 +00:00
|
|
|
Side side = 7;
|
2022-02-21 04:53:39 +00:00
|
|
|
double fee = 8;
|
|
|
|
string fee_currency = 9;
|
|
|
|
bool maker = 10;
|
|
|
|
string trend = 11;
|
2022-02-19 20:08:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// https://maicoin.github.io/max-websocket-docs/#/public_ticker?id=success-response
|
|
|
|
message Ticker {
|
2022-02-23 04:26:45 +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-02-21 03:38:43 +00:00
|
|
|
string exchange = 1;
|
2022-02-23 04:26:45 +00:00
|
|
|
string symbol = 2;
|
2022-03-09 05:12:47 +00:00
|
|
|
string id = 3;
|
2022-03-07 04:06:16 +00:00
|
|
|
Side side = 4;
|
|
|
|
OrderType order_type = 5;
|
2022-02-23 04:26:45 +00:00
|
|
|
double price = 6;
|
|
|
|
double stop_price = 7;
|
|
|
|
double avg_price = 8;
|
|
|
|
string status = 9;
|
2022-02-21 03:38:43 +00:00
|
|
|
int64 created_at = 10;
|
|
|
|
double quantity = 11;
|
2022-02-19 20:08:52 +00:00
|
|
|
double executed_volume = 12;
|
|
|
|
int64 trades_count = 13;
|
2022-03-09 05:12:47 +00:00
|
|
|
string client_order_id = 14;
|
2022-02-19 20:08:52 +00:00
|
|
|
int64 group_id = 15;
|
|
|
|
}
|
|
|
|
|
2022-02-21 03:38:43 +00:00
|
|
|
message SubmitOrder {
|
|
|
|
string exchange = 1;
|
|
|
|
string symbol = 2;
|
2022-03-07 04:06:16 +00:00
|
|
|
Side side = 3;
|
2022-02-21 03:38:43 +00:00
|
|
|
double quantity = 4;
|
|
|
|
double price = 5;
|
|
|
|
double stop_price = 6;
|
2022-03-07 04:06:16 +00:00
|
|
|
OrderType order_type = 7;
|
2022-03-09 05:12:47 +00:00
|
|
|
string client_order_id = 8;
|
2022-02-21 03:38:43 +00:00
|
|
|
int64 group_id = 9;
|
|
|
|
}
|
|
|
|
|
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-02-23 04:26:45 +00:00
|
|
|
string exchange = 1;
|
2022-03-15 07:35:46 +00:00
|
|
|
string currency = 2;
|
|
|
|
double available = 3;
|
|
|
|
double locked = 4;
|
2022-02-14 08:16:32 +00:00
|
|
|
}
|
|
|
|
|
2022-02-21 03:38:43 +00:00
|
|
|
message SubmitOrderRequest {
|
|
|
|
SubmitOrder submit_order = 1;
|
2022-02-14 08:16:32 +00:00
|
|
|
}
|
|
|
|
|
2022-02-21 03:38:43 +00:00
|
|
|
message SubmitOrderResponse {
|
2022-02-23 04:41:11 +00:00
|
|
|
Order order = 1;
|
|
|
|
Error error = 2;
|
2022-02-14 08:16:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
message CancelOrderRequest {
|
2022-02-19 20:08:52 +00:00
|
|
|
string exchange = 1;
|
2022-03-09 05:12:47 +00:00
|
|
|
string id = 2;
|
|
|
|
string client_order_id = 3;
|
2022-02-14 08:16:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
message CancelOrderResponse {
|
2022-02-23 04:41:11 +00:00
|
|
|
Order order = 1;
|
|
|
|
Error error = 2;
|
2022-02-14 08:16:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
message QueryOrderRequest {
|
2022-03-08 11:32:40 +00:00
|
|
|
string exchange = 1;
|
2022-03-09 05:12:47 +00:00
|
|
|
string id = 2;
|
|
|
|
string client_order_id = 3;
|
2022-02-14 08:16:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
message QueryOrderResponse {
|
2022-02-21 04:53:39 +00:00
|
|
|
Order order = 1;
|
2022-02-23 04:41:11 +00:00
|
|
|
Error error = 2;
|
2022-02-14 08:16:32 +00:00
|
|
|
}
|
|
|
|
|
2022-02-19 20:08:52 +00:00
|
|
|
message QueryOrdersRequest {
|
|
|
|
string exchange = 1;
|
2022-02-21 03:38:43 +00:00
|
|
|
string symbol = 2;
|
2022-02-19 20:08:52 +00:00
|
|
|
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-16 03:41:33 +00:00
|
|
|
}
|
2022-02-14 08:16:32 +00:00
|
|
|
|
2022-02-19 20:08:52 +00:00
|
|
|
message QueryOrdersResponse {
|
2022-02-23 04:41:11 +00:00
|
|
|
repeated Order orders = 1;
|
|
|
|
Error error = 2;
|
2022-02-16 03:41:33 +00:00
|
|
|
}
|
2022-02-14 08:16:32 +00:00
|
|
|
|
|
|
|
message QueryTradesRequest {
|
|
|
|
string exchange = 1;
|
2022-02-21 03:38:43 +00:00
|
|
|
string symbol = 2;
|
2022-02-19 20:08:52 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2022-02-16 03:41:33 +00:00
|
|
|
message QueryTradesResponse {
|
2022-02-21 04:53:39 +00:00
|
|
|
repeated Trade trades = 1;
|
2022-02-23 04:41:11 +00:00
|
|
|
Error error = 2;
|
2022-02-16 03:41:33 +00:00
|
|
|
}
|
2022-02-19 20:41:39 +00:00
|
|
|
|
2022-02-21 03:38:43 +00:00
|
|
|
message QueryKLinesRequest {
|
2022-02-19 20:41:39 +00:00
|
|
|
string exchange = 1;
|
2022-02-21 03:38:43 +00:00
|
|
|
string symbol = 2;
|
|
|
|
int64 limit = 3;
|
|
|
|
int64 interval = 4; // time period of K line in minute
|
2022-02-19 20:41:39 +00:00
|
|
|
int64 timestamp = 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
message QueryKLinesResponse {
|
2022-02-21 03:38:43 +00:00
|
|
|
repeated KLine klines = 1;
|
2022-02-23 04:41:11 +00:00
|
|
|
Error error = 2;
|
2022-02-19 20:41:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
message KLine {
|
2022-02-21 03:38:43 +00:00
|
|
|
string exchange = 1;
|
|
|
|
string symbol = 2;
|
|
|
|
int64 timestamp = 3;
|
|
|
|
double open = 4;
|
|
|
|
double high = 5;
|
|
|
|
double low = 6;
|
|
|
|
double close = 7;
|
|
|
|
double volume = 8;
|
|
|
|
double quote_volume = 9;
|
2022-02-19 20:41:39 +00:00
|
|
|
}
|