syntax = "proto3"; import "api/pub.proto"; option go_package = "./pb"; // 订阅/查询/存储,交易所k线图/热度/深度等基础数据指标 service ExchangeService { // 订阅实时K线 rpc SubscribeKline(stream ReqStreamSubscribeKline) returns (stream RspStreamSubscribeKline); // 获取支持的交易所列表 rpc Exchanges(ReqExchanges) returns (RspExchanges); // 获取交易所交易产品状态 rpc ExchangeInstanceState(ReqExchangeInstanceState) returns (RspExchangeInstanceState); // 查询历史k线 rpc HistoryKline(ReqHistoryKline) returns (RspHistoryKline); // 查询历史k线(流式返回) rpc HistoryKlineStream(ReqHistoryKlineStream) returns (stream RspHistoryKlineStream); } message ReqStreamSubscribeKline { SubscribeType subType = 1; repeated ExchangeType exchanges = 2; // 交易所 repeated string instIds = 3; repeated string intervals = 4; bool onlyConfirm = 5; // 只要confirm的k线 } message RspStreamSubscribeKline { StreamKline kline = 1; } message StreamKline { repeated Kline klines = 2; ExchangeType exchange = 3; // 交易所 string instId = 4; // 交易产品id int64 streamId = 5; // subscribe stream id } message ReqExchanges { } message RspExchanges { repeated ExchangeType exchanges = 1; } message ReqExchangeInstanceState { bool allExchange = 1; // 所有交易所 bool allInsts = 2; // 所有交易产品 bool allStatus = 3; // 所有状态 repeated ExchangeType exchanges = 4; // 指定交易所 repeated string insts = 5; // 指定交易产品 repeated int32 status = 6; // 指定交易产品状态 } message RspExchangeInstanceState { repeated TradeInstanceState instsState = 1; // 交易产品列表 } message ReqHistoryKline { 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; // 是否降序, 默认升序 } message RspHistoryKline { ExchangeType exchange = 1; // 交易所 string instId = 2; string interval = 3; bool live = 4; // 第一根是否实时k线 // bool next = 5; // 是否有更多历史数据: 为true时, 可以用最后一根k线的ts作为before继续请求 repeated Kline klines = 9; } message ReqHistoryKlineStream { ExchangeType exchange = 1; // 交易所 string instId = 2; string interval = 3; int64 before = 4; int64 after = 5; uint32 count = 6; // k线条数,before或after其中一个为0时有效 } message RspHistoryKlineStream { repeated Kline klines = 2; }