mirror of
https://github.com/longbridge/developers.git
synced 2026-09-19 03:34:09 +08:00
134 lines
3.4 KiB
Markdown
134 lines
3.4 KiB
Markdown
---
|
||
id: quote_intraday
|
||
title: 获取标的当日分时
|
||
slug: intraday
|
||
sidebar_position: 9
|
||
---
|
||
|
||
该接口用于获取标的的当日分时数据。
|
||
|
||
:::info
|
||
|
||
[业务指令](../../socket/biz-command):`18`
|
||
|
||
:::
|
||
|
||
## Request
|
||
|
||
### Parameters
|
||
|
||
| Name | Type | Required | Description |
|
||
|--------|--------|----------|--------------------------------------------------|
|
||
| symbol | string | 是 | 标的代码,使用 `ticker.region` 格式,例如:`700.HK` |
|
||
|
||
### Protobuf
|
||
|
||
```protobuf
|
||
message SecurityIntradayRequest {
|
||
string symbol = 1;
|
||
}
|
||
```
|
||
|
||
### Request Example
|
||
|
||
```python
|
||
# 获取标的分时
|
||
# https://open.longportapp.com/docs/quote/pull/intraday
|
||
# 运行前请访问“开发者中心”确保账户有正确的行情权限。
|
||
# 如没有开通行情权限,可以通过“LongPort”手机客户端,并进入“我的 - 我的行情 - 行情商城”购买开通行情权限。
|
||
from longport.openapi import QuoteContext, Config
|
||
|
||
config = Config.from_env()
|
||
ctx = QuoteContext(config)
|
||
|
||
resp = ctx.intraday("700.HK")
|
||
print(resp)
|
||
```
|
||
|
||
## Response
|
||
|
||
### Response Properties
|
||
|
||
| Name | Type | Description |
|
||
|-------------|----------|-------------------------|
|
||
| symbol | string | 标的代码,例如:`AAPL.US` |
|
||
| lines | object[] | 分时数据 |
|
||
| ∟ price | string | 当前分钟的收盘价格 |
|
||
| ∟ timestamp | int64 | 当前分钟的开始时间 |
|
||
| ∟ volume | int64 | 成交量 |
|
||
| ∟ turnover | string | 成交额 |
|
||
| ∟ avg_price | string | 均价 |
|
||
|
||
### Protobuf
|
||
|
||
```
|
||
message SecurityIntradayResponse{
|
||
string symbol = 1;
|
||
repeated Line lines = 2;
|
||
}
|
||
|
||
message Line {
|
||
string price = 1;
|
||
int64 timestamp = 2;
|
||
int64 volume = 3;
|
||
string turnover = 4;
|
||
string avg_price = 5;
|
||
}
|
||
```
|
||
|
||
### Response JSON Example
|
||
|
||
```json
|
||
{
|
||
"symbol": "700.HK",
|
||
"lines": [
|
||
{
|
||
"price": "330.400",
|
||
"timestamp": 1651023000,
|
||
"volume": 375870,
|
||
"turnover": "123949699.000",
|
||
"avg_price": "329.767470"
|
||
},
|
||
{
|
||
"price": "331.200",
|
||
"timestamp": 1651023060,
|
||
"volume": 233095,
|
||
"turnover": "77269032.800",
|
||
"avg_price": "330.427416"
|
||
},
|
||
{
|
||
"price": "330.400",
|
||
"timestamp": 1651023120,
|
||
"volume": 192565,
|
||
"turnover": "63711556.000",
|
||
"avg_price": "330.530719"
|
||
},
|
||
{
|
||
"price": "330.800",
|
||
"timestamp": 1651023180,
|
||
"volume": 143397,
|
||
"turnover": "47471072.400",
|
||
"avg_price": "330.608989"
|
||
},
|
||
{
|
||
"price": "330.800",
|
||
"timestamp": 1651023240,
|
||
"volume": 141834,
|
||
"turnover": "46890605.600",
|
||
"avg_price": "330.608078"
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
## 错误码
|
||
|
||
| 协议错误码 | 业务错误码 | 描述 | 排查建议 |
|
||
|------------|------------|--------------|--------------------------|
|
||
| 3 | 301600 | 无效的请求 | 请求参数有误或解包失败 |
|
||
| 3 | 301606 | 限流 | 降低请求频次 |
|
||
| 7 | 301602 | 服务端内部错误 | 请重试或联系技术人员处理 |
|
||
| 7 | 301600 | 请求标的不存在 | 检查请求的 `symbol` 是否正确 |
|
||
| 7 | 301603 | 标的无行情 | 标的没有请求的行情数据 |
|
||
| 7 | 301604 | 无权限 | 没有获取标的行情的权限 |
|