bbgo_origin/pkg/pb/bbgo.proto

198 lines
4.5 KiB
Protocol Buffer
Raw Normal View History

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-02-19 20:08:52 +00:00
rpc Subcribe(SubscribeRequest) returns (stream SubscribeResponse) {}
2022-02-14 08:16:32 +00:00
// request-response
rpc CreateOrder(CreateOrderRequest) returns (CreateOrderResponse) {}
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-19 20:41:39 +00:00
rpc QueryKLines(QueryKlinesRequest) returns (QueryKLinesResponse) {}
2022-02-14 08:16:32 +00:00
}
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-02-19 20:08:52 +00:00
string channel = 2; // book, trade, ticker
string market = 3;
int64 depth = 4;
2022-02-14 08:16:32 +00:00
}
2022-02-19 20:08:52 +00:00
message SubscribeResponse {
repeated SuccessResponse success_responses = 1;
2022-02-14 08:16:32 +00:00
}
2022-02-19 20:08:52 +00:00
message SuccessResponse {
string exchange = 1;
string channel = 2; // book, trade, ticker, user
string event = 3; // snapshot, update, order_snapshot, ...
string market = 4;
repeated PriceVolume asks = 5;
repeated PriceVolume bids = 6;
repeated Trade trades = 7;
Ticker ticker = 8;
repeated Order orders = 9;
repeated Balance balances = 10;
2022-02-19 20:41:39 +00:00
int64 created_at = 11;
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 {
int64 id = 1; // trade id
double price = 2;
double volume = 3;
string market = 4;
int64 created_at = 5;
string side = 6;
double fee = 7;
string fee_currency = 8;
bool maker = 9;
string trend = 10;
}
// https://maicoin.github.io/max-websocket-docs/#/public_ticker?id=success-response
message Ticker {
double open = 1;
double high = 2;
double low = 3;
double close = 4;
double volume = 5;
}
// https://maicoin.github.io/max-websocket-docs/#/private_channels?id=snapshot
message Order {
int64 id = 1;
string side = 2;
string order_type = 3; // limit, ...
double price = 4;
double stop_price = 5;
double avg_price = 6;
string state = 7;
string market = 8;
int64 created_at = 9;
double volume = 10;
double remaining_volume = 11;
double executed_volume = 12;
int64 trades_count = 13;
int64 client_oid = 14;
int64 group_id = 15;
}
// https://maicoin.github.io/max-websocket-docs/#/private_channels?id=account-response
2022-02-14 08:16:32 +00:00
message Balance {
2022-02-19 20:08:52 +00:00
string currency = 1;
double available = 2;
double locked = 3;
2022-02-14 08:16:32 +00:00
}
message CreateOrderRequest {
string exchange = 1;
2022-02-19 20:08:52 +00:00
Order order = 2;
2022-02-14 08:16:32 +00:00
}
message CreateOrderResponse {
2022-02-19 20:08:52 +00:00
string exchange = 1;
2022-02-14 08:16:32 +00:00
Order order = 2;
}
message CancelOrderRequest {
2022-02-19 20:08:52 +00:00
string exchange = 1;
int64 id = 2;
int64 client_oid = 3;
2022-02-14 08:16:32 +00:00
}
message CancelOrderResponse {
2022-02-19 20:08:52 +00:00
string exchange = 1;
Order order = 2;
int64 status_code = 3;
2022-02-14 08:16:32 +00:00
}
message QueryOrderRequest {
2022-02-19 20:08:52 +00:00
string exchange = 1;
int64 id = 2;
int64 client_oid = 3;
2022-02-14 08:16:32 +00:00
}
message QueryOrderResponse {
2022-02-19 20:08:52 +00:00
string exchange = 1;
2022-02-14 08:16:32 +00:00
Order order = 2;
2022-02-19 20:08:52 +00:00
int64 status_code = 3;
2022-02-14 08:16:32 +00:00
}
2022-02-19 20:08:52 +00:00
// https://max.maicoin.com/documents/api_list/v2#!/private/getApiV2Orders
message QueryOrdersRequest {
string exchange = 1;
string market = 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 {
string exchange = 1;
repeated Order orders = 2;
int64 status_code = 3;
}
2022-02-14 08:16:32 +00:00
message QueryTradesRequest {
string exchange = 1;
2022-02-19 20:08:52 +00:00
string market = 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-02-19 20:08:52 +00:00
string exchange = 1;
repeated Trade trades = 2;
int64 status_code = 3;
}
2022-02-19 20:41:39 +00:00
// https://max.maicoin.com/documents/api_list/v2#!/public/getApiV2K
message QueryKlinesRequest {
string exchange = 1;
string market = 2;
int64 int64 = 3;
int64 period = 4; // time period of K line in minute
int64 timestamp = 5;
}
message QueryKLinesResponse {
string exchange = 1;
repeated KLine klines = 2;
int64 status_code = 3;
}
message KLine {
int64 timestamp = 1;
double open = 2;
double high = 3;
double low = 4;
double close = 5;
}