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.
253 lines
5.4 KiB
253 lines
5.4 KiB
syntax = "proto3"; |
|
|
|
import "google/protobuf/struct.proto"; |
|
|
|
option go_package = "./pb"; |
|
|
|
enum SubscribeType { |
|
SUB = 0; |
|
UNSUB = 1; |
|
UNSUB_ALL = 2; |
|
} |
|
|
|
enum ExchangeType { |
|
SIG = 0; |
|
OKX = 1; |
|
BINANCE = 2; |
|
} |
|
|
|
enum TradeInstanceType { |
|
UNKNOW = 0; |
|
SPOT = 1; // 1现货 |
|
SWAP = 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 inst_id = 1; |
|
string inst_pair = 2; |
|
string inst_coin = 3; |
|
TradeInstanceType inst_type = 4; |
|
int32 status = 5; |
|
int32 price_sz = 6; |
|
int32 quantity_sz = 7; |
|
string icon = 8; |
|
string update_by = 9; |
|
int64 update_time = 10; |
|
repeated int32 leverages = 11; |
|
repeated TradeInstanceExchange exchanges = 15; // 交易产品支持的交易所 |
|
} |
|
|
|
// 交易所交易产品 |
|
message TradeInstanceExchange { |
|
string exchange_inst_id = 1; |
|
string inst_id = 2; |
|
int32 status = 3; |
|
ExchangeType exchange = 4; |
|
string update_by = 5; |
|
int64 update_time = 6; |
|
} |
|
|
|
// 交易所交易产品基础信息 |
|
message MarketTradeInstance { |
|
ExchangeType exchange = 1; |
|
string inst_id = 2; |
|
string exchange_inst_id = 3; |
|
TradeInstanceType inst_type = 4; |
|
string inst_coin = 5; |
|
int32 status = 6; |
|
int32 price_sz = 9; |
|
int32 quantity_sz = 10; |
|
repeated int32 leverages = 11; |
|
} |
|
|
|
// 交易所交易产品状态 |
|
message TradeInstanceState { |
|
ExchangeType exchange = 1; |
|
string inst_id = 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 vol_quote = 9; // 交易额 |
|
bool confirm = 10; // k线是否完结 |
|
} |
|
|
|
message KlineSeries { |
|
string interval = 2; // 周期 |
|
repeated int64 time = 3; |
|
repeated double open = 4; |
|
repeated double high = 5; |
|
repeated double low = 6; |
|
repeated double close = 7; |
|
repeated double vol = 8; // 交易量 |
|
repeated double vol_quote = 9; // 交易额 |
|
// bool confirm = 10; // k线是否完结 true |
|
Kline live = 11; // 未完结实时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 inst_id = 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 window_extra = 10; // 需要额外拉取更早的k线条数 |
|
uint32 limit = 11; // 大于0时检查, 数据长度超过limit则返回错误 |
|
} |
|
|
|
// 分页参数 |
|
message Paging { |
|
int32 page = 1; |
|
int32 size = 2; |
|
bool asc = 3; // 升序排序 |
|
} |
|
|
|
// 指标元数据 |
|
message IndicatorMeta { |
|
string name = 1; // 指标名称 |
|
string desc = 2; // 指标描述 |
|
repeated InputArg input = 3; // 输入参数 |
|
repeated string state = 4; // 向外暴露状态 |
|
repeated IndicatorPlotSeries plots = 5; // 指标绘图属性 |
|
} |
|
|
|
// 指标绘图 |
|
message IndicatorPlot { |
|
string indicator = 1; |
|
repeated IndicatorPlotSeries plots = 9; |
|
} |
|
message IndicatorPlotSeries { |
|
string name = 1; |
|
string state = 2; |
|
int32 type = 3; |
|
google.protobuf.Struct props = 4; |
|
repeated IndicatorPlotExp exps = 5; |
|
} |
|
message IndicatorPlotExp { |
|
string exp = 1; |
|
google.protobuf.Struct props = 3; |
|
} |
|
|
|
// 输入参数定义 |
|
message InputArg { |
|
string name = 1; |
|
string desc = 2; |
|
int32 type = 3; // 参数类型 |
|
repeated InputOption options = 4 ; // 单选/多选选项列表 |
|
string default = 5; // 默认值 |
|
} |
|
message InputOption { |
|
string name = 1; |
|
string desc = 2; |
|
} |
|
|
|
// 输入参数范围 |
|
message InputRange { |
|
string name = 1; // 参数名 names |
|
int32 type = 2; // 0.fixed, 1.range, 2.enum, 3.simple group |
|
string value = 3; // range => [10,20,1](min,max,step); enum => [1,2,3,4,5]; simple group => [["2025-10-01","2025-12-31"],["2025-01-01","2025-12-31"]] |
|
} |
|
|
|
// 回测订单 |
|
message BacktestTradeOrder { |
|
int64 backtest_id = 1; |
|
int64 trade_id = 2; |
|
int32 trade_type = 3; |
|
string inst_id = 4; |
|
Side side = 5; |
|
double qty = 6; |
|
double price = 7; |
|
double fee = 8; |
|
int32 leverage = 9; |
|
int64 ctime = 10; |
|
int32 status = 11; |
|
double peak_px = 12; |
|
string close_cause = 13; |
|
double equity = 14; |
|
string hold_time = 15; |
|
double profit = 16; |
|
double last_px = 17; |
|
double entry_px = 18; |
|
double entry_fee = 19; |
|
int64 entry_time = 20; |
|
repeated int64 trades = 21; |
|
} |
|
|
|
// 登录认证对象 |
|
message RpcSubject { |
|
int64 uid = 1; |
|
string account = 2; |
|
int64 time = 3; // ms |
|
map<string, string> extra = 4; |
|
} |
|
|
|
|