update proto

This commit is contained in:
なるみ 2022-02-20 04:08:52 +08:00
parent 4fb8881be7
commit 7a7627eafd

View File

@ -6,51 +6,43 @@ option go_package = "../pb";
service BBGO { service BBGO {
// should support streaming // should support streaming
rpc SubscribeKLine(SubscribeKLineRequest) returns (stream SubscribeKLineResponse) {} rpc Subcribe(SubscribeRequest) returns (stream SubscribeResponse) {}
rpc SubscribeOrderBook(SubscribeOrderBookRequest) returns (stream SubscribeOrderBookResponse) {}
rpc SubscribeUserData(SubscribeUserDataRequest) returns (stream SubscribeUserDataResponse) {}
// request-response // request-response
rpc CreateOrder(CreateOrderRequest) returns (CreateOrderResponse) {} rpc CreateOrder(CreateOrderRequest) returns (CreateOrderResponse) {}
rpc CancelOrder(CancelOrderRequest) returns (CancelOrderResponse) {} rpc CancelOrder(CancelOrderRequest) returns (CancelOrderResponse) {}
rpc QueryOrder(QueryOrderRequest) returns (QueryOrderResponse) {} rpc QueryOrder(QueryOrderRequest) returns (QueryOrderResponse) {}
rpc QueryOpenOrders(QueryOpenOrdersRequest) returns (QueryOpenOrdersResponse) {} rpc QueryOrders(QueryOrdersRequest) returns (QueryOrdersResponse) {}
rpc QueryTrades(QueryTradesRequest) returns (QueryTradesResponse) {} rpc QueryTrades(QueryTradesRequest) returns (QueryTradesResponse) {}
} }
message SubscribeKLineRequest { message SubscribeRequest {
repeated Subscription subscriptions = 1;
}
message Subscription {
string exchange = 1; string exchange = 1;
string symbol = 2; string channel = 2; // book, trade, ticker
string interval = 3; string market = 3;
int64 limit = 4; int64 depth = 4;
uint64 since = 5;
} }
message SubscribeKLineResponse { message SubscribeResponse {
repeated SuccessResponse success_responses = 1;
}
message SuccessResponse {
string exchange = 1; string exchange = 1;
string symbol = 2; string channel = 2; // book, trade, ticker, user
repeated KLine klines = 3; string event = 3; // snapshot, update, order_snapshot, ...
} string market = 4;
repeated PriceVolume asks = 5;
message KLine { repeated PriceVolume bids = 6;
int64 timestamp = 1; repeated Trade trades = 7;
double open = 2; Ticker ticker = 8;
double high = 3; repeated Order orders = 9;
double low = 4; repeated Balance balances = 10;
double close = 5; int64 timestamp = 11;
double volume = 6;
}
message SubscribeOrderBookRequest {
string symbol = 1;
optional int64 limit = 2;
}
message SubscribeOrderBookResponse {
int64 timestamp = 1;
string symbol = 2;
repeated PriceVolume bids = 3;
repeated PriceVolume asks = 4;
} }
message PriceVolume { message PriceVolume {
@ -58,110 +50,124 @@ message PriceVolume {
int64 volume = 2; int64 volume = 2;
} }
message SubscribeUserDataRequest { // https://maicoin.github.io/max-websocket-docs/#/private_channels?id=trade-response
repeated BalanceRequest balance_requests = 1; // 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;
} }
message BalanceRequest { // https://maicoin.github.io/max-websocket-docs/#/public_ticker?id=success-response
string exchange = 1; message Ticker {
string currency = 2; double open = 1;
double high = 2;
double low = 3;
double close = 4;
double volume = 5;
} }
message SubscribeUserDataResponse { // https://maicoin.github.io/max-websocket-docs/#/private_channels?id=snapshot
repeated Balance balances = 1; message Order {
repeated Order orders = 2; 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
message Balance { message Balance {
string exchange = 1; string currency = 1;
string currency = 2; double available = 2;
double quantity = 3; double locked = 3;
double available = 4;
} }
message CreateOrderRequest { message CreateOrderRequest {
string exchange = 1; string exchange = 1;
string symbol = 2; Order order = 2;
string side = 3; // buy, sell
string order = 4; // limit, limit maker, market, stop limit, stop market, ioc limit
double quantity = 5;
double price = 6;
optional double stop_price = 7;
optional string time_in_force = 8; // GTC, IOC, FOK
} }
message CreateOrderResponse { message CreateOrderResponse {
bool ok = 1; string exchange = 1;
Order order = 2; Order order = 2;
} }
message CancelOrderRequest { message CancelOrderRequest {
string order_id = 1; string exchange = 1;
int64 id = 2;
int64 client_oid = 3;
} }
message CancelOrderResponse { message CancelOrderResponse {
bool ok = 1; string exchange = 1;
Order order = 2;
int64 status_code = 3;
} }
message QueryOrderRequest { message QueryOrderRequest {
string order_id = 1; string exchange = 1;
int64 id = 2;
int64 client_oid = 3;
} }
message QueryOrderResponse { message QueryOrderResponse {
bool exists = 1; string exchange = 1;
Order order = 2; Order order = 2;
int64 status_code = 3;
} }
message Order { // https://max.maicoin.com/documents/api_list/v2#!/private/getApiV2Orders
string order_id = 1; message QueryOrdersRequest {
string exchange = 2; string exchange = 1;
string symbol = 3; string market = 2;
string side = 4; // buy, sell repeated string state = 3;
string order = 5; // limit, limit maker, market, stop limit, stop market, ioc limit string order_by = 4;
double quantity = 6; int64 group_id = 5;
double price = 7; bool pagination = 6;
double stop_price = 8; int64 page = 7;
string time_in_force = 9; // GTC, IOC, FOK int64 limit = 8;
int64 offset = 9;
string order_status = 10; // new, filled, partially filled, canceled, rejected
double executed_quantity = 11;
bool isWorking = 12;
int64 creation_time = 13;
int64 update_time = 14;
} }
message QueryOpenOrdersRequest { message QueryOrdersResponse {
string order_id = 1; string exchange = 1;
} repeated Order orders = 2;
int64 status_code = 3;
message QueryOpenOrdersResponse {
bool exists = 1;
Order order = 2;
} }
message QueryTradesRequest { message QueryTradesRequest {
string exchange = 1; string exchange = 1;
string symbol = 2; string market = 2;
int64 since = 3; int64 timestamp = 3;
int64 until = 4; int64 from = 4;
optional int64 order_id = 5; int64 to = 5;
string order_by = 6;
bool pagination = 7;
int64 page = 8;
int64 limit = 9;
int64 offset = 10;
} }
message QueryTradesResponse { message QueryTradesResponse {
repeated Trade trades = 1; string exchange = 1;
} repeated Trade trades = 2;
int64 status_code = 3;
message Trade {
string order_id = 1;
string exchange = 2;
string symbol = 3;
string side = 4; // buy, sell
double quantity = 5;
double quote_quantity = 6;
double price = 7;
bool is_buyer = 8;
bool is_maker = 9;
int64 trade_at = 10;
double fee = 11;
string fee_currency = 12;
} }