Order Book (深度)
獲取深度數據
覆蓋範圍: 現貨 / USDT永續 / USDC永續 / USDC交割 / 反向合約 / 期權
- 期貨: 最多返回500檔的數據.
- 現貨: 最多返回200檔的數據.
- 期權: 僅返回25檔的數據.
提示
響應是當前時間的切片數據
HTTP請求
GET /v5/market/orderbook
請求參數
參數 | 是否必需 | 類型 | 說明 |
---|---|---|---|
category | true | string | 產品類型. spot , linear , inverse , option |
symbol | true | string | 合約名稱 |
limit | false | integer | 深度限制.
|
響應參數
參數 | 類型 | 說明 |
---|---|---|
s | string | 合約名稱 |
b | array | Bid, 買方. 按照價格從大到小 |
> b[0] | string | 買方報價 |
> b[1] | string | 買方數量 |
a | array | Ask, 賣方. 按照價格從小到大 |
> a[0] | string | 賣方報價 |
> a[1] | string | 賣方數量 |
ts | integer | 行情服務生成數據時間戳(毫秒) |
u | integer | 表示數據連續性的id.
|
seq | integer | 撮合版本號 |
cts | number | 產生此訂單簿數據時來自撮合引擎的時間戳. 可用於與平台成交頻道中的T 進行關聯 |
請求示例
- HTTP
- Python
- Go
- Java
- Node.js
GET /v5/market/orderbook?category=spot&symbol=BTCUSDT HTTP/1.1
Host: api-testnet.bybit.com
from pybit.unified_trading import HTTP
session = HTTP(testnet=True)
print(session.get_orderbook(
category="linear",
symbol="BTCUSDT",
))
import (
"context"
"fmt"
bybit "github.com/wuhewuhe/bybit.go.api"
)
client := bybit.NewBybitHttpClient("", "", bybit.WithBaseURL(bybit.TESTNET))
params := map[string]interface{}{"category": "spot", "symbol": "BTCUSDT"}
client.NewUtaBybitServiceWithParams(params).GetOrderBookInfo(context.Background())
import com.bybit.api.client.domain.CategoryType;
import com.bybit.api.client.domain.market.*;
import com.bybit.api.client.domain.market.request.MarketDataRequest;
import com.bybit.api.client.service.BybitApiClientFactory;
var client = BybitApiClientFactory.newInstance().newAsyncMarketDataRestClient();
var orderbookRequest = MarketDataRequest.builder().category(CategoryType.SPOT).symbol("BTCUSDT").build();
client.getMarketOrderBook(orderbookRequest,System.out::println);
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
});
client
.getOrderbook({
category: 'linear',
symbol: 'BTCUSDT',
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});
響應示例
{
"retCode": 0,
"retMsg": "OK",
"result": {
"s": "BTCUSDT",
"a": [
[
"65557.7",
"16.606555"
]
],
"b": [
[
"65485.47",
"47.081829"
]
],
"ts": 1716863719031,
"u": 230704,
"seq": 1432604333,
"cts": 1716863718905
},
"retExtInfo": {},
"time": 1716863719382
}