跳转到内容

获取标的 K 线

该接口用于获取标的的 K 线数据。

Info

注意:本接口只能获取到最近 1000 根 K 线,如需获取较长的历史数据,请访问接口:获取标的历史 K 线。

CLI安装 CLI

bash
# Tesla 日 K 线(最近 100 根)
longbridge kline TSLA.US
# Apple 周 K 线
longbridge kline AAPL.US --period week
# NVDA 最近 20 根日 K
longbridge kline NVDA.US --period day --count 20
Info

Request

Parameters

NameTypeRequiredDescription
symbolstring标的代码,使用 ticker.region 格式,例如:700.HK
periodint32k 线周期,例如:1000,详见 Period
countint32数据数量,例如:100

校验规则:
请求数量最大为 1000
adjust_typeint32复权类型,例如:0,详见 AdjustType
trade_sessionint32交易时段,0: 盘中,100: 所有(盘前,盘中,盘后,夜盘)

Protobuf

protobuf
message SecurityCandlestickRequest {
  string symbol = 1;
  Period period = 2;
  int32 count = 3;
  AdjustType adjust_type = 4;
  int32 trade_session = 5;
}

Request Example

Response

Response Properties

NameTypeDescription
symbolstring标的代码,例如:AAPL.US
candlesticksobject[]K 线数据
∟ closestring当前周期收盘价
∟ openstring当前周期开盘价
∟ lowstring当前周期最低价
∟ highstring当前周期最高价
∟ volumeint64当前周期成交量
∟ turnoverstring当前周期成交额
∟ timestampint64当前周期的时间戳
∟ trade_sessionint32交易時段,详见 TradeSession

Protobuf

protobuf
message SecurityCandlestickResponse {
  string symbol = 1;
  repeated Candlestick candlesticks = 2;
}

message Candlestick {
  string close = 1;
  string open = 2;
  string low = 3;
  string high = 4;
  int64 volume = 5;
  string turnover = 6;
  int64 timestamp = 7;
}

Response JSON Example

json
{
  "symbol": "700.HK",
  "candlesticks": [
    {
      "close": "362.000",
      "open": "364.600",
      "low": "361.600",
      "high": "368.800",
      "volume": 10853604,
      "turnover": "3954556819.000",
      "timestamp": 1650384000
    },
    {
      "close": "348.000",
      "open": "352.000",
      "low": "343.000",
      "high": "356.200",
      "volume": 25738562,
      "turnover": "8981529950.000",
      "timestamp": 1650470400
    },
    {
      "close": "340.600",
      "open": "334.800",
      "low": "334.200",
      "high": "343.000",
      "volume": 28031299,
      "turnover": "9492674293.000",
      "timestamp": 1650556800
    },
    {
      "close": "327.400",
      "open": "332.200",
      "low": "325.200",
      "high": "338.600",
      "volume": 25788422,
      "turnover": "8541441823.000",
      "timestamp": 1650816000
    },
    {
      "close": "335.800",
      "open": "332.200",
      "low": "330.600",
      "high": "341.600",
      "volume": 27288328,
      "turnover": "9166022626.000",
      "timestamp": 1650902400
    }
  ]
}

错误码

协议错误码业务错误码描述排查建议
3301600无效的请求请求参数有误或解包失败
3301606限流降低请求频次
7301602服务端内部错误请重试或联系技术人员处理
7301600请求数据非法检查请求的 symbolcountadjust_type, period 数据是否在正确范围
7301603标的无行情标的没有请求的行情数据
7301604无权限没有获取标的行情的权限
7301607接口限制请求的数据数量超限,减少数据数量