You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

176 lines
3.6 KiB

syntax = "proto3";
import "google/protobuf/struct.proto";
option go_package = "./pb";
enum SubscribeType {
Subscribe = 0;
Unsubscribe = 1;
UnsubscribeAll = 2;
}
enum ExchangeType {
SIG = 0;
OKX = 1;
BINANCE = 2;
}
enum TradeInstanceType {
Unknow = 0;
Spot = 1; // 1现货
PerpetualContract = 2; // 2永续合约
}
enum Event {
UNKNOWN = 0;
SUBSCRIBED = 1;
UNSUBSCRIBED = 2;
SNAPSHOT = 3;
UPDATE = 4;
AUTHENTICATED = 5;
ERROR = 99;
}
enum Channel {
BOOK = 0;
TRADE = 1;
TICKER = 2;
KLINE = 3;
BALANCE = 4;
ORDER = 5;
}
enum Side {
None = 0;
BUY = 1;
SELL = 2;
}
enum OrderType {
MARKET = 0;
LIMIT = 1;
STOP_MARKET = 2;
STOP_LIMIT = 3;
POST_ONLY = 4;
IOC_LIMIT = 5;
}
message Error {
int64 error_code = 1;
string error_message = 2;
}
// 交易产品基础信息
message TradeInstance {
string instId = 1;
string instPair = 2;
string instCoin = 3;
TradeInstanceType instType = 4;
int32 status = 5;
int32 priceSz = 6;
int32 quantitySz = 7;
string icon = 8;
string updateBy = 9;
int64 updateTime = 10;
repeated int32 leverages = 11;
repeated TradeInstanceExchange exchanges = 15; // 交易产品支持的交易所
}
// 交易所交易产品
message TradeInstanceExchange {
string exchangeInstId = 1;
string instId = 2;
int32 status = 3;
ExchangeType exchange = 4;
string updateBy = 5;
int64 updateTime = 6;
}
// 交易所交易产品基础信息
message MarketTradeInstance {
ExchangeType exchange = 1;
string instId = 2;
string exchangeInstId = 3;
TradeInstanceType instType = 4;
string instCoin = 5;
int32 status = 6;
int32 priceSz = 9;
int32 quantitySz = 10;
repeated int32 leverages = 11;
}
// 交易所交易产品状态
message TradeInstanceState {
ExchangeType exchange = 1;
string instId = 2;
int32 status = 3;
string last = 4; // 最后成交价格
}
message Kline {
int64 time = 2;
string interval = 3; // 周期
double open = 4;
double high = 5;
double low = 6;
double close = 7;
double vol = 8; // 交易量
double volQuote = 9; // 交易额
bool confirm = 10; // k线是否完结
}
// https://maicoin.github.io/max-websocket-docs/#/private_channels?id=snapshot
message Order {
ExchangeType exchange = 1;
string symbol = 2;
string id = 3;
Side side = 4;
OrderType order_type = 5;
string price = 6;
string stop_price = 7;
string status = 9;
string quantity = 11;
string executed_quantity = 12;
string client_order_id = 14;
int64 group_id = 15;
int64 created_at = 10;
}
message SeriesRange {
ExchangeType exchange = 1; // 交易所
string instId = 2;
string interval = 3;
int64 before = 4;
int64 after = 5;
uint32 count = 6; // k线条数,before或after其中一个为0时有效
bool open = 7; // 是否开区间, before/after不为0时不包含
bool live = 8; // 实时k线, before和after为0时是否追加实时k线
bool desc = 9; // 是否降序, 默认升序
uint32 windowExtra = 10; // 需要额外拉取更早的k线条数
uint32 limit = 11; // 大于0时检查, 数据长度超过limit则返回错误
}
// 分页参数
message Paging {
int32 page = 1;
int32 size = 2;
bool asc = 3; // 升序排序
}
message IndicatorPlot {
string indicator = 1;
IndicatorPlotSeries series = 2;
repeated IndicatorPlotSeries stateSeries = 3;
}
message IndicatorPlotSeries {
string state = 1;
int32 type = 2;
google.protobuf.Struct props = 3;
repeated IndicatorStateEnumProps stateEnumProps = 4;
}
message IndicatorStateEnumProps {
string state = 1;
map<int32, google.protobuf.Struct> enumProps = 2;
}